Re: [Tutor] Question about login=''.join(choice(lc) for j in range(llen))

2012-04-03 Thread Alan Gauld
On 03/04/12 15:54, Khalid Al-Ghamdi wrote: dom=.join(choice(lc) for j in range (dlen)) how does the interpreter know what j is supposed to refer to when it was not mentioned prior? In Python variables are defined by using them. In the code below you have i used in a for loop, even

Re: [Tutor] Question about login=''.join(choice(lc) for j in range(llen))

2012-04-03 Thread Peter Otten
Alan Gauld wrote: On 03/04/12 15:54, Khalid Al-Ghamdi wrote: dom=.join(choice(lc) for j in range (dlen)) how does the interpreter know what j is supposed to refer to when it was not mentioned prior? In Python variables are defined by using them. In the code below you have i used

Re: [Tutor] Question about login=''.join(choice(lc) for j in range(llen))

2012-04-03 Thread wesley chun
On Tue, Apr 3, 2012 at 10:50 AM, Peter Otten __pete...@web.de wrote: Alan Gauld wrote: On 03/04/12 15:54, Khalid Al-Ghamdi wrote:      dom=.join(choice(lc) for j in range (dlen)) how does the interpreter know what j is supposed to refer to when it was not mentioned prior? +1 everyone

Re: [Tutor] Question about input

2012-03-25 Thread Joel Goldstick
On Sun, Mar 25, 2012 at 1:31 AM, Asif Kazmi akazmi...@gmail.com wrote: Hello, I'm going through Python Programming for the Absolute Beginner, 3rd edition, on a Mac with Python 3.2. In the second chapter, the book gives sample code that shows how a logical error can occur: # Trust Fund

Re: [Tutor] Question about input

2012-03-25 Thread Asif Kazmi
The odd thing is that the same code runs perfectly in the Mac terminal, but incorrectly in Komodo Edit. In the latter, the input prompts are somehow being included into the variables themselves somehow due to the way Komodo works. Thanks for the help. I've just taken to running the code in the

Re: [Tutor] Question about input

2012-03-25 Thread Joel Goldstick
On Sun, Mar 25, 2012 at 11:52 AM, Asif Kazmi akazmi...@gmail.com wrote: The odd thing is that the same code runs perfectly in the Mac terminal, but incorrectly in Komodo Edit. In the latter, the input prompts are somehow being included  into the variables themselves somehow due to the way

[Tutor] Question about input

2012-03-24 Thread Asif Kazmi
Hello, I'm going through Python Programming for the Absolute Beginner, 3rd edition, on a Mac with Python 3.2. In the second chapter, the book gives sample code that shows how a logical error can occur: # Trust Fund Buddy - Bad # Demonstrates a logical error print( Trust Fund Buddy

Re: [Tutor] question on self

2012-03-12 Thread Alan Gauld
On 12/03/12 02:02, Michael Lewis wrote: I have another method called take turns (not shown for brevity purposes). When I want to call it, why can't I just call it like a function and use TakeTurns() instead of self.TakeTurns()? The Steve's have given technical answers, its also stylistically

[Tutor] question on self

2012-03-11 Thread Michael Lewis
Why do I have to use self.example when calling a method inside a class? For example: def Play(self): '''find scores, reports winners''' self.scores = [] for player in range(self.players): print print 'Player', player + 1

Re: [Tutor] question on self

2012-03-11 Thread Steven D'Aprano
On Sun, Mar 11, 2012 at 07:02:11PM -0700, Michael Lewis wrote: Why do I have to use self.example when calling a method inside a class? For example: def Play(self): '''find scores, reports winners''' self.scores = [] for player in range(self.players):

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

2012-03-09 Thread Marko Limbek
Hi Walter I understand, thank you. Maybe I am trying to do what is not meant to be done. I tried as you suggested mySavReaderObject = SavReader(savFileName) mySavReaderObject.getNumberofVariables(savFileName, mySavReaderObject.fh, mySavReaderObject.spssio) but it won't work File

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

2012-03-09 Thread Walter Prins
Hi Marko, On 9 March 2012 08:34, Marko Limbek marko.lim...@valicon.net wrote:  File C:\Dropbox\Exc_MarkoL_Zenel\Python\crosstabs\src\src\rw.py, line 715, in module    mySavReaderObject.getNumberofVariables(savFileName, mySavReaderObject.fh, mySavReaderObject.spssio) AttributeError:

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

