[Tutor] HELP: subclass of int

2005-03-08 Thread Shidai Liu
Hi all, I'll sum up a question as following: def int5(): '''return 5''' return 5 class my_int(int): def __init__(self): self.id = int5() int.__init__(self, self.id) # FIXME: this line doesn't work the above code act like this: >>> I = my_int() >>> I 0 I want it to

Re: [Tutor] HELP: subclass of int

2005-03-08 Thread Shidai Liu
On Tue, 8 Mar 2005 17:15:00 -0800 (PST), Terry Carroll <[EMAIL PROTECTED]> wrote: > On Tue, 8 Mar 2005, Shidai Liu wrote: > > > I'll sum up a question as following: > > > > def int5(): > > '''return 5'''

Re: [Tutor] Looking for a Pythonic way to pass variable number of lists to zip()

2005-03-22 Thread Shidai Liu
On Mon, 21 Mar 2005 22:51:31 -0800, Sean Perry <[EMAIL PROTECTED]> wrote: > Tony Cappellini wrote: > > well, I would have said "apply(zip, (l1, l2, l3, ...))" but apply has > been deprecated in 2.3. > > So how about this? > > arg_list = [] > # fill up arg_list > zipped = zip(*arg_list) > I met

Re: [Tutor] Looking for a Pythonic way to pass variable

2005-03-22 Thread Shidai Liu
On Tue, 22 Mar 2005 15:27:02 -0500, Bill Mill <[EMAIL PROTECTED]> wrote: > >>> zip(K, *L) > [(100, 1, 3), (200, 2, 4)] Any idea why zip(*L, K) fails? -- With best wishes! Shidai ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/lis

[Tutor] [HELP]how to test properties of a file

2005-04-03 Thread Shidai Liu
Dear all, Here is a simple question. But I can't find a simple answer. How to test if a file is readable, executalbe or writable, especially, writable? -- With best wishes! Shidai ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/l

Re: [Tutor] [HELP]how to test properties of a file

2005-04-03 Thread Shidai Liu
On Apr 3, 2005 6:42 PM, Pierre Barbier de Reuille <[EMAIL PROTECTED]> wrote: > Tthe simplest, IMHO, is : > > try: > f = file(filename, "w") > [...] > except IOError: > print "The file is not writable" > > Of course, not that this method empty the file if it is writable ! The > best is to ju

Re: [Tutor] [HELP]how to test properties of a file

2005-04-04 Thread Shidai Liu
On Apr 4, 2005 10:43 PM, Alan Gauld <[EMAIL PROTECTED]> wrote: > > Its not really the simplest, its not efficient and it might be > dangerous > if the file is not empty. At the very least open using 'a' to avoid > obliterating the file!! > > However the os.stat function and stat module do what yo

Re: [Tutor] [HELP]how to test properties of a file

2005-04-04 Thread Shidai Liu
On Apr 4, 2005 10:54 PM, Nick Lunt <[EMAIL PROTECTED]> wrote: > I've gotten into the habit of just using the os.?_OK stuff. > > eg > > >>> import os > >>> os.access('/', os.W_OK) > False > >>> os.access('/tmp', os.W_OK) > True > > Thats gotta be simple if I understand it lol :) > > Nick . > I

Re: [Tutor] [HELP]how to test properties of a file

2005-04-05 Thread Shidai Liu
On Apr 5, 2005 6:33 PM, Nick Lunt <[EMAIL PROTECTED]> wrote: > I havent got access to a windows box unfortunately at the moment. And I > have no idea about permissions on windows boxes anyway :) > However, did you already have the .csv file open in Excel or some other > app ? Or is is password prot

Re: [Tutor] [HELP]how to test properties of a file

2005-04-05 Thread Shidai Liu
On Apr 5, 2005 3:40 PM, Bernard Lebel <[EMAIL PROTECTED]> wrote: > As far as I'm aware, this is very normal. The file is being used by an > application, so there is a lock on it. > However, os.access('somefile.csv', os.W_OK) returns True. Shouldn't it return False? ___

[Tutor] [HELP]win32 shutdown, restart, logoff

2005-05-22 Thread Shidai Liu
Hi all, Any one know how to make a shutdown, restart, logoff call in windows os like 98, 2000 and xp? Implemented in python, can use python win32 extensions. But not os.system('rundll/shutodwn ...'). Thanks for your help.-- With best wishes!Shidai ___ T

Re: [Tutor] [HELP]win32 shutdown, restart, logoff

2005-05-22 Thread Shidai Liu
On 5/23/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Quoting Shidai Liu <[EMAIL PROTECTED] >:> Any one know how to make a shutdown, restart, logoff call in windows os> like 98, 2000 and xp?Try this: win32api.InitiateSystemShutdown(None, 'Kaboom!', 2000, False, False

Re: [Tutor] __init__.py

2005-05-22 Thread Shidai Liu
On 5/23/05, Joseph Quigley <[EMAIL PROTECTED]> wrote: I've seen many (python) "plugins" (some located in site-packages [windowshere]) with the name __init__.py.What's their use?class foo:def __init__:print "this starts first" def foo1():print "this co

Re: [Tutor] [HELP]win32 shutdown, restart, logoff

2005-05-24 Thread Shidai Liu
On 5/23/05, Tony Meyer <[EMAIL PROTECTED]> wrote: > I have the local machine's administration privilege.[...]> When I run the command as you point out, I got the following> messages>> (5, 'InitiateSystemShutdown', 'Access is denied.') The process itself needs to have the privilege.  This message ha