Re: [Tutor] Generating unique ID

2009-10-28 Thread Modulok
> I'm writing an application which will hold a database of people. Ofcourse, > people can have the same name, so I want to stock them with an unique ID. > > I've searched and found some things: > - uuid.uuid4() > - id(name) > - os.urandom(n) > > But they seem overkill to me. Well, maybe not id(). >

Re: [Tutor] Sorting points on a 2D plane

2009-10-28 Thread Kent Johnson
On Wed, Oct 28, 2009 at 1:34 PM, Robert Berman wrote: > Hi, > > I am working on a practice problem called 'POINTS' on the CodeChef > site:http://www.codechef.com/problems/POINTS/. This simply wants the sum > of the distances between a number of points on a 2 dimensional plane. > Looking at the pro

Re: [Tutor] Sorting points on a 2D plane

2009-10-28 Thread Alan Gauld
"Robert Berman" wrote constructed. My point of confusion is in ordering the points. Given a very simple example set of points: The arrangement should be, 0 5 0 2 0 1 2 3 2 1 5 2 5 1 You might find the itertools.groupby function does most of what you need? HTH, Alan G. __

Re: [Tutor] Can python determine Battery or AC Power?

2009-10-28 Thread Alan Gauld
"Nick Hird" wrote I am running Windows XP. On Wed, Oct 28, 2009 at 4:15 PM, Nick Hird wrote: Is there a way in python to tell if the power source for a laptop is ac or battery? Search Microsoft Developer site (MSDN) for GetSystemPowerStatus which is the function that tests for batte

Re: [Tutor] Sorting points on a 2D plane

2009-10-28 Thread Luke Paireepinart
Oops I replied off list twice. (i wish they would just munge the addresses *grumble**grumble*) On Wed, Oct 28, 2009 at 11:34 AM, Robert Berman wrote: Hi, What I am looking for is a better, faster approach. I think there would be a way to build a dictionary but you can't use the X values as keys

[Tutor] Sorting points on a 2D plane

2009-10-28 Thread Robert Berman
Hi, I am working on a practice problem called 'POINTS' on the CodeChef site:http://www.codechef.com/problems/POINTS/. This simply wants the sum of the distances between a number of points on a 2 dimensional plane. Looking at the problem, the algorithm to define the sum of the distances between all

Re: [Tutor] Can python determine Battery or AC Power?

2009-10-28 Thread Luke Paireepinart
On Wed, Oct 28, 2009 at 4:28 PM, Nick Hird wrote: > I am running Windows XP. > My advice applies then ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Can python determine Battery or AC Power?

2009-10-28 Thread Nick Hird
I am running Windows XP. On Wed, Oct 28, 2009 at 5:19 PM, Luke Paireepinart wrote: > If you're on Windows and you can find an example using the Win32 api (in C++ > for example) you can use pywin32 module to do the same thing through > python.  It's a little complicated sometimes though.  So what

Re: [Tutor] Can python determine Battery or AC Power?

2009-10-28 Thread Luke Paireepinart
If you're on Windows and you can find an example using the Win32 api (in C++ for example) you can use pywin32 module to do the same thing through python. It's a little complicated sometimes though. So what O.S. are you on? On Wed, Oct 28, 2009 at 4:15 PM, Nick Hird wrote: > Is there a way in p

[Tutor] Can python determine Battery or AC Power?

2009-10-28 Thread Nick Hird
Is there a way in python to tell if the power source for a laptop is ac or battery? I am trying to write a small script to print out my system stats and would like to know if the laptop is on battery power or using ac power. I just dont know enough python to know where to look for that info. Thank

Re: [Tutor] Generating unique ID