2012-03-09 Thread Marko Limbek
Hi Walter It is as you say. Thanks for long explanation. I am using the newer version. Now I also understand difference between single underscore and double underscore. I would still have problems if I would want to programme them for instance. Well I always try to be independent and I want to

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

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

2012-03-07 Thread Marko Limbek
? ~~ From: Marko Limbek marko.lim...@valicon.net To: cwi...@compuscan.co.za Cc: tutor@python.org Sent: Monday, March 5, 2012 2:05 PM Subject: Re: [Tutor] Question about writing to Excel

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

2012-03-07 Thread Steven D'Aprano
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() for line in sav: process(line) but I am get errors Will you tell us

Re: [Tutor] question about operator overloading

2012-03-06 Thread Peter Otten
Dave Angel wrote: On 03/05/2012 06:20 PM, Alan Gauld wrote: On 05/03/12 21:25, Dave Angel wrote: It's not clear what __add__() should mean for physical files. My guess would be similar to the cat operator in Unix: $ cat file1, file2 file3 is equivalent to file3 = file1 + file2 But

Re: [Tutor] question about operator overloading

2012-03-06 Thread Alan Gauld
On 06/03/12 02:42, Dave Angel wrote: My guess would be similar to the cat operator in Unix: file3 = file1 + file2 So somehow assigning the object to file3 will write the data to a file by the name file3 ? I know about __add__(), but didn't know we had __assign__() We don't need any

Re: [Tutor] question about operator overloading

2012-03-06 Thread Albert-Jan Roskam
From: Steven D'Aprano st...@pearwood.info To: tutor@python.org Sent: Tuesday, March 6, 2012 1:58 AM Subject: Re: [Tutor] question about operator overloading Alan Gauld wrote: On 05/03/12 21:25, Dave Angel wrote: It's not clear what __add__() should mean for physical files. My guess would

Re: [Tutor] question about operator overloading

2012-03-06 Thread Joel Goldstick
On Tue, Mar 6, 2012 at 7:05 AM, Albert-Jan Roskam fo...@yahoo.com wrote: From: Steven D'Aprano st...@pearwood.info To: tutor@python.org Sent: Tuesday, March 6, 2012 1:58 AM Subject: Re: [Tutor] question about operator overloading Alan Gauld wrote: On 05/03/12 21:25, Dave Angel wrote

[Tutor] Question about writing to Excel with slavic characters

2012-03-05 Thread Marko Limbek
Hi everyone. I am new to list and few months old to Python. I am writing some text to Excel and I open the new book and try to write to the book and the save it using book.save Now when I write slavic characters in the text to Excel (č, š, ž, for instance 0xc5), I get an error, I can't save

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

