Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-30 Thread Xavier Ho
Alf, I kindly urge you to re-read bartc's comments. He does have a good point and you seem to be avoiding direct answers. On Fri, Oct 30, 2009 at 1:17 PM, Alf P. Steinbach al...@start.no wrote: * bartc: You say elsewhere that you're not specifically teaching Python, but the text is full of

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-30 Thread Xavier Ho
On Fri, Oct 30, 2009 at 1:48 PM, Alf P. Steinbach al...@start.no wrote: Does that mean that 'print' is still subject to change as of 3.1.1? Funny that. They removed reduce() when Python moved from 2.6.x to 3.0. They even removed __cmp__(). Makes me a sad panda. Is print() subject to change as

Re: Help resolve a syntax error on 'as' keyword (python 2.5)

2009-11-03 Thread Xavier Ho
I don't have Python 25 on my computer, but since codepad.org is using Python 2.5.1, I did a quick test: # input try: raise Exception(Mrraa!) except Exception as msg: print msg # output t.py:3: Warning: 'as' will become a reserved keyword in Python 2.6 Line 3 except Exception as

Re: Program to compute and print 1000th prime number

2009-11-07 Thread Xavier Ho
On Sun, Nov 8, 2009 at 12:44 AM, Ray Holt mrhol...@sbcglobal.net wrote: I have a assignment to write a program to compute and print the 1000th. prime number. Can someone give me some leads on the correct code? Ray, if you really want an answer out of this list, you'll have to at least show

Re: Logic operators with in statement

2009-11-16 Thread Xavier Ho
On Tue, Nov 17, 2009 at 12:02 AM, Mr.SpOOn mr.spoo...@gmail.com wrote: Hi, I'm trying to use logical operators (or, and) with the in statement, but I'm having some problems to understand their behavior. Hey Carlo, I think your issue here is mistaking 'in' as a statement. It's just another

Re: Logic operators with in statement

2009-11-16 Thread Xavier Ho
On Tue, Nov 17, 2009 at 12:08 AM, Mr.SpOOn mr.spoo...@gmail.com wrote: Sorry for replying to myself, but I think I understood why I was wrong. The correct statement should be something like this: In [13]: ('b3' and '5') in l or ('3' and 'b3') in l Out[13]: True Carlo, I'm not sure what

Re: Logic operators with in statement

2009-11-16 Thread Xavier Ho
On Tue, Nov 17, 2009 at 12:46 AM, Chris Rebert c...@rebertia.com wrote: On Mon, Nov 16, 2009 at 6:23 AM, Xavier Ho cont...@xavierho.com wrote: AND operator has a higher precedence, so you don't need any brackets here, I think. But anyway, you have to use it like that. So that's something

Re: What is the difference between 'except IOError as e:' and 'except IOError, e:'

2009-11-17 Thread Xavier Ho
On Wed, Nov 18, 2009 at 12:28 PM, Peng Yu pengyu...@gmail.com wrote: I don't see any different between the following code in terms of output. Are they exactly the same ('as' v.s. ',')? Yes, they're exactly the same. However, the syntax with as is newer, introducted in Python 3.x, and

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Xavier Ho
Hi Victor, the .append function doesn't return anything, so it's a None. And you should have it inside the parentheses. tree.append(%s%s % (\t * level, name)) is probably what you're after. Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Overriding the builtin

2009-12-11 Thread Xavier Ho
On Fri, Dec 11, 2009 at 12:05 PM, Kevin Ar18 kevina...@hotmail.com wrote: I am aware of the fact that you can somehow replace the __builtins__ in Python. There is a library here that modifies the binary builtins: http://github.com/aht/stream.py/blob/master/stream.py Question: Is there

Re: Class variables static by default?

2009-12-19 Thread Xavier Ho
Yes, if you want instance variables that are unique to each instance of a class, do the following: class Parser: def __init__(self): self.items = [] And that should work fine. J:\_Programming Projects\Pythonpython test.py __main__.Parser object at 0x0240E7B0 __main__.Parser object at

Re: Invalid syntax error

