How can I enumerate all windows services and disable some of them?

2006-08-22 Thread could . net
I know that Module win32service has some functions on manipulating
win32 services.
But I still have 2 questions:
1. how to enumerate all services?
2. how to disable a certain one?

Thanks in advance!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and STL efficiency

2006-08-22 Thread could . net
That's to say,
python is still much faster?

I am a c++ newbie but I think c++ should be faster here.
Maybe someone can post this to the c++ maillist and they will tell how
to accelerate it.
Tim N. van der Leeuw wrote:
> Mc Osten wrote:
> > Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> >
> > > Python's memory allocator is also quite fast, compared to most generic
> > > allocators...
> >
> > In fact also in the two "slow" versions Python outperforms C++.
> > I didn't notice it in the first place.
> >
> > --
> > blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
> > site:  http://www.akropolix.net/rik0/  | tenetevi riso e
> > forum: http://www.akropolix.net/forum/ | bacchette per voi.
>
> Well, I guess I'm getting really obsessed with this. But anyways. I
> installed MinGW on my Windows-XP (sp2) laptop. It is g++ version 3.4.5
> -- ancient, yes, but on windows it's the latest available.
>
> I compiled Mc Osten's C++ program (tweaked the output a little) and ran
> it; ran his version of the python code too.
> Oh boy; yes indeed the slow python is faster than the fast C++
> version... Must be something really awful happening in the STL
> implementation that comes with GCC 3.4!
>
> Here's the output from my console:
>
> [EMAIL PROTECTED] ~/My Documents/Python
> $ g++ -O3 -march=pentium-m -o SpeedTest SpeedTest.cpp
>
> [EMAIL PROTECTED] ~/My Documents/Python
> $ ./SpeedTest.py
> Begin Test
> Number of unique string objects: 4
> so long...
> What do you know
> fool
> chicken crosses road
> Number of unique string objects: 4
> so long...
> What do you know
> fool
> chicken crosses road
> Fast - Elapsed: 0.037574 seconds
> Slow - Elapsed: 0.081520 seconds
>
> [EMAIL PROTECTED] ~/My Documents/Python
> $ ./SpeedTest.exe
> Begin Test
> What do you know?
> chicken crosses road
> fool
> so long...
> What do you know?
> chicken crosses road
> fool
> so long...
> Fast - Elapsed: 2.089 seconds
> Slow - Elapsed: 6.303 seconds
>
> [EMAIL PROTECTED] ~/My Documents/Python
> 
> 
> Cheers,
> 
> --Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


boost::python embedding example running error

2006-11-12 Thread could . net
I use boost 1.33_1, there's an example on boost::python named
embedding.cpp. When I tried to build and run it in visual studio 2005,
I got an error on this line:

std::string hello() { return python::call_method(self,
"hello"); }

It's a back ptr error.

I don't know where to ask this question so I came to python group. Has
anyone run this example successfully? Thanks in advance.

-- 
http://mail.python.org/mailman/listinfo/python-list


How to compare to directories?

2006-09-12 Thread could . net
I want to compare 2 directories: dir1 and dir2.
What I want to do is to get these informations:
1. does they have the same number of files and sub-directories?
2. does each file with the same name have the same size and date
information?

So, how can I do it in python?
Thank you!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: YouTube written in Python

2006-12-12 Thread could . net
Really?
It's awful!
Terry Reedy wrote:
> In a thread on the PyDev list, Guido van Rossum today wrote:
> > And I just found out (after everyone else probably :-) that YouTube is
> > almost entirely written in Python. (And now I can rub shoulders with
> > the developers since they're all Googlers now... :-)
>
> In reply, Simon Brunning noted:
> > That'll put to bed any "Does Python scale" discussions.

-- 
http://mail.python.org/mailman/listinfo/python-list


How to turn of the monitor by python?

2006-12-12 Thread could . net
I want to turn off my monitor from within python, How to do it?
Thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to turn of the monitor by python?

2006-12-12 Thread could . net
Thank you, that's exactly what I want.

Sorry I didn't give my OS info.
Leo Kislov wrote:
> [EMAIL PROTECTED] wrote:
> > I want to turn off my monitor from within python, How to do it?
> > Thanks!
>
> Do you realize that hardware management and control is OS dependant?
> When asking such questions always specify OS.
>
> Assuming you are interested in Windows, then you just need to translate
> this  C API calls
> into python. You can use ctypes (included in Python 2.5) or python
> win32 extensions.
> 
>   -- Leo

-- 
http://mail.python.org/mailman/listinfo/python-list


a question on python dict

2006-12-20 Thread could . net
Python dict is a hash table, isn't it?

I know that hashtable has the concept of "bucket size" and "min bucket
count" stuff,
and they should be configurable so I can set them to the proper value
when I know how many items I'm going to handle.

If these two values can't be set, the hashtable will give them default
values. When there are more and more items being added to the
hashtable, it increase its buckets and copy the old items into the new
one and re-calculate the hash value of each item.

I think this will waste some time doing the increasing-copying thing.
If I know I'm going to handle about 2 items, I can set the size of
hashtable to 3.

So, can I do this in python? I can't figure it out so I come here for
help.

Thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a question on python dict

2006-12-20 Thread could . net
Thank you very much for your explanation!

I made a mistake that I said the hash value should be recalculated each
time the dict resize, what I wanted to say was that the position of
each item should be recalculated.

Maybe I should take a look at the source code of python dict some day.
I'll some here for help then.

Thanks again!


Tim Peters wrote:
> [EMAIL PROTECTED]
> > Python dict is a hash table, isn't it?
>
> Yup.
>
> > I know that hashtable has the concept of "bucket size" and "min bucket
> > count" stuff,
>
> Some implementations of hash tables do.  Python's does not.  Python's
> uses what's called "open addressing" instead.
>
> > and they should be configurable so I can set them to the proper value
> > when I know how many items I'm going to handle.
> >
> > If these two values can't be set, the hashtable will give them default
> > values. When there are more and more items being added to the
> > hashtable, it increase its buckets and copy the old items into the new
> > one and re-calculate the hash value of each item.
>
> That's several distinct claims, each of which is true of some hash
> table implementations but not of others.  Python's implementation has
> no "buckets", so all that's simply irrelevant.  Python's
> implementation (not all do) saves the hash value of each item, so when
> it does need to grow (or shrink) the space allocated to the table, it
> does not need to recalculate the hash value of any item.
>
> You should also note that copying a dict key or value (no matter of
> what type) consists in its entirety of copying one machine address (a
> 4- or 8-byte pointer, depending on platform).
>
> > I think this will waste some time doing the increasing-copying thing.
>
> It does take time to resize.  "Waste" is a value judgment ;-)
>
> > If I know I'm going to handle about 2 items, I can set the size of
> > hashtable to 3.
> >
> > So, can I do this in python?
>
> You can't.  Unless you build up to 2 items over and over (many
> thousands of times), it's unlikely you'd be able to measure the time
> difference even if you could.

-- 
http://mail.python.org/mailman/listinfo/python-list


an hex number problem

2006-12-21 Thread could . net
Hello,
I got a number 19968:

1. how can I change it to the hex form 0x4e00,
2. and how can I change 0x4e00 to a python unicode character u"\u4e00"?

thank you!

-- 
http://mail.python.org/mailman/listinfo/python-list