2012-03-05 Thread Christian Witts
On 2012/03/05 02:37 PM, Marko Limbek wrote: Hi everyone. I am new to list and few months old to Python. I am writing some text to Excel and I open the new book and try to write to the book and the save it using book.save Now when I write slavic characters in the text to Excel (č, š, ž, for

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

2012-03-05 Thread Marko Limbek
Thank you! That was easy. Now I have another problem. I use RPy and read the spss database with method read.spss inside a nested R code in Python, that looks like that: import rpy r( library(foreign) baza - read.spss( + analysis[0] + ) print(baza$demo_izob0) ) Now when my text data labels

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

2012-03-05 Thread Christian Witts
On 2012/03/05 03:05 PM, Marko Limbek wrote: Thank you! That was easy. Now I have another problem. I use RPy and read the spss database with method read.spss inside a nested R code in Python, that looks like that: import rpy r( library(foreign) baza- read.spss( + analysis[0] + )

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

2012-03-05 Thread Steven D'Aprano
Marko Limbek wrote: Thank you! That was easy. Now I have another problem. I use RPy and read the spss database with method read.spss inside a nested R code in Python, that looks like that: import rpy r( library(foreign) baza - read.spss( + analysis[0] + ) print(baza$demo_izob0) ) Now when

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

2012-03-05 Thread Albert-Jan Roskam
the Romans ever done for us? ~~  From: Marko Limbek marko.lim...@valicon.net To: cwi...@compuscan.co.za Cc: tutor@python.org Sent: Monday, March 5, 2012 2:05 PM Subject: Re: [Tutor] Question about

[Tutor] question about operator overloading

2012-03-05 Thread Albert-Jan Roskam
Hi, I am extending a program for a hobby project where potentially huge spss files are read. I would like to add functionality to append files. I thought it would be nice and intuitive to overload + and += for this. The code below is a gross simplification, but I want to get the basics right.

Re: [Tutor] question about operator overloading

2012-03-05 Thread Dave Angel
On 03/05/2012 03:16 PM, Albert-Jan Roskam wrote: Hi, I am extending a program for a hobby project where potentially huge spss files are read. I would like to add functionality to append files. I thought it would be nice and intuitive to overload + and += for this. The code below is a gross

Re: [Tutor] question about operator overloading

2012-03-05 Thread Albert-Jan Roskam
? ~~  From: Dave Angel d...@davea.name To: Albert-Jan Roskam fo...@yahoo.com Cc: Python Mailing List tutor@python.org Sent: Monday, March 5, 2012 9:36 PM Subject: Re: [Tutor] question about operator overloading On 03/05/2012 03:16 PM, Albert-Jan Roskam wrote: Hi

Re: [Tutor] question about operator overloading

2012-03-05 Thread Dave Angel
On 03/05/2012 04:10 PM, Albert-Jan Roskam wrote: Hi Dave, aha! Good thing I asked. ;-) I've indeed been thinking where this __add__ method should live. The program as it is now has a Generic class, a Reader class and a Writer class. I thought an Append class was appropriate because it uses

Re: [Tutor] question about operator overloading

2012-03-05 Thread Alan Gauld
On 05/03/12 21:25, Dave Angel wrote: It's not clear what __add__() should mean for physical files. My guess would be similar to the cat operator in Unix: $ cat file1, file2 file3 is equivalent to file3 = file1 + file2 But of course, thats just my interpretation of file addition... --

Re: [Tutor] question about operator overloading

2012-03-05 Thread Joel Goldstick
On Mon, Mar 5, 2012 at 6:20 PM, Alan Gauld alan.ga...@btinternet.com wrote: On 05/03/12 21:25, Dave Angel wrote: It's not clear what __add__() should mean for physical files. My guess would be similar to the cat operator in Unix: $ cat file1, file2 file3 is equivalent to file3 = file1

Re: [Tutor] question about operator overloading

2012-03-05 Thread Joel Goldstick
On Mon, Mar 5, 2012 at 6:35 PM, Joel Goldstick joel.goldst...@gmail.com wrote: On Mon, Mar 5, 2012 at 6:20 PM, Alan Gauld alan.ga...@btinternet.com wrote: On 05/03/12 21:25, Dave Angel wrote: It's not clear what __add__() should mean for physical files. My guess would be similar to the cat

Re: [Tutor] question about operator overloading

2012-03-05 Thread Steven D'Aprano
Alan Gauld wrote: On 05/03/12 21:25, Dave Angel wrote: It's not clear what __add__() should mean for physical files. My guess would be similar to the cat operator in Unix: $ cat file1, file2 file3 is equivalent to file3 = file1 + file2 But of course, thats just my interpretation of file

Re: [Tutor] question about operator overloading

2012-03-05 Thread Dave Angel
On 03/05/2012 06:20 PM, Alan Gauld wrote: On 05/03/12 21:25, Dave Angel wrote: It's not clear what __add__() should mean for physical files. My guess would be similar to the cat operator in Unix: $ cat file1, file2 file3 is equivalent to file3 = file1 + file2 But of course, thats just

[Tutor] Question about an example in Python doc

2012-02-10 Thread daedae11
The example is the third example in (Python2.7's doc)-(Python Library Reference)-17.2.2. The code of the example is: import socket # the public network interface HOST = socket.gethostbyname(socket.gethostname()) # create a raw socket and bind it to the public interface s =

Re: [Tutor] Question about an example in Python doc

2012-02-10 Thread Hugo Arts
On Fri, Feb 10, 2012 at 3:12 PM, daedae11 daeda...@126.com wrote: The example is the third example in (Python2.7's doc)-(Python Library Reference)-17.2.2. The code of the example is: import socket # the public network interface HOST = socket.gethostbyname(socket.gethostname()) # create a 

Re: [Tutor] Question on how to do exponents

2012-02-07 Thread Alan Gauld
On 07/02/12 01:01, Nate Lastname wrote: Exponents ... are **(or ^) Not quite the ^ operator is a bitwise XOR... 2^2 0 2^1 3 pow() is the other way to do exponents. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] Question on how to do exponents

2012-02-07 Thread Sarma Tangirala
On 7 February 2012 13:49, Alan Gauld alan.ga...@btinternet.com wrote: On 07/02/12 01:01, Nate Lastname wrote: Exponents ... are **(or ^) Not quite the ^ operator is a bitwise XOR... 2^2 0 2^1 3 pow() is the other way to do exponents. Is is better to use pow() against **? --

Re: [Tutor] Question on how to do exponents

2012-02-07 Thread Alan Gauld
On 07/02/12 16:54, Sarma Tangirala wrote: Is is better to use pow() against **? I suspect ** will be faster since it doesn't have the function call overhead. But I haven't tried timing it. Feel free to do some tests and find out. Let us know how you get on! -- Alan G Author of the Learn to

Re: [Tutor] Question on how to do exponents

2012-02-07 Thread Steven D'Aprano
Sarma Tangirala wrote: Is is better to use pow() against **? Advantages of ** - it is shorter to type x**y vs pow(x, y) - being an operator, it is slightly faster than calling a function - you can't monkey-patch it Disadvantages of ** - being an operator, you can't directly use it as a

Re: [Tutor] Question on how to do exponents

2012-02-07 Thread Sarma Tangirala
On 8 February 2012 00:01, Steven D'Aprano st...@pearwood.info wrote: Sarma Tangirala wrote: Is is better to use pow() against **? Advantages of ** - it is shorter to type x**y vs pow(x, y) - being an operator, it is slightly faster than calling a function - you can't monkey-patch it

Re: [Tutor] Question on how to do exponents

2012-02-07 Thread Dave Angel
On 02/07/2012 01:57 PM, Sarma Tangirala wrote: On 8 February 2012 00:01, Steven D'Apranost...@pearwood.info wrote: Sarma Tangirala wrote: Is is better to use pow() against **? Advantages of ** - it is shorter to type x**y vs pow(x, y) - being an operator, it is slightly faster than

Re: [Tutor] Question on how to do exponents

2012-02-07 Thread bob gailer
On 2/7/2012 1:57 PM, Sarma Tangirala wrote: Anyway, I was wondering about this, if internally pow() actually uses **. :P from dis import dis dis(lambda a,b:a**b) 1 0 LOAD_FAST0 (a) 3 LOAD_FAST1 (b) 6 BINARY_POWER

[Tutor] Question on how to do exponents

2012-02-06 Thread William Stewart
Hello everyone, I am making a calculator and I need to know how to make it do exponents and remainders How can I input this info in python? Any help would be appreciated Thanks --- On Mon, 2/6/12, Steven D'Aprano st...@pearwood.info wrote: From: Steven D'Aprano st...@pearwood.info Subject: Re:

Re: [Tutor] Question on how to do exponents

2012-02-06 Thread Nate Lastname
Exponents and remainder (modulus) are **(or ^) and % respectively. I.E.; d = a ** b (exponent) c = a % b (modulus) There you are! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] Question on how to do exponents

2012-02-06 Thread Steven D'Aprano
On Mon, Feb 06, 2012 at 04:54:57PM -0800, William Stewart wrote: Hello everyone, I am making a calculator and I need to know how to make it do exponents and remainders How can I input this info in python? Any help would be appreciated You can do exponents either with the ** operator or the

Re: [Tutor] Question regarding setup.py

2012-01-27 Thread Evert Rol
I had a question regarding installing packages that I posted a couple of days ago. But I'm re-sending the question again.. this time with output so that it is clearer. I am unable to install libraries using 'python setup.py install' Say that I'm installing a package kando. I extract it

[Tutor] Question regarding setup.py

2012-01-26 Thread sp6
Hi All, I had a question regarding installing packages that I posted a couple of days ago. But I'm re-sending the question again.. this time with output so that it is clearer. I am unable to install libraries using 'python setup.py install' Say that I'm installing a package kando. I

Re: [Tutor] Question about install.py

2012-01-19 Thread Evert Rol
Hi, I'm new to Python and was wondering if someone could answer a question I have. Say that I have a python library, arithmetic-0.5, located at /X/arithmetic-0.5 I'd like to run setup and install it. But I guess since /X/arithmetic-0.5 is not in install.py's default search path, it comes

[Tutor] Question about install.py

2012-01-18 Thread sp6
Hello, I'm new to Python and was wondering if someone could answer a question I have. Say that I have a python library, arithmetic-0.5, located at /X/arithmetic-0.5 I'd like to run setup and install it. But I guess since /X/arithmetic-0.5 is not in install.py's default search path, it comes

[Tutor] question about a exercise

2012-01-05 Thread daedae11
The exercise is: Write a function which has 3 parameters. First parameter is a char, second parameter is a integer, third parameter is a integer. The function would create a file which have following requests: 1. the length of the file is in accordance with the third parameter. 2. the content of

Re: [Tutor] question about a exercise

2012-01-05 Thread Alexander
On Thu, Jan 5, 2012 at 10:22 AM, daedae11 daeda...@126.com wrote: ** The exercise is: Write a function which has 3 parameters. First parameter is a char, second parameter is a integer, third parameter is a integer. The function would create a file which have following requests: 1. the

Re: [Tutor] question about a exercise

2012-01-05 Thread Wayne Werner
On Thu, Jan 5, 2012 at 9:22 AM, daedae11 daeda...@126.com wrote: ** The exercise is: Write a function which has 3 parameters. First parameter is a char, second parameter is a integer, third parameter is a integer. The function would create a file which have following requests: 1. the

[Tutor] question about gzip module

2012-01-05 Thread daedae11
Is there anyone who can give me an example of how to use the gzip module? I have read the document, but there is no example in the document. Thank you!! daedae11___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] question about gzip module