2009-12-20 Thread Xavier Ho
Putting quotemarks around the path would be a good start, I think. Cheers, Xav On Sun, Dec 20, 2009 at 11:40 PM, Ray Holt mrhol...@sbcglobal.net wrote: Why am I getting an invalid syntax error on the following: os.chdir(c:\\Python_Modules). The error message says the colon after c is

Re: How to get UTC offset for non-standard time zone names?

2010-01-31 Thread Xavier Ho
This may not answer your question directly, but have you thought about ingoring the number at the end of these non-standard timezones? CDT is Central Daylight-saving Timezone, while CST is Central Standard Timezone. And you are correct they are -5 and -6 hours respectively. Does pytz know about

Re: How to get UTC offset for non-standard time zone names?

2010-01-31 Thread Xavier Ho
Would it hurt if you put in some extra information? http://www.timeanddate.com/library/abbreviations/timezones/ HTH, -Xav P.S: You, sir, have an awesome first name. On Mon, Feb 1, 2010 at 1:57 AM, Skip Montanaro s...@pobox.com wrote: Does pytz know about CDT and CST? Nope... Skip --

Re: Common area of circles

2010-02-04 Thread Xavier Ho
I'm not sure what you're after. Are you after how to calculate the area? Or are you trying to graph it? Or an analytical solution? What do you mean by take out the intersection? -Xav On Thu, Feb 4, 2010 at 9:47 PM, Shashwat Anand anand.shash...@gmail.comwrote: I wanted some general

Re: Common area of circles

2010-02-04 Thread Xavier Ho
It's an interesting problem. Never thought it was this difficult. I can't account for all geometrical enumerations, but assuming all 4 circles intersect, here's the solution for this particular senario. It's probably not going to be useful to you since you're working on geometrical approximations

Re: Your beloved python features

2010-02-04 Thread Xavier Ho
Personally, I love the fact that I can type in 2**25 in the intepreter without crashing my machine. ;) Cheers, -Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with lambda

2010-02-18 Thread Xavier Ho
I'm looking at your code and was thinking ... why writing code that is difficult to understand? To answer your question though, they're different because in case f, your lambda experssion is only evaluated once. That means the variable 'n' is ever only created once, and replaced repeatedly. In

Re: How to make an empty generator?

2010-02-18 Thread Xavier Ho
I don't think it's a stupid question at all. =]. But wouldn't it solve the problem if you call the generator the first time you need it to yield? Cheers, Xav On Fri, Feb 19, 2010 at 9:30 AM, Robert Kern robert.k...@gmail.com wrote: On Feb 18, 5:08 pm, Steven D'Aprano

Curiosity stirkes me on 'import this'.

2010-03-07 Thread Xavier Ho
rnfl gb rkcynva, vg znl or n tbbq vqrn. Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr! And some other attributes in 'this' module as well, that decodes the string. I'm curious. Was this encoded purely for fun? *grins* Cheers, Ching-Yun Xavier Ho, Technical Artist Contact

Re: Hi everyone, I get a problem when using binhex module

2009-08-20 Thread Xavier Ho
On Thu, Aug 20, 2009 at 10:07 PM, Yan Jian ballack...@gmail.com wrote: Does anyone encounter similar situation. Thank you for your help? Yeah, in Python 3.1 I get this: Traceback (most recent call last): File test.py, line 6, in module binhex.binhex(file, sys.stdout) File

Re: debugger

2009-08-22 Thread Xavier Ho
On Sat, Aug 22, 2009 at 6:17 PM, flagmino ray.belan...@gmail.com wrote: To get familiar with the debugger, I have loaded this program: import math def s1(x, y): a = (x + y) print(Answer from s1), a return def s2(x, y): b = (x - y) print(This comes from s2), b #print z

Re: Is Python what I need?

2009-08-23 Thread Xavier Ho
On Sun, Aug 23, 2009 at 9:26 PM, newbie sp.b...@gmail.com wrote: Hi all I'm interested in developing computer based, interactive programs for students in a special school who have an aversion to pen and paper. What sort of interactive program? Would it be educational, for example? I've

Re: Need help with Python scoping rules

