Re: [Tutor] Need a solution.

2009-06-12 Thread David
Alan Gauld wrote: This is a bad choice of class. It is a verb which is indicative that its not an object. Objects are nearly always nouns. You could use GuessableNumber. Then it would have a number attribute which is the number to guess. It could have a generate() ,method which produces a new

Re: [Tutor] use of __new__

2009-06-12 Thread Lie Ryan
spir wrote: > Le Fri, 12 Jun 2009 22:37:17 +1000, > Lie Ryan s'exprima ainsi: > > Right, thank you. I continued my trials and ended with seemingly working > code, close to yours. > > # case pattern is Klass: yield String instead > if isinstance(pattern,Klass): >

Re: [Tutor] parallel port commands

2009-06-12 Thread Alan Gauld
"Jacob Mansfield" wrote does anyone know how to replace the C comands inp() and outb() these are used for parallel port communication These are non standard C functions and will depend on your compiler, OS and hardware. You might be able to access them from Python via the ctypes module,

Re: [Tutor] quarry,

2009-06-12 Thread Alan Gauld
"csarita bhandari" wrote I have download python version 3.0.1 windows installer, but problem occur during installing it. And the problem is " Your Administration don't permit to install this program". Thats a windows problem not Python. You need to get an account with Admin access. Wh

Re: [Tutor] use of __new__

2009-06-12 Thread Kent Johnson
On Fri, Jun 12, 2009 at 10:03 AM, spir wrote: > Don't you have a comment in the 'if' case, too? Namely that __init__ is not > invoked explicitely, while the docs clearly state: > > << f __new__() returns an instance of cls, then the new instance’s __init__() > method will be invoked like __init__

Re: [Tutor] use of __new__

2009-06-12 Thread spir
Le Fri, 12 Jun 2009 09:05:35 -0400, Kent Johnson s'exprima ainsi: > On Fri, Jun 12, 2009 at 8:37 AM, Lie Ryan wrote: > class Normal(object): > > ...     def __new__(cls, arg): > > ...         if arg: > > ...             return Special(arg) > > ...         else: > > ...             ret = supe

Re: [Tutor] use of __new__

2009-06-12 Thread Kent Johnson
On Fri, Jun 12, 2009 at 9:48 AM, spir wrote: > Right, thank you. I continued my trials and ended with seemingly working > code, close to yours. > >                # case pattern is Klass: yield String instead >                if isinstance(pattern,Klass): >                        self = String(pat

[Tutor] parallel port commands

2009-06-12 Thread Jacob Mansfield
does anyone know how to replace the C comands inp() and outb() these are used for parallel port communication ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] use of __new__

2009-06-12 Thread spir
Le Fri, 12 Jun 2009 22:37:17 +1000, Lie Ryan s'exprima ainsi: > >>> class Normal(object): > ... def __new__(cls, arg): > ... if arg: > ... return Special(arg) > ... else: > ... ret = super(Normal, cls).__new__(cls) > ... ret.__init__(arg)

Re: [Tutor] use of __new__

2009-06-12 Thread spir
Le Fri, 12 Jun 2009 22:37:17 +1000, Lie Ryan s'exprima ainsi: > spir wrote: > > Hello, > > > > I have (again) some issue using __new__. > > What I need is basically to catch an object creation and yield an object > > of an alternate type, when a condition is met. > > > > Basically, the outline

[Tutor] Fw: use of __new__

2009-06-12 Thread spir
Le Fri, 12 Jun 2009 14:20:24 +0200, "A.T.Hofkamp" s'exprima ainsi: > spir wrote: > > Hello, > > > > I have (again) some issue using __new__. > > What I need is basically to catch an object creation and yield an object > > of an alternate type, when a condition is met. > > > > Basically, the out

Re: [Tutor] use of __new__

2009-06-12 Thread Kent Johnson
On Fri, Jun 12, 2009 at 8:37 AM, Lie Ryan wrote: class Normal(object): > ...     def __new__(cls, arg): > ...         if arg: > ...             return Special(arg) > ...         else: > ...             ret = super(Normal, cls).__new__(cls) > ...             ret.__init__(arg) > ...            

Re: [Tutor] use of __new__

2009-06-12 Thread Lie Ryan
spir wrote: > Hello, > > I have (again) some issue using __new__. > What I need is basically to catch an object creation and yield an object of > an alternate type, when a condition is met. > > Basically, the outline looks like: > > class Normal(object): > def __new__(cls, arg): > i

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-12 Thread Wayne
On Fri, Jun 12, 2009 at 2:49 AM, eShopping wrote: > > Hm .does this mean we are snookered on Win XP? Well, strictly using python anyway. I'm not sure precisely how the ctypes module works, but it's a fairly simple amount of code in assembly to push characters into the keyboard buffer. I pre

Re: [Tutor] use of __new__

2009-06-12 Thread A.T.Hofkamp
spir wrote: Hello, I have (again) some issue using __new__. What I need is basically to catch an object creation and yield an object of an alternate type, when a condition is met. Basically, the outline looks like: class Normal(object): def __new__(cls, arg): if cond(arg):

Re: [Tutor] quarry,

2009-06-12 Thread Wayne
On Fri, Jun 12, 2009 at 2:48 AM, csarita bhandari < csaritabhandari...@hotmail.com> wrote: > Dear sir/madam, > > I have download python version 3.0.1 windows installer, but problem occur > during installing it. And the problem is " Your Administration don't permit > to install this program". Wha

[Tutor] use of __new__

2009-06-12 Thread spir
Hello, I have (again) some issue using __new__. What I need is basically to catch an object creation and yield an object of an alternate type, when a condition is met. Basically, the outline looks like: class Normal(object): def __new__(cls, arg): if cond(arg): #

Re: [Tutor] Help..Concatenaton Error

2009-06-12 Thread Kent Johnson
On Thu, Jun 11, 2009 at 9:00 PM, Randy Trahan wrote: > Also Programming Lanquage Question: > I have studied and an fairly proficient at XHTML and CSS, I tried Javascript > but just didn't like it for some reason..so I am trying Python which so far > fits my personality, needs, whatever that part i

[Tutor] quarry,

2009-06-12 Thread csarita bhandari
Dear sir/madam, I have download python version 3.0.1 windows installer, but problem occur during installing it. And the problem is " Your Administration don't permit to install this program". What should i do? I am new in python. thank you! _

Re: [Tutor] Need a solution.

2009-06-12 Thread Alan Gauld
"David" wrote have been attempting to learn about classes, this is my version, comments, suggestions always welcome. -david #!/usr/bin/python from random import randrange from sys import exit class GuessNumber: def __init__(self): self.number = randrange(100)+1 self.coun

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-12 Thread Alan Gauld
"eShopping" wrote Or use the Python wrapper around expect - pyexpect??? Alan G Installed pexpect and rewrote the code to look like this: Now I get these errors: Traceback (most recent call last): File "C:\Projects\Active\Alun\US_DOE_EOR\test_poly.py", line 1, in -toplevel- import p

Re: [Tutor] Help..Concatenaton Error

2009-06-12 Thread Alan Gauld
"Randy Trahan" wrote Attached is an error I cannot get to work, I was doing a print concatenation but it won't let me get past "+ "ibly impressive. " \ (then to next line) You don;t appear to have a quote in front of the string - immediately after the print statement? BTW While that is OK a

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-12 Thread eShopping
"Tino Dai" wrote > >I know that this is a python group but you might want to try the open > source utility called Expect. It does what you need it to do without > having > having to go through this trial and error process with subprocess. > http://expect.nist.gov/ Or use the Python wrappe