2012-01-05 Thread lzantal
Good morning, I learned it (and many other modules) from pymotw. Here is a direct link to the gzip week. http://www.doughellmann.com/PyMOTW/gzip/index.html#module-gzip lzantal On Jan 5, 2012, at 7:45 AM, daedae11 wrote: Is there anyone who can give me an example of how to use the gzip

Re: [Tutor] question about gzip module

2012-01-05 Thread Walter Prins
Hi, On 5 January 2012 15:45, daedae11 daeda...@126.com wrote: Is there anyone who can give me an example of how to use the gzip module? I have read the document, but there is no example in the document. Which document are you referring to? The Official Python documentation does in fact

[Tutor] question about the exercises in core python programing

2012-01-04 Thread daedae11
Who can give me an example program about the exercise 4 in chapter 9 in core python programming ? daedae11___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] question about the exercises in core python programing

2012-01-04 Thread daedae11
Who can give me an example program about the exercise 4 in chapter 9 in core python programming ? Thank you! daedae11___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] question about the exercises in core python programing

2012-01-04 Thread Walter Prins
Hi daedae11, 2012/1/4 daedae11 daeda...@126.com: Who can give me an example program about the exercise 4 in chapter 9 in core python programming ? Thank you! You're limiting the number of people who might help you by not posting the excercise/problem you're having directly and instead only