2009-08-25 Thread Xavier Ho
I'm not really quite sure what voodoo I did here, but my code seems to work in Python 3.1.1 in the following way: class Demo(object): def func(self, n): return n * 5 _f = func(None, 5) d = Demo() print(d._f) print(d.func(5)) # OUTPUT 25 25 So, hmm? Regards, Ching-Yun Xavier

Re: Need help with Python scoping rules

2009-08-25 Thread Xavier Ho
On Wed, Aug 26, 2009 at 2:14 AM, Diez B. Roggisch de...@nospam.web.dewrote: Classes are not scopes. So the above doesn't work because name resolution inside functions/methods looks for local variables first, then for the *global* scope. There is no class-scope-lookup. Sorry, I'm coming

Re: Overriding iadd for dictionary like objects

2009-08-26 Thread Xavier Ho
I haven't tested it, but did you encounter a problem defining __iadd__ in the class definition? See: http://docs.python.org/reference/datamodel.html#object.__iadd__ Cheers, Ching-Yun Xavier Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont

Re: [OT] How do I reply to a thread by sending a message to python-list@python.org

2009-08-27 Thread Xavier Ho
it, and what for? - Kind 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: List iterator thread safety

2009-08-27 Thread Xavier Ho
On Tue, Aug 25, 2009 at 3:43 AM, Emanuele D'Arrigo man...@gmail.com wrote: Let's say I have a list accessed by two threads, one removing list items via del myList[index] statement the other iterating through the list and printing out the items via for item in myList: statement. I tried

Re: Need help with Python scoping rules

2009-08-27 Thread Xavier Ho
On Fri, Aug 28, 2009 at 9:49 AM, kj no.em...@please.post wrote: Miles Kaufmann mile...@umich.edu writes: ...because the suite namespace and the class namespace would get out of sync when different objects were assigned to the class namespace: class C: x = 1 def foo(self):

Re: Need help with Python scoping rules

2009-08-27 Thread Xavier Ho
On Fri, Aug 28, 2009 at 1:27 PM, Miles Kaufmann mile...@umich.edu wrote: You're right, of course. If I had been thinking properly, I would have posted this: ... the suite namespace and the class namespace would get out of sync when different objects were assigned to the class namespace:

Re: Need help with Python scoping rules

2009-08-27 Thread Xavier Ho
On Fri, Aug 28, 2009 at 1:48 PM, Xavier Ho cont...@xavierho.com wrote: Class already provides some kind of scoping/namespace, that is the locals() method for the class. What is pypothetical about this, if you could elaborate? Obviously that was supposed to be hypothetical. Oops. -- http

Re: Transforming a str to an operator

2009-08-27 Thread Xavier Ho
On Fri, Aug 28, 2009 at 1:52 PM, Duke Normandin dukeofp...@ml1.net wrote: How do I convert the contents of op from a string to an actual arithmetic operator? eval() does not seem to be the answer. TIA! Maybe you were looking for print eval(num1 + op + num2) # it's a little ugly string

Re: Transforming a str to an operator

2009-08-27 Thread Xavier Ho
On Fri, Aug 28, 2009 at 2:35 PM, Ben Finney ben+pyt...@benfinney.id.auben%2bpyt...@benfinney.id.au wrote: import operator op_funcs = { '+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.div, } num_1 = int(raw_input('Enter

Re: Select column from a list

2009-08-28 Thread Xavier Ho
On Fri, Aug 28, 2009 at 5:45 PM, hoffik be...@seznam.cz wrote: Hello, I'm quite new in Python and I have one question. I have a 2D matrix of values stored in list (3 columns, many rows). I wonder if I can select one column without having to go through the list with 'for' command. As far as

Re: [OT] How do I reply to a thread by sending a message to python-list@python.org

2009-08-28 Thread Xavier Ho
On Fri, Aug 28, 2009 at 6:18 PM, Hendrik van Rooyen hend...@microcorp.co.za wrote: It would really be nice if the reply would go to the list, but for the digest versions, at least, it does not. I'm on a few other lists. The Python ones are the only ones that I have to manually change. The

Re: [OT] How do I reply to a thread by sending a message to python-list@python.org

2009-08-28 Thread Xavier Ho
On Fri, Aug 28, 2009 at 6:54 PM, Ben Finney ben+pyt...@benfinney.id.auben%2bpyt...@benfinney.id.au wrote: Fortunately, the messages that come from the list enable any mail client to know the correct address for “reply to list”. It only remains to choose a mail client that knows how to use it.

Re: Executing python script stored as a string

2009-09-01 Thread Xavier Ho
On Tue, Sep 1, 2009 at 9:29 AM, Ecir Hana ecir.h...@gmail.com wrote: - if I understood it correctly defining a function in the string and exec-ing it created the function in current scope. This is something I really don't want Oops, missed that point. May I ask what is there you don't want,

Smallest float different from 0.0?

2009-09-07 Thread Xavier Ho
This topic came up before. =] See below. Not sure how 'standardised' this is, though. Double precision: import struct struct.unpack('d', struct.pack('Q', 1))[0] 4.9406564584124654e-324 Float precision: struct.unpack('f', struct.pack('L', 1))[0] 1.4012984643248171e-45 Cheers, Xavier --