2009-10-28 Thread Serdar Tumgoren
> I'm writing an application which will hold a database of people. Ofcourse, > people can have the same name, so I want to stock them with an unique ID. > If you're using an actual database rather than a plain old text file, you can let the database do the work for you. Most flavors (sqlite, post

Re: [Tutor] Generating unique ID

2009-10-28 Thread Wayne
On Wed, Oct 28, 2009 at 1:52 PM, Timo List wrote: > Hello, > > I'm writing an application which will hold a database of people. Ofcourse, > people can have the same name, so I want to stock them with an unique ID. > > I've searched and found some things: > - uuid.uuid4() > - id(name) > - os.urand

[Tutor] Generating unique ID

2009-10-28 Thread Timo List
Hello, I'm writing an application which will hold a database of people. Ofcourse, people can have the same name, so I want to stock them with an unique ID. I've searched and found some things: - uuid.uuid4() - id(name) - os.urandom(n) But they seem overkill to me. Well, maybe not id(). What sho

[Tutor] PyQT forum?

2009-10-28 Thread Christopher Spears
I'm starting to learn PyQt. Can anyone recommend a good mailing list or forum? Thanks. "I'm the last person to pretend that I'm a radio. I'd rather go out and be a color television set." -David Bowie "Who dares wins" -British military motto "There is no such thing as luck; there is only adeq

Re: [Tutor] New to Python

2009-10-28 Thread Kent Johnson
On Wed, Oct 28, 2009 at 11:16 AM, wrote: > Well I would have to remote to the machine that contains the log file and > copy it from there. You are not being very helpful. What does "remote to the machine" mean? What OS are you running? Some details would help. Kent PS Please don't top-post. >

Re: [Tutor] New to Python

2009-10-28 Thread asterix09
Well I would have to remote to the machine that contains the log file and copy it from there. -Original Message- From: Kent Johnson To: asteri...@petlover.com Cc: *tutor python Sent: Wed, Oct 28, 2009 1:18 pm Subject: Re: [Tutor] New to Python Forwarding to the list with my reply (

Re: [Tutor] New to Python

2009-10-28 Thread Dave Angel
Remember to hit Reply to all - Forwarding your message onto the list -- Forwarded message -- From: Date: Wed, Oct 28, 2009 at 1:00 AM Subject: Re: [Tutor] New to Python To: sri...@gmail.com Hi Wayne, I will try as best to explain what I need to do. I have a log file. In t

Re: [Tutor] Access PostGreSQL 8.3 by python 2.5

2009-10-28 Thread Kent Johnson
On Wed, Oct 28, 2009 at 1:44 AM, Mahasen Dehideniya wrote: > Hi , > > I'm try to access PostGreSQL 8.3 by python 2.5. I'm working on winXP. > > I use pg module. > > At the first time i get error that no found dll. when i add C:\Program > Files\PostgreSQL\8.3\bin to  the path variable i able to fix

Re: [Tutor] New to Python

2009-10-28 Thread Kent Johnson
Forwarding to the list with my reply (please use Reply All to reply to the list): On Wed, Oct 28, 2009 at 2:01 AM, wrote: > Hi Kent, > > Thank you for replying to my request, really appreciate it. > > I am not familiar with all your connections that you have mentioned below. > > What I can tell

[Tutor] Access PostGreSQL 8.3 by python 2.5

2009-10-28 Thread Mahasen Dehideniya
Hi , I'm try to access PostGreSQL 8.3 by python 2.5. I'm working on winXP. I use pg module. At the first time i get error that no found dll. when i add C:\Program Files\PostgreSQL\8.3\bin to  the path variable i able to fixed it. After that  i get following error.   >>> import pg Traceback (mo

[Tutor] Fwd: New to Python

2009-10-28 Thread Wayne
Remember to hit Reply to all - Forwarding your message onto the list -- Forwarded message -- From: Date: Wed, Oct 28, 2009 at 1:00 AM Subject: Re: [Tutor] New to Python To: sri...@gmail.com Hi Wayne, I will try as best to explain what I need to do. I have a log file. In that

Re: [Tutor] How to load a dict into a dict subclass?

2009-10-28 Thread Modulok
... >> Assume I have a dict, 'foo'. I also have my own class, 'Bar', which >> subclasses (i.e. is a derived class) of a dict. How do I eloquently >> get foo into an instace of Bar? Example: >> >> >> ### BEGIN CODE: >> class Bar(dict): >>pass # Act like a dict for now. >> >> foo = {'a': 100, 'b