Re: Re: Changing the private variables content

2009-07-22 Thread Xavier Ho
> > val('self.' + attr + '=\'' + val + '\'') > Obviously that was eval, not val. Also it doesn't work without the escaped single quotes, either. -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: Changing the private variables content

2009-07-22 Thread Xavier Ho
#x27; ^ SyntaxError: invalid syntax So, uh, I'm wondering if this is a bug. And also the solution to his problem. Good luck. Any ideas appreciated. Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://xavierho.com/ -- http://mail.python.org/mailman/listinfo/python-list

Try... except....Try again?

2009-07-17 Thread Xavier Ho
. Right, so for i in xrange() would be a better choice? Best regards, Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://xavierho.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Try... except....Try again?

2009-07-17 Thread Xavier Ho
gt; is not really an exceptional case. > > If you insists on using a try-except clause, use it this way: > > Well, I don't have to use try-except. I think I got another idea though. I could use an internal counter to keep track of how many prime numbers have generated, and if not eno

Re: Try... except....Try again?

2009-07-17 Thread Xavier Ho
erate from n=2 and on every time, which makes generation time linear. However, I just gave the link's code a quick try. It was at least 10x times faster than my code to generate 100000 prime numbers - I'll have a closer look. Thanks a great deal. Ching-Yun "Xavier" Ho, Technical

Try... except....Try again?

2009-07-17 Thread Xavier Ho
as well as the previous version, but slightly safer on my part... and I can adapt this in my future coding habits. Thanks again. Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http

Re: Try... except....Try again?

2009-07-17 Thread Xavier Ho
, common sense. Also... "while True" has a bad reputation. But mostly outside influences. But if it's okay, it's okay by me.. I can't think of an easier way to code the "try loop" above, anyhow. Ching-Yun "Xavier" Ho, Technical Artist Contact Informa

Try... except....Try again?

2009-07-16 Thread Xavier Ho
pends it into primes. This way, it keeps trying to append until the nth prime requested exist, and returns it. My problem is that it's a "While True" loop, which I get a lot of "Don't do it!" In the light of making the code better, what could I do? Best regards,

Re: using timers to force an execution time

2009-07-16 Thread Xavier Ho
see? the while body ran for about 7 seconds... i bet it has to do with the > fact that the timer does not control inner loops... any suggestion? > > I'm guessing it has to do with a sleep of 0.66 seconds x 10 times = sleep for 6.6 seconds, and then it checks for e.isSet(). Best rega

Re: Why does extend() fail in this case, and what am I doing wrong?

2009-07-14 Thread Xavier Ho
I see. Thanks! Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://xavierho.com/ On Tue, Jul 14, 2009 at 11:20 PM, Jochen Schulz wrote: > Xavier Ho: > > > > Why doesn

Why does extend() fail in this case, and what am I doing wrong?

2009-07-14 Thread Xavier Ho
w, but I'm probably missing something. Any pointers would be great. Best regards, Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://xavierho.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: simple question about Dictionary type containing List objects

2009-07-13 Thread Xavier Ho
e list mycontacts ,like > mycontacts_numbers=3 <http://mail.python.org/mailman/listinfo/python-list> > >>> len(emails['mycontacts']) 3 HTH, Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://xavierho.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: help me to find the error

2009-07-10 Thread Xavier Ho
lines = f0.readlines()* Then in the for loop, change f1 to *f1=lines[i].split()* That may just stop it from complaining. Untested, but logically it's sound. Hope that works, Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaX

Re: Why is my code faster with append() in a loop than with a large list?

2009-07-06 Thread Xavier Ho
Thanks for the response all, I finally got my 'net working on the mountains, and I think your reasons are quite sound. I'll keep that in mind for the future. Best regards, Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID:

Why is my code faster with append() in a loop than with a large list?

2009-07-05 Thread Xavier Ho
ing is 40x slower, and was expected. But I still can't puzzle out why his use of appending in Version B was so much faster than mine. Any insights would be welcome. I'm going on a family trip, though, so my replies may delay. Best regards, Ching-Yun "Xavier" Ho, Technical Arti

Re: Newby Windows User

2009-07-01 Thread Xavier Ho
command like this: python .py That should do the trick. Alternatively, you can type in python and start the python shell in the same folder. Then you can just do import and whatever you like. :] Best regards, Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04

Re: re.NONE

2009-06-22 Thread Xavier Ho
ding to mailing list for some reason. What happend to the reply-to request? =/) Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://xavierho.com/ -- http://mail.python.org/mailman/listinfo/python-list

re.NONE

2009-06-22 Thread Xavier Ho
(arg, MRAB, sorry, wrong address!) Defining None to 0 is a bad idea. You'll have trouble debugging later on. Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://xavierho.com/ On Tu

Inheritance and forward references (prototypes)

2009-06-20 Thread Xavier Ho
x27;m just getting this "necessary" step because my books say so. If anyone has a good explanation, please do tell. Best regards, Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://x

Re: calculating a self.value, self.randomnum = normalvariate(x, y)

2009-06-20 Thread Xavier Ho
to begin? > > x = max(0, min(100, normalvariate(x, y))) > > That is an awesome way of shorthanding clamp. Best regards, Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://xavier

calculating a self.value, self.randomnum = normalvariate(x, y)

2009-06-20 Thread Xavier Ho
hat was to print out 10 random samples. If you're not sure if this is what you want, then um.. not much I can do there. What is this class originally for? If you feel the clamp is too huge, well, I'm always interested in improvements/alternatives! Best regards, Ching-Yun "Xavier"

Re: calculating a self.value, self.randomnum = normalvariate(x, y)

2009-06-20 Thread Xavier Ho
: print applicant(random.randint(0,100), random.randint(0,100)).randomnum == Or you could just use randint() if you only wanted a linear distribution. PS: Thanks, btw, new to python myself also, and looking into this was cool. :]

Re: class or instance method

2009-06-17 Thread Xavier Ho
I'm quite curious as to why you would like it, because: >>> MyClass (returns the MyClass class representation) >>> MyClass() (returns a instance of the MyClass class) So, are you just looking for a method that does exactly the above? Best regards, Ching-Yun "

Re: Persistent failure of 'break' statement ( novice )

2009-06-13 Thread Xavier Ho
erent ways of launching the program. And share with us what you did to run this to begin with, that might help as well. Best regards, Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://xav

<    1   2   3