[Tutor] Getting confusing NameError

2010-08-18 Thread shane brennan
Hi Tutors This is my first mail to this list so firstly thank you for reading and apologies in advance for any noob mistakes i may have inadvertantly made:). Ive only started learning python as my first programming language and its all going well so far, working my way through a couple of books on

Re: [Tutor] Getting confusing NameError

2010-08-18 Thread Evert Rol
> This is my first mail to this list so firstly thank you for reading and > apologies in advance for any noob mistakes i may have inadvertantly made:). > Ive only started learning python as my first programming language and its all > going well so far, working my way through a couple of books on

Re: [Tutor] Getting confusing NameError

2010-08-18 Thread Nitin Das
use raw_input instead of input . as using input is unsafe as it evaluates your input as python command. for e,g. x = input("enter command") and u entered "1 + 2" as input., then it will evaluate 1+2 = 3 = x. -nitin On Wed, Aug 18, 2010 at 12:45 PM, shane brennan wrote: > Hi Tutors > > This is m

Re: [Tutor] Getting confusing NameError

2010-08-18 Thread Christian Witts
On 18/08/2010 09:15, shane brennan wrote: Hi Tutors This is my first mail to this list so firstly thank you for reading and apologies in advance for any noob mistakes i may have inadvertantly made:). Ive only started learning python as my first programming language and its all going well so fa

Re: [Tutor] box drawing characters

2010-08-18 Thread Alan Gauld
"Bill Allen" wrote I want to be able to create some user interfaces, similar to what you see in console based programs like Midnight Commander or other TUI type programs that use box drawing characters to create a user interfaces for input and display of information. This is OK and you can

Re: [Tutor] Error Using exec to Run Module Files

2010-08-18 Thread Alan Gauld
wrote exec(open('script1.py').read()) Traceback (most recent call last): File "", line 1, in File "", line 1 %!PS-Adobe-3.0 ^ SyntaxError: invalid syntax What is going on/ Looks like your script1.py file is actually a postscript file. exec expects to see valid Python code, it can'

Re: [Tutor] Getting confusing NameError

2010-08-18 Thread Alan Gauld
"shane brennan" wrote In one of the code samples he supplies while doing loops ( namely if and else loops) im getting a NameError i dont understand and cannot find any help anywhere about it. Evert has already pointed out that the code is for Python v3 and it looks like you are using Python

Re: [Tutor] Getting confusing NameError

2010-08-18 Thread shane brennan
Hi all Thank you for all the help. I had upgraded the machine to v3 but for some reason 2 hadnt removed properly, once i did some digigng i found the redundant entries in the registry and the libraries that didnt remove and cleared them up . script is running fine now:) thanks for all the help Es

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Laurens Vets
On 8/12/2010 1:26 AM, Steven D'Aprano wrote: On Thu, 12 Aug 2010 07:04:15 am Laurens Vets wrote: I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, 4, 5& 6. However, I cannot have more than 2 numbers which are the same next to each other. I came up with the following (Please

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Evert Rol
On 18 Aug 2010, at 13:21 , Laurens Vets wrote: > On 8/12/2010 1:26 AM, Steven D'Aprano wrote: >> On Thu, 12 Aug 2010 07:04:15 am Laurens Vets wrote: >> >>> I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, >>> 4, 5& 6. However, I cannot have more than 2 numbers which are the

Re: [Tutor] Getting confusing NameError

2010-08-18 Thread Wayne Werner
On Wed, Aug 18, 2010 at 3:48 AM, shane brennan wrote: > > > again thanks for everything, and hopefully ill be around here for a long > time and once i get a more experienced i can contribute back > You don't need to be /too/ experienced. Contributing here is actually how I learned Python as much

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Laurens Vets
Thank you all for your help! I've added another condition to this program, namely, in a range of 60, each 'random' number can only occur 10 times. I came up with the following: import random series = [] for i in range(60): temp = [random.randint(1, 6)] while series[-2:-1] == series[-1:

Re: [Tutor] box drawing characters

2010-08-18 Thread Bill Allen
On Wed, Aug 18, 2010 at 3:15 AM, Alan Gauld wrote: > > "Bill Allen" wrote > >> I want to be able to create some user interfaces, similar to what you see >>> >> in console based programs like Midnight Commander or other TUI type >> programs >> that use box drawing characters to create a user inter

Re: [Tutor] box drawing characters

2010-08-18 Thread Ewald Horn
Hi Bill, have you given UniCurses a spin? See http://pyunicurses.sourceforge.net/ for more information. I recall finding it online, so it might be worth investigating. Good luck. Regards Ewald ___ Tutor maillist - Tutor@python.org To unsubscribe or

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Dave Angel
Laurens Vets wrote: Yes of course :) That's a typo on my part. I came up with the following which I think works as well? import random reeks = [] for i in range(60): temp = [random.randint(1, 6)] while reeks[-2:-1] == reeks[-1:] == temp: temp = [random.randint(1, 6)] if reeks.

[Tutor] Multiple file open

2010-08-18 Thread nitin chandra
Hi All, @ Alan - Thank you. Your suggestion worked. ( read 2 input file and 1 output file). I am on Python 2.6 I need to process two sets of 96 files and prepare equal no. of sets of 96 files. The first set of 96 files have a formula A and second set of 96 files have formula B. Formula A is deri

Re: [Tutor] box drawing characters

2010-08-18 Thread Alan Gauld
Looks interesting, a new one for me, thanks for posting. Alan G. "Ewald Horn" wrote in message news:aanlktinmkzyxbd0t7rldyexhbanw1tnfzac5z2gee...@mail.gmail.com... Hi Bill, have you given UniCurses a spin? See http://pyunicurses.sourceforge.net/ for more information. I recall finding it on

Re: [Tutor] box drawing characters

2010-08-18 Thread Bill Allen
On Wed, Aug 18, 2010 at 12:36 PM, Alan Gauld wrote: > Looks interesting, a new one for me, thanks for posting. > > Alan G. > > "Ewald Horn" wrote in message > news:aanlktinmkzyxbd0t7rldyexhbanw1tnfzac5z2gee...@mail.gmail.com... > > Hi Bill, >> >> have you given UniCurses a spin? >> >> See http:/

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Steven D'Aprano
On Wed, 18 Aug 2010 09:21:51 pm Laurens Vets wrote: > On 8/12/2010 1:26 AM, Steven D'Aprano wrote: > > On Thu, 12 Aug 2010 07:04:15 am Laurens Vets wrote: > >> I need to generate a list of 30 numbers randomly chosen from 1, 2, > >> 3, 4, 5& 6. However, I cannot have more than 2 numbers which are >

Re: [Tutor] Multiple file open

2010-08-18 Thread Sander Sweers
On 18 August 2010 17:14, nitin chandra wrote: > I am on Python 2.6 > > Please guide with the syntax. All beginners tutorials on the web teach the syntax of python.. I am unsure what your questions is. > below is the existing program with Formula A (Mean). Formula B will be > Extrapolation, > a

[Tutor] Immutable objects

2010-08-18 Thread Nitin Das
Hello, Can somebody help me how to make immutable objects in python. I have seen overriding the __new__, __setattr__ methods.. but not comfortable with how to use them to make the object immutable. thanks in advance --nitin ___ Tutor maillist - T

Re: [Tutor] Immutable objects

2010-08-18 Thread Nitin Das
class mymut(object): def __setattr__(self,k,v): if hasattr(self,k): if self.__dict__.get(k) == None: self.__dict__[k] = v else: raise TypeError("Cant Modify Attribute Value") else: raise TypeError("Immutable Object") class m