[Tutor] question about the an exercise in core python programing (including the discription about the exercise)

2012-01-04 Thread daedae11
Who can give me an example program about the exercise 6 in chapter 9 in core python programming ? The exercise is: Write a program that compare the two files given by users. If the two files' content is equal, just print equal. Else, print the rows And column number of the first different

Re: [Tutor] question about the an exercise in core python programing (including the discription about the exercise)

2012-01-04 Thread David Palao
Hi, some hints: 1) strings are iterables 2) help(zip) 3) help(enumerate) Best regards. 2012/1/4 daedae11 daeda...@126.com ** Who can give me an example program about the exercise 6 in chapter 9 in core python programming ? The exercise is: Write a program that compare the two files given

Re: [Tutor] question about the an exercise in core python programing (including the discription about the exercise)

2012-01-04 Thread Alan Gauld
On 04/01/12 14:13, David Palao wrote: Hi, some hints: 1) strings are iterables And so are files ;-) 2) help(zip) 3) help(enumerate) Write a program that compare the two files given by users. If the two files' content is equal, just print equal. Else, print the rows And

Re: [Tutor] question about the an exercise in core python programing (including the discription about the exercise)

2012-01-04 Thread Joel Goldstick
On Wed, Jan 4, 2012 at 9:36 AM, Alan Gauld alan.ga...@btinternet.com wrote: On 04/01/12 14:13, David Palao wrote: Hi, some hints: 1) strings are iterables And so are files ;-) 2) help(zip) 3) help(enumerate)    Write a program that compare the two files given by users. If the    