Re: NameError: name '__main__' is not defined

2009-09-13 Thread Xavier Ho
Try if __name__ == '__main__' :], Xav On Mon, Sep 14, 2009 at 11:43 AM, Peng Yu pengyu...@gmail.com wrote: Hi, I try the following code. I don't quite understand why __main__ is not defined. Could somebody let me know what I am wrong about it? Regards, Peng $ cat test.py

Re: How to define a class that can act as dictionary key?

2009-09-15 Thread Xavier Ho
On Tue, Sep 15, 2009 at 9:47 PM, Lambda stephenh...@gmail.com wrote: When I run it, it says TypeError: unhashable instance I believe you need to implement __hash__() for the class. Make sure your class returns a unique identifier for a certain value. --

Re: str.split() with empty separator

2009-09-15 Thread Xavier Ho
On Tue, Sep 15, 2009 at 10:31 PM, Ulrich Eckhardt eckha...@satorlaser.comwrote: 'abc'.split('') gives me a ValueError: empty separator. However, ''.join(['a', 'b', 'c']) gives me 'abc'. Why this asymmetry? I was under the impression that the two would be complementary. I'm not sure about

Re: easy question, how to double a variable

2009-09-20 Thread Xavier Ho
On Mon, Sep 21, 2009 at 6:27 AM, daggerdvm dagger...@yahoo.com wrote: Write the definition of a function twice , that receives an int parameter and returns an int that is twice the value of the parameter. how can i do this I thought it was easier to implement this twice function than

Re: easy question, how to double a variable

2009-09-22 Thread Xavier Ho
On Tue, Sep 22, 2009 at 11:58 PM, Mahmoud Abdelkader mabdelka...@gmail.comwrote: hi looking for help catching up in a class and overall to get me better than i am now. I can pay you by the week or per hour. Wow. I'd feel guilty getting paid doing that. Sounds all too easy. I hope he is

Re: Intercepting binding?

2009-09-23 Thread Xavier Ho
()) - default loc = dict(locals()) for item in loc.items(): if item[0] in user: print(item) ###output: ('a', __main__.test object at 0x02D6A240) ('default', {'__builtins__', '__name__', '__file__', '__doc__', '__package__'}) ('test', class '__main__.test') Cheers, Ching-Yun Xavier

Re: how to truncate to get the 1st 5 chars from a string

2009-09-23 Thread Xavier Ho
On Thu, Sep 24, 2009 at 1:05 PM, MacRules macru...@none.com wrote: s=1234abcd s.range(0..4) 1234a Is there a string function like this? Use the slice. s = 1234abcd s[:5] '1234a' Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Average of entries in a list of lists

2009-09-24 Thread Xavier Ho
On Thu, Sep 24, 2009 at 8:54 PM, Evora lasse_lorent...@hotmail.com wrote: Hello, I'm a bit of a newbie to python, so this may very well be a basic question: I have a list of lists, with around 1000 lists looking like this: ['0.000744', '0.480106', 'B']. I need the average of the first to

Re: Format string with single quotes in it

