Re: [Tutor] \x00T\x00r\x00i\x00a\x00 ie I get \x00 breaking up every character ?

2011-11-21 Thread Steven D'Aprano
Dave Angel wrote: On 11/20/2011 04:45 PM, Steven D'Aprano wrote: Something in the tool chain before it reached Python has saved it using a wide (four byte) encoding, most likely UTF-16 as that is widely used by Windows and Java. With the right settings, it could take as little as opening th

[Tutor] IndexError: list index out of range

2011-11-21 Thread John
Hi all, I have wriiten the following code: [Segment] def survivor(names, step): index = step - 1 next = names while len(next)> 1: next.remove (next[index]) However when ever i run it i get this error message: Traceback (most recent call last): File "", line 1, in

Re: [Tutor] IndexError: list index out of range

2011-11-21 Thread James Reynolds
On Tue, Nov 22, 2011 at 12:28 AM, John wrote: > > Hi all, > > I have wriiten the following code: > [Segment] > > def survivor(names, step): >>>index = step - 1 >next = names >while len(next)> 1: >next.remove (next[index]) > > > > However when ever i run it i get this e

Re: [Tutor] IndexError: list index out of range

2011-11-21 Thread Alan Gauld
On 22/11/11 05:28, John wrote: def survivor(names, step): index = step - 1 next = names while len(next)> 1: next.remove (next[index]) However when ever i run it i get this error message: next.remove (next[index]) IndexError: list index out of range Any ideas about whats causing this error?

Re: [Tutor] IndexError: list index out of range

2011-11-21 Thread Dave Angel
On 11/22/2011 12:28 AM, John wrote: Hi all, I have wriiten the following code: I can't provide any more clues about your code than the two excellent replies you've already gotten. But it'd be really good if you could fix your time machine, so you're not posting in the future. Really hard

[Tutor] Python code trouble!

2011-11-21 Thread John
Hi all, I have attempted to create a programme which removes every Nth person from the list until there is only one name remaining. N is inputted by the user. Here is the code: def survivor(names, step): next = names while len(next) > 1: index = step - 1 next.remove (next[i

Re: [Tutor] IndexError: list index out of range

2011-11-21 Thread Steven D'Aprano
John wrote: Hi all, I have wriiten the following code: [Segment] def survivor(names, step): index = step - 1 next = names while len(next)> 1: next.remove (next[index]) What is the intention of this function? The name given doesn't mean anything to me. The parameters

Re: [Tutor] IndexError: list index out of range

2011-11-21 Thread Nidian Job-Smith
To answer your questions Steven What is the intention of this function? The name given doesn't mean anything to me. The parameters "names" and "step" don't seem meaningful. I can see what the function does: it deletes bits of something, probably a list, in a convoluted way, eventually causing

Re: [Tutor] Python code trouble!

2011-11-21 Thread Dave Angel
You're still posting from tomorrow. On 11/22/2011 05:50 AM, John wrote: Hi all, I have attempted to create a programme which removes every Nth person from the list until there is only one name remaining. N is inputted by the user. Here is the code: def survivor(names, step): next = nam

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

Re: [Tutor] Python code trouble!

2011-11-21 Thread Steven D'Aprano
Hello John, You are still posting from the future. Please fix your computer so that it is no longer set 12 hours in the future. Or perhaps your computer is just set in the wrong time zone. John wrote: Hi all, I have attempted to create a programme which removes every Nth person from the

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] How to get module name from ImportError

2011-11-21 Thread Steven D'Aprano
nikunj.badja...@emc.com wrote: Hi All, Please look at the following snippet. {{{ # User defined modules try: from scripts import precheck from scripts import validate from scripts import constants except ImportError: print("ERROR: One of the modules (..scripts/precheck.py, valid

[Tutor] File vs. Database (possible off topic)

2011-11-21 Thread Ken G.
It occurred to me last week while reviewing the files I made in using Python, it could be somewhat similar to a database. What would be a different between a Python files and Python databases? Granted, the access in creating them are different, I really don't see any different in the format o

Re: [Tutor] Python code trouble!

2011-11-21 Thread Dave Angel
On 11/21/2011 06:57 PM, Steven D'Aprano wrote: Hello John, You are still posting from the future. Please fix your computer so that it is no longer set 12 hours in the future. Or perhaps your computer is just set in the wrong time zone. John wrote: Hi all, I have attempted to create a pro

Re: [Tutor] File vs. Database (possible off topic)

2011-11-21 Thread Alan Gauld
On 22/11/11 00:24, Ken G. wrote: It occurred to me last week while reviewing the files I made in using Python, it could be somewhat similar to a database. Depending on how broadly you define "database" you could be right. What would be a different between a Python files and Python databases?

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 seq

Re: [Tutor] File vs. Database (possible off topic)

2011-11-21 Thread Modulok
On 11/21/11, Ken G. wrote: > It occurred to me last week while reviewing the files I made in using > Python, it could be somewhat similar to a database. > > What would be a different between a Python files and Python databases? > Granted, the access in creating them are different, I really don't s

Re: [Tutor] IndexError: list index out of range

2011-11-21 Thread Asokan Pichai
On Tue, Nov 22, 2011 at 4:32 AM, Steven D'Aprano wrote: > John wrote: > >> >> Hi all, >> >> I have wriiten the following code: >> [Segment] >> >> def survivor(names, step): > index = step - 1 >>next = names >>while len(next)> 1: >>next.remove (next[index]) >> > > > W

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 a

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 e