Re: [Tutor] question about the an exercise in core python programing (including the discription about the exercise)

2012-01-04 Thread Alan Gauld
On 04/01/12 14:54, Joel Goldstick wrote: two files' content is equal, just print equal. Else, print the rows And column number of the first different position. while True: line = f1.readline() if line != f2.readline(): print lineNum, : , line # in here I believe you

[Tutor] question about pywin32

2011-12-26 Thread daedae11
Does pywin32 provide a module for AES encryption algorithm ? The description of some module in pywin32 document is so simple that there is not introduction about the function of the function. For example, CryptProtectData function in module win32crypt.

Re: [Tutor] question about pywin32

2011-12-26 Thread Lie Ryan
On 12/27/2011 12:18 AM, daedae11 wrote: Does pywin32 provide a module for AES encryption algorithm ? The description of some module in pywin32 document is so simple that there is not introduction about the function of the function. For example, CryptProtectData function in module win32crypt.

Re: [Tutor] question about pywin32

2011-12-26 Thread Lie Ryan
On 12/27/2011 02:58 AM, Lie Ryan wrote: On 12/27/2011 12:18 AM, daedae11 wrote: Does pywin32 provide a module for AES encryption algorithm ? The description of some module in pywin32 document is so simple that there is not introduction about the function of the function. For example,

Re: [Tutor] question about pywin32

2011-12-26 Thread Marc Tompkins
On Mon, Dec 26, 2011 at 5:18 AM, daedae11 daeda...@126.com wrote: ** Does pywin32 provide a module for AES encryption algorithm ? The description of some module in pywin32 document is so simple that there is not introduction about the function of the function. For example, CryptProtectData

Re: [Tutor] question about the build-in function reversed in Python2.5

2011-12-25 Thread Steven D'Aprano
daedae11 wrote: The build-in function reversed() in Python2.5 returns a iterator. But I don't know how to use the iterator. Please give me a simple example about how to use bulid-in function reversed() to reverse a list. You use the iterator the same way you would any other iterator: * in

[Tutor] question about the build-in function reversed in Python2.5

2011-12-24 Thread daedae11
The build-in function reversed() in Python2.5 returns a iterator. But I don't know how to use the iterator. Please give me a simple example about how to use bulid-in function reversed() to reverse a list. Thank you in advance. daedae11___ Tutor

Re: [Tutor] question about the build-in function reversed in Python2.5

2011-12-24 Thread bob gailer
On 12/25/2011 12:02 AM, daedae11 wrote: The build-in function reversed() in Python2.5 returns a iterator. But I don't know how to use the iterator. Please give me a simple example about how to use bulid-in function reversed() to reverse a list. [x for x in reversed([1,2,3])] [3, 2, 1]

Re: [Tutor] Question

2011-12-03 Thread Alan Gauld
On 03/12/11 08:31, Michael Hall wrote: # a) write a function, getDivisors(), that returns a list of all # of the positive divisors of a given number. This is a very clear statement of what you need to do. def getDivisors(num): my_list = [] sum = 0 for number in range(1, num,

Re: [Tutor] Question

2011-12-03 Thread Walter Prins
Hello Michael, On 3 December 2011 08:31, Michael Hall michael.hall5...@gmail.com wrote: Andreas and others Thank you for your help. I am still having an issues. I went to the links and they were very helpful. Would you mind explaining exactly how they helped you? :) Here is my problem. If

Re: [Tutor] Question on List Comprehensions

2011-11-22 Thread Steve Willoughby
On 21-Nov-11 23:49, Charles Becker wrote: Alan, Steve, future readers, After some re-reading and hacking I was able to discover the solution. Since I raised the question here it is : [['{0}'.format(x+1), x+1] for x in range(size)] Just to fill out some other refinements for your

[Tutor] Question on List Comprehensions

2011-11-21 Thread Charles Karl Becker
I'm trying to use a list comprehension to build a list with a variable number of lists nested within it (ideally eventually going several levels of nesting). However I seem to be observing some strange behavior and was wondering if anyone could take a look at this and tell me if what I'm trying