2009-09-25 Thread Xavier Ho
On Fri, Sep 25, 2009 at 10:42 PM, Bahadir bilgehan.bal...@gmail.com wrote: Hi there, My question is simple, but I've been spending some hours over the web and still struggling to get this right: How do I format a string that contains single quotes in it? I don't know what you're doing

Re: The rap against while True: loops

2009-10-12 Thread Xavier Ho
On Mon, Oct 12, 2009 at 11:32 PM, Luis Zarrabeitia ky...@uh.cu wrote: Actually, in python, this works even better: for lin in iter(file_object.readline, ): ... do something with lin What about with open(path_string) as f: for line in f: # do something Cheers, Xav --

Re: What command should be use when the testing of arguments is failed?

2009-10-14 Thread Xavier Ho
On Thu, Oct 15, 2009 at 10:58 AM, Peng Yu pengyu...@gmail.com wrote: I actually wanted to ask what return code should be returned in this case when the arguments are not right. Thank you1 I think that depends on the design of the program. Is there a return value that would make sense to be

Re: () vs. [] operator

2009-10-15 Thread Xavier Ho
On Thu, Oct 15, 2009 at 5:14 PM, Ole Streicher ole-usenet-s...@gmx.netwrote: snip So what is the reason that Python has separate __call__()/() and __getitem__()/[] interfaces and what is the rule to choose between them? Hi, This is very interesting, a thought that never occured to me before.

Re: Problem

2009-10-15 Thread Xavier Ho
On Fri, Oct 16, 2009 at 3:28 AM, Ander and...@hot.ee wrote: I can't send emails out. Can u fix this problem please? I don't know what I'm missing here, but you evidently sent out an email to the Python mailing list... Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: md5 strange error

2009-10-21 Thread Xavier Ho
On Wed, Oct 21, 2009 at 6:11 PM, catalinf...@gmail.com catalinf...@gmail.com wrote: pass = md5.new() File stdin, line 1 pass = md5.new() ^ SyntaxError: invalid syntax pass is a keyword in Python, you can't use it as an identifier. Try password instead. Cheers, Xav --

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

2009-06-20 Thread Xavier Ho
)).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. :] Best regards, Ching-Yun Xavier Ho, Technical Artist Contact Information Mobile

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

2009-06-20 Thread Xavier Ho
. 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 Ho, Technical Artist Contact Information Mobile: (+61

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

2009-06-20 Thread Xavier Ho
))) 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://xavierho.com/ -- http://mail.python.org/mailman/listinfo/python-list

Inheritance and forward references (prototypes)

2009-06-20 Thread Xavier Ho
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://xavierho.com/ On Sun, Jun 21

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 Tue, Jun 23, 2009

Re: re.NONE

2009-06-22 Thread Xavier Ho
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: Newby Windows User

2009-07-01 Thread Xavier Ho
like this: python file name.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 3335 4748

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

2009-07-05 Thread Xavier Ho
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 Artist Contact Information Mobile

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: SpaXe85 Email: cont

Re: help me to find the error

2009-07-10 Thread Xavier Ho
, 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: SpaXe85 Email: cont...@xavierho.com Website: http://xavierho.com/ On Fri

Re: simple question about Dictionary type containing List objects

2009-07-13 Thread Xavier Ho
://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

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

2009-07-14 Thread Xavier Ho
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: 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 m...@well-adjusted.de wrote: Xavier Ho: Why doesn't the second

Re: using timers to force an execution time

2009-07-16 Thread Xavier Ho
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 regards, Ching-Yun Xavier Ho

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

2009-07-16 Thread Xavier Ho
. 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, Ching-Yun Xavier Ho, Technical Artist Contact Information

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

2009-07-17 Thread Xavier Ho
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 Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com

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

2009-07-17 Thread Xavier Ho
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://xavierho.com/ -- http://mail.python.org

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

2009-07-17 Thread Xavier Ho
just gave the link's code a quick try. It was at least 10x times faster than my code to generate 10 prime numbers - I'll have a closer look. Thanks a great deal. Ching-Yun Xavier Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com

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

2009-07-17 Thread Xavier Ho
. 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 enough, generate more. Thanks. Ching-Yun Xavier Ho

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

2009-07-17 Thread Xavier Ho
() 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: Re: Changing the private variables content

2009-07-22 Thread Xavier Ho
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

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
Got it: exec('self.' + attr + '=\'' + val + '\'') That worked. I think it'll do what you want now ;) 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

Re: Changing the private variables content

2009-07-22 Thread Xavier Ho
What is the point of the _SetVar method? So you can set any variable in that class, I guess? -- http://mail.python.org/mailman/listinfo/python-list

Re: merge two png pic

2009-07-28 Thread Xavier Ho
. Good luck, 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: idiom for list looping

2009-07-29 Thread Xavier Ho
superpollo wrote: for (i, e) in enumerate(nomi): print i, -, e Just to be random: print '\n'.join([%s - %s % (i, e) for i, e in enumerate(nomi)]) This has one advantage: only print once. So it's slightly faster if you have a list of a large amount. --

Re: idiom for list looping

2009-07-29 Thread Xavier Ho
On Wed, Jul 29, 2009 at 8:52 PM, MRAB pyt...@mrabarnett.plus.com wrote: Slightly shorter: print '\n'.join(%s - %s % p for p in enumerate(nomi)) :-) That's cool. Does that make the list a tuple? (not that it matters, I'm just curious!) I just tested for a list of 1000 elements (number in

idiom for list looping

2009-07-29 Thread Xavier Ho
Ack, sent to the wrong email again. On Wed, Jul 29, 2009 at 9:02 PM, superpollo u...@example.net wrote: print '\n'.join(%s - %s % p for p in enumerate(nomi)) File stdin, line 1 print '\n'.join(%s - %s % p for p in enumerate(nomi)) ^ SyntaxError:

Re: idiom for list looping

2009-07-29 Thread Xavier Ho
On Wed, Jul 29, 2009 at 9:17 PM, MRAB pyt...@mrabarnett.plus.com wrote: I've just replaced the list comprehension with a generator expression. Oh, and that isn't in Python 2.3 I see. Generators are slightly newer, eh. Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Particle research opens door for new technology

2009-07-29 Thread Xavier Ho
Is this a spam? Why did you have to send it 4 times, and it's already in the past (July 9 and 10) ? 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

Re: problem on socket programming

2009-07-31 Thread Xavier Ho
Whoops, posted to the wrong address yet again. I deserve some punishment. On Fri, Jul 31, 2009 at 5:33 PM, Xavier Ho cont...@xavierho.com wrote: On Fri, Jul 31, 2009 at 5:25 PM, MalC0de malc0de.encr...@gmail.comwrote: while true : where's the problem, There. =] (Btw, it's True

Re: Confessions of a Python fanboy

2009-07-31 Thread Xavier Ho
On Fri, Jul 31, 2009 at 6:08 PM, Masklinn maskl...@masklinn.net wrote: snip... but since Python doesn't have anonymous functions that usage tends to be a bit too verbose ... snip Sorry to interrupt, but wouldn't lambda in Python be considered as 'anonymous functions'? --

Re: Confessions of a Python fanboy

2009-07-31 Thread Xavier Ho
On Fri, Jul 31, 2009 at 6:25 PM, Chris Rebert c...@rebertia.com wrote: I believe full anonymous functions was intended by the author. lambdas are limited to a single expression. Full anonymous functions would be allowed to contain multiple statements. Cheers, but what about this: def

Re: Confessions of a Python fanboy

2009-07-31 Thread Xavier Ho
On Fri, Jul 31, 2009 at 6:38 PM, Chris Rebert c...@rebertia.com wrote: No, because it has a name, namely goBig; this obviously prevents it from being anonymous. For comparison, note how the function in the following example is never given a name, and is thus anonymous: (lambda x: x+5)(6)

Re: file comparison

2009-07-31 Thread Xavier Ho
On Fri, Jul 31, 2009 at 7:25 PM, learner learner pyvault...@gmail.comwrote: Hi all, I want to compare two text files line by line and eliminate the matching/repeated line and store the unmatched/leftout lines into a third file or overwrite into one of them. Sounds like homework to me. Why

Re: Seeding the rand() Generator

2009-08-04 Thread Xavier Ho
, some people have suggested to use that inside Python. That would work, right? Although, if you're just trying to find the Python-equivalent, fair enough. Regards, Ching-Yun Xavier Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com

Re: merge two png pic

2009-08-04 Thread Xavier Ho
5GB of pictures every time you access Maps - that wouldn't have worked. They work with the only visible areas. If you could tell us exactly what your program is trying to achieve, maybe we'll have a better solution for you. Best regards, Ching-Yun Xavier Ho, Technical Artist Contact Information

Re: Obtaining Python version

2009-08-04 Thread Xavier Ho
On Tue, Aug 4, 2009 at 8:30 PM, Yinon Ehrlich yinon...@gmail.com wrote: Hi, Easy way to test for Python version: if sys.hexversion = 0x2060100: pass Great suggestion. I just tested it on my newly installed Python 3.1 (as of 3.1r31) import sys %X % sys.hexversion '30100F0' That's genius

Re: Obtaining Python version

2009-08-04 Thread Xavier Ho
On Tue, Aug 4, 2009 at 9:34 PM, Xavier Ho cont...@xavierho.com wrote: ... and '00F0' is r31! Actually, 00F0 is 576 in decimal. Maybe it's the subversion? Anyhow, it's still good! -- http://mail.python.org/mailman/listinfo/python-list

Re: Obtaining Python version

2009-08-04 Thread Xavier Ho
On Wed, Aug 5, 2009 at 12:17 AM, MRAB pyt...@mrabarnett.plus.com wrote: 0x00F0 is 240. ... Right. I wonder where my brain is. *searches pocket* So, what am I doing wrong here? int(str(0x00F0), 16) 576 Cheers, -Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Obtaining Python version

2009-08-04 Thread Xavier Ho
On Wed, Aug 5, 2009 at 12:44 AM, D'Arcy J.M. Cain da...@druid.net wrote: On Wed, 5 Aug 2009 00:39:56 +1000 Xavier Ho cont...@xavierho.com wrote: So, what am I doing wrong here? int(str(0x00F0), 16) Look at the output of str(0x00F0) for a clue. ... Wow. I *am* slow tonight. Thanks

Re: Datetime with float seconds

2009-08-05 Thread Xavier Ho
On Wed, Aug 5, 2009 at 10:50 PM, kpal kpalamartch...@gmail.com wrote: Hello Everybody, The standard datetime has 1 microsecond granularity. My application needs finer time resolution, preferably float seconds. Is there an alternative to the out-of-the-box datetime? Timezone support is not

Re: Subclassing Python's dict

2009-08-05 Thread Xavier Ho
might be of your interest. Another guy have reported me that he experiences similar problems with subclassing builtin 'list'. Similarly, UserList is what you should subclass. HTH, Ching-Yun Xavier Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email

Re: Subclassing Python's dict

2009-08-05 Thread Xavier Ho
On Thu, Aug 6, 2009 at 5:23 AM, Joshua Kugler jos...@joshuakugler.comwrote: Are you referring to Python 3.0? Python 2.6 does not have collections.UserDict j Yes, I was sometimes it's hard to keep track what's not in 2.6 and in 3.1 for me, sorry. And thanks. The ABC MutableMapping is

Re: merge two png pic

2009-08-06 Thread Xavier Ho
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: Subclassing Python's dict

2009-08-06 Thread Xavier Ho
On Thu, Aug 6, 2009 at 1:19 PM, alex23 wuwe...@gmail.com wrote: Xavier Ho wrote: You should subclass collections.UserDict, and not the default dict class. Refer to the collections module. Xavier, why do you think that is the correct approach? I'll be honest first and say that I do

Re: remove last 76 letters from string

2009-08-06 Thread Xavier Ho
] # ... Should do what you need. 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: www.python.org website is down?

2009-08-08 Thread Xavier Ho
Well, it's back up now. At least for me. ;) 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 Sun, Aug 9, 2009 at 4:49 AM, Sharath sharath20...@gmail.com wrote: On Aug 8, 11:33

  1   2   3   >