Re: [Tutor] Question on List Comprehensions

2011-11-21 Thread Steven D'Aprano
Charles Karl Becker wrote: I'm trying to use a list comprehension to build a list with a variable number of lists nested within it (ideally eventually going several levels of nesting). However I seem to be observing some strange behavior and was wondering if anyone could take a look at this and

Re: [Tutor] Question on List Comprehensions

2011-11-21 Thread Alan Gauld
On 22/11/11 00:10, Steven D'Aprano wrote: Because you don't have a list comprehension. You can't put add arbitrary code inside a square brackets [ ]. You have to follow the syntax for a list comprehension: listcomp = [expression for name in sequence] not listcomp = [expression for name in

Re: [Tutor] Question on List Comprehensions

2011-11-21 Thread Charles Karl Becker
Steven and Alan, Thank you for your comments! Alan said: Because you don't have a list comprehension. You can't put add arbitrary code inside a square brackets [ ]. You have to follow the syntax for a list comprehension: This helps me understand a lot when looking back, I thought that any

Re: [Tutor] Question on List Comprehensions

2011-11-21 Thread Charles Becker
Alan, Steve, future readers, After some re-reading and hacking I was able to discover the solution. Since I raised the question here it is : [['{0}'.format(x+1), x+1] for x in range(size)] This will create the list with nested lists for whatever number 'size' is set to. This should be good

[Tutor] Question about graphics.

2011-11-09 Thread Nathaniel Trujillo
I installed livewires for python 2.x so should that work with python version 2.7.2 ? I typed in the code you see below and got the following error message. Here is the code. from livewires import games and here is the error message Traceback (most recent call last): File

Re: [Tutor] Question about GUI applications.

2011-11-08 Thread Alan Gauld
On 08/11/11 04:30, Nathaniel Trujillo wrote: I just wrote the following GUI application. How do I get rid of the 7k in the upper left hand corner and how to I put other stuff there like say a picture of someone. Thanks for the help. If you are using Windows I don't think you can, due to a bug

Re: [Tutor] Question about GUI applications.

2011-11-08 Thread Steve Willoughby
On 08-Nov-11 00:39, Alan Gauld wrote: On 08/11/11 04:30, Nathaniel Trujillo wrote: I just wrote the following GUI application. How do I get rid of the 7k in the upper left hand corner and how to I put other stuff there like say a picture of someone. Thanks for the help. If you are using

Re: [Tutor] Question about GUI applications.

2011-11-08 Thread Alan Gauld
On 08/11/11 15:56, Steve Willoughby wrote: I can't recall what it is, but its similar to the one used for setting the title text on the Window, one of the wm_x calls. I have an app I'm developing and running successfully on Windows ... root = Tkinter.Tk()

Re: [Tutor] Question about GUI applications.

2011-11-08 Thread Alan Gauld
On 08/11/11 15:56, Steve Willoughby wrote: I have an app I'm developing and running successfully on Windows (as well as OSX and Linux). At least in this case it is able to replace the application icon in place of the default TK one. The code I use is: root = Tkinter.Tk()

Re: [Tutor] Question about GUI applications.

2011-11-08 Thread Steve Willoughby
On 08-Nov-11 16:38, Alan Gauld wrote: I note it says this sets the bitmap for the iconified widget. That to me means the icon on the desktop, or in the Taskbar. Can you confirm that it also sets the icon at top left in the title bar? Yes, it changes the top left of the application window. To

[Tutor] Question about GUI applications.

2011-11-07 Thread Nathaniel Trujillo
I just wrote the following GUI application. How do I get rid of the 7k in the upper left hand corner and how to I put other stuff there like say a picture of someone. Thanks for the help. Here is the GUI application. It is called mad_lib.py.py # Mad Lib # Create a story based on user input from

[Tutor] Question about sorting a list within a dictionary within a list

2011-08-01 Thread ian douglas
I'm using the Bono library for talking to EC2, and I'm getting a list of EC2 instances back in a list called reservations. Each element in the list is a dictionary of information. One of those dictionary elements is a list called 'instances', and I only ever care about the first entry. That

Re: [Tutor] Question about sorting a list within a dictionary within a list

2011-08-01 Thread Peter Otten
ian douglas wrote: I'm using the Bono library for talking to EC2, and I'm getting a list of EC2 instances back in a list called reservations. Each element in the list is a dictionary of information. One of those dictionary elements is a list called 'instances', and I only ever care about the

Re: [Tutor] Question about sorting a list within a dictionary within a list

2011-08-01 Thread ian douglas
On 08/01/2011 01:03 PM, Peter Otten wrote: ian douglas wrote: I'm using the Bono library for talking to EC2, and I'm getting a list of I cannot help you with the django or boto part. Well, I suppose that using django/bono wasn't really relevant to the question. I appreciate the feedback

Re: [Tutor] Question about sorting a list within a dictionary within a list

2011-08-01 Thread Peter Otten
ian douglas wrote: On 08/01/2011 01:03 PM, Peter Otten wrote: ian douglas wrote: I'm using the Bono library for talking to EC2, and I'm getting a list of I cannot help you with the django or boto part. Well, I suppose that using django/bono wasn't really relevant to the question. I

Re: [Tutor] Question about sorting a list within a dictionary within a list

2011-08-01 Thread Peter Otten
Peter Otten wrote: Untested: from operator import attrgetter, itemgetter from itertools import imap firsts = imap(itemgetter(0), conn.get_all_instances()) reservations = sorted(firsts, key=attrgetter(launch_time)) This gives you objects rather than the objects' __dict__s. Oops, I

[Tutor] Question related to Tkinker

2011-07-24 Thread Emeka
Hello All, I am putting up a simple game .. the game is about manipulation. If the gets through level one ... I have to change the word with another... Am I going to destroy level window and build level 2 or is there a way to just adjust the word (I used labels) Regards, Janus -- *Satajanus

Re: [Tutor] Question related to Tkinker

2011-07-24 Thread Corey Richardson
Excerpts from Emeka's message of Sun Jul 24 02:56:02 -0400 2011: Hello All, I am putting up a simple game .. the game is about manipulation. If the gets through level one ... I have to change the word with another... Am I going to destroy level window and build level 2 or is there a way to

Re: [Tutor] Question related to Tkinker

2011-07-24 Thread Emeka
for i,cha in enumerate(wordi): label = Label(root, image=photoimage, text = cha) label.grid(row=1, column=i, columnspan=1, rowspan=1,sticky=W+E+N+S, padx=0, pady=1) label1 = Label(root, image=IMAGE) I used grid ... Though I used labels, I was dealing only on character level. So for

Re: [Tutor] Question related to Tkinker

2011-07-24 Thread Peter Otten
Emeka wrote: for i,cha in enumerate(wordi): label = Label(root, image=photoimage, text = cha) label.grid(row=1, column=i, columnspan=1, rowspan=1,sticky=W+E+N+S, padx=0, pady=1) label1 = Label(root, image=IMAGE) I used grid ... Though I used labels, I was dealing only on

[Tutor] Question regarding xml.dom.minidom: How do you send an unsignedByte in an wsdl request

2011-07-22 Thread Garry Bettle
Howdy all, Hope this message finds everyone well - roll on the weekend! I'm trying some calls to an wsdl API I've subscribed to. But I'm struggling to know what they want when sending an unsignedByte in a request. I'm using xml.dom.minidom so to start with I have: from xml.dom.minidom import

Re: [Tutor] Question regarding xml.dom.minidom: How do you send an unsignedByte in an wsdl request

2011-07-22 Thread Emile van Sebille
You'll likely get more traction on this at http://mail.python.org/mailman/listinfo/xml-sig Emile On 7/22/2011 11:18 AM Garry Bettle said... Howdy all, Hope this message finds everyone well - roll on the weekend! I'm trying some calls to an wsdl API I've subscribed to. But I'm struggling

Re: [Tutor] Question regarding xml.dom.minidom: How do you send an unsignedByte in an wsdl request

2011-07-22 Thread James Reynolds
On Fri, Jul 22, 2011 at 2:18 PM, Garry Bettle garry.bet...@gmail.comwrote: Howdy all, Hope this message finds everyone well - roll on the weekend! I'm trying some calls to an wsdl API I've subscribed to. But I'm struggling to know what they want when sending an unsignedByte in a request.

<    1   2   3   4   5   6   7   8   9   10   >