Re: [Tutor] XP & catching execl o/p ?

2006-12-06 Thread Tim Golden
| Struggling with python & XP again. My app needs to know if a | certain program is running on my XP box As a complete alternative, consider using WMI: import os, sys import wmi c = wmi.WMI () for process in c.Win32_Process (Name="excel.exe"): print "Excel is running" break else: print "

Re: [Tutor] Integer?

2006-12-06 Thread Luke Paireepinart
> Very interesting. But what is "duckly-typed"? I'm so dumb I can't > distinguish between a typo and a technical term.. > > Dick Moores > > Refer to the Wikipedia article on Duck Typing: http://en.wikipedia.org/wiki/Duck_typing Basically, if you saw my example earlier of substituting stdout:

Re: [Tutor] How to kill an app from python on windows? (Tim Golden)

2006-12-06 Thread Tim Golden
[Tim Golden] | > This link may get you started: | > | > http://effbot.org/pyfaq/how-do-i-emulate-os-kill-in-windows.htm | > | > although it may not apply, depending on the exact | > circumstances of what you're doing. [Paulino] | Thank you Tim, | | How do i get the pid of the process? I'm going

Re: [Tutor] order of arguments in function

2006-12-06 Thread Michael Lange
On Tue, 05 Dec 2006 22:18:02 -0800 Dick Moores <[EMAIL PROTECTED]> wrote: > Say I have a function, > > def my_function(max, min=0): > return max - min > > The order of arguments is counterintuitive, but it seems it can't be > changed if I want to have a default min. Is there way to write >

Re: [Tutor] XP & catching execl o/p ?

2006-12-06 Thread Kent Johnson
Dave S wrote: > Hi all, > > Struggling with python & XP again. My app needs to know if a certain program > is running on my XP box > > Ideal world - I can get the output of 'tasklist.exe' into a string. > > I have tried > > os.execl('') > It throws the output to the terminal + I need the e

[Tutor] changing a variable over simple network (with pyOpenGL)

2006-12-06 Thread Michael Shulman
Hello, I am trying to write a very simple py-opengl program pair causing a variable in each program to be changed by the other. I am able to open a command window in which I manually assign a value to the variable, but I cannot seem to implement the udp/ip information I wish to send into a f

Re: [Tutor] XP & catching execl o/p ?

2006-12-06 Thread Dave S
On Tuesday 05 December 2006 23:32, Alan Gauld wrote: > "Dave S" <[EMAIL PROTECTED]> wrote > > > Struggling with python & XP again. My app needs to know if a certain > > program > > is running on my XP box > > > > os.execl('') > > It throws the output to the terminal + I need the exact path to t

Re: [Tutor] XP & catching execl o/p ?

2006-12-06 Thread Dave S
On Wednesday 06 December 2006 08:48, Tim Golden wrote: > | Struggling with python & XP again. My app needs to know if a > | certain program is running on my XP box > > As a complete alternative, consider using WMI: > > > import os, sys > import wmi > > c = wmi.WMI () > for process in c.Win32_Proce

Re: [Tutor] XP & catching execl o/p ?

2006-12-06 Thread Dave S
On Wednesday 06 December 2006 11:04, Kent Johnson wrote: > Dave S wrote: > > Hi all, > > > > Struggling with python & XP again. My app needs to know if a certain > > program is running on my XP box > > > > Ideal world - I can get the output of 'tasklist.exe' into a string. > > > > I have tried > >

Re: [Tutor] XP & catching execl o/p ?

2006-12-06 Thread Tim Golden
[Dave S] | Just looked at WMI - didn't know it existed ! | Am going down the subprocess route first as its 'built in'. | If that does not work - hello WMI Personally, I find having both (and other) tools in my toolbelt useful -- I've just answered another question elsewhere about starting and st

Re: [Tutor] order of arguments in function

2006-12-06 Thread Dick Moores
At 02:28 AM 12/6/2006, Michael Lange wrote: >On Tue, 05 Dec 2006 22:18:02 -0800 >Dick Moores <[EMAIL PROTECTED]> wrote: > > > Say I have a function, > > > > def my_function(max, min=0): > > return max - min > > > > The order of arguments is counterintuitive, but it seems it can't be > > change

Re: [Tutor] XP & catching execl o/p ?

2006-12-06 Thread Dave S
On Wednesday 06 December 2006 11:43, Dave S wrote: > On Tuesday 05 December 2006 23:32, Alan Gauld wrote: > > "Dave S" <[EMAIL PROTECTED]> wrote > > > > > Struggling with python & XP again. My app needs to know if a certain > > > program > > > is running on my XP box > > > > > > os.execl('') >

Re: [Tutor] Integer?

2006-12-06 Thread Dick Moores
At 01:07 AM 12/6/2006, Luke Paireepinart wrote: > > Very interesting. But what is "duckly-typed"? I'm so dumb I can't > > distinguish between a typo and a technical term.. > > > > Dick Moores > > > > >Refer to the Wikipedia article on Duck Typing: >http://en.wikipedia.org/wiki/Duck_typing Thanks,

[Tutor] Decimal module question

2006-12-06 Thread Dick Moores
I wrote this function: def numberRounding(n, significantDigits=4): """ Rounds a number (float or integer, negative or positive) to any number of significant digits. If an integer, there is no limitation on it's size. """ import decimal def d(x):

Re: [Tutor] Decimal module question

2006-12-06 Thread Kent Johnson
Dick Moores wrote: > I wrote this function: > > def numberRounding(n, significantDigits=4): > """ > Rounds a number (float or integer, negative or positive) to any number > of > significant digits. If an integer, there is no limitation on it's size. > """ > import de

[Tutor] Python scrypts and daemons

2006-12-06 Thread emilia12
Hi all, I have a python script (with endless loop) and i want to start it from the rc.config file. So, the question is: how to covert this script to work as daemon ... or how to start the python interpreter ... to work as background process ? E. - Спортни залагани

Re: [Tutor] Decimal module question

2006-12-06 Thread Dick Moores
At 05:35 AM 12/6/2006, Kent Johnson wrote: >Dick Moores wrote: >>I wrote this function: >>def numberRounding(n, significantDigits=4): >> """ >> Rounds a number (float or integer, negative or positive) >> to any number of >> significant digits. If an integer, there is no lim

Re: [Tutor] Python scrypts and daemons

2006-12-06 Thread Christopher Arndt
[EMAIL PROTECTED] schrieb: > > Hi all, > > I have a python script (with endless loop) and i want to > start it from the rc.config file. So, the question is: how > to covert this script to work as daemon ... or how to start > the python interpreter ... to work as background process ? Search googl

Re: [Tutor] Integer?

2006-12-06 Thread Mike Hansen
> > How can I check if a variable is an integer? > > Luke and John have answered your question, but we should also > ask, why > do you want to do that? Explicit type testing is a code > smell, perhaps > there is a better way to do what you want. > > Kent > Kent, Can you explain further? Re

[Tutor] Q: win32 download (attack of the newbies)

2006-12-06 Thread Toon Pieton
Hey, friendly person who took the time to read this! I'm cutting right to the case. Trying to get certain information into Excel. However, I can't: from win32com.client import Dispatch xlApp = Dispatch("Excel.Application") # continues As soon as I start the program, I get a error: win32com.cli

Re: [Tutor] Q: win32 download (attack of the newbies)

2006-12-06 Thread Tim Golden
[Toon Pieton] | As soon as I start the program, I get a error: | win32com.client not found. This - of course - leads to the | conclusion that I don't have the win32com module installed. I | tried to find it (Google), but all I could find when | searching for "python win32 module (download)", I

[Tutor] subprocess & pyw conflict ?

2006-12-06 Thread Dave S
Hi all, I thought I had my solution with subprocess ... my test code ... #!/usr/bin/env python # -*- coding: iso8859_1 -*- import subprocess a = subprocess.Popen('tasklist.exe', bufsize=0, stdout=subprocess.PIPE, universal_newlines=True) op = a.stdout.readlines() for i in op: i

Re: [Tutor] Q: win32 download (attack of the newbies)

2006-12-06 Thread Kent Johnson
Toon Pieton wrote: > Hey, friendly person who took the time to read this! > > I'm cutting right to the case. Trying to get certain information into > Excel. However, I can't: > > from win32com.client import Dispatch > > xlApp = Dispatch(" > Excel.Application") > # continues > > As soon as I st

Re: [Tutor] Integer?

2006-12-06 Thread Kent Johnson
Mike Hansen wrote: >>> How can I check if a variable is an integer? >> Luke and John have answered your question, but we should also >> ask, why >> do you want to do that? Explicit type testing is a code >> smell, perhaps >> there is a better way to do what you want. >> >> Kent >> > > Kent, >

Re: [Tutor] Q: win32 download (attack of the newbies)

2006-12-06 Thread Kent Johnson
Tim Golden wrote: > Using win32com and Excel is very easy, but there > are alternatives if you want: > > http://cheeseshop.python.org/pypi/xlrd/0.5.2 xlrd is for reading only - OP wants to write Excel files. Kent ___ Tutor maillist - Tutor@python.o

Re: [Tutor] Q: win32 download (attack of the newbies)

2006-12-06 Thread Tim Golden
[Kent Johnson] | Tim Golden wrote: | > Using win32com and Excel is very easy, but there | > are alternatives if you want: | > | > http://cheeseshop.python.org/pypi/xlrd/0.5.2 | | xlrd is for reading only - OP wants to write Excel files. Oops! Quite right. I was moving a bit too fast. Sorry, OP

[Tutor] How to create variable length bar chart ??

2006-12-06 Thread Asrarahmed Kadri
Hi folks, I have a problem with drawing a BAR-chart. I am drawing a HORIZONTAL bar chart. I did manage to sort out the length issue of individual bars (with the help of inputs from this forum's members). What I want is the height of the bar chart should be determined dynamically (basically it m

Re: [Tutor] Q: win32 download (attack of the newbies)

2006-12-06 Thread Kent Johnson
Toon Pieton wrote: > Hey Kent, > > Thanks for your reply. Can you suggest which module I should look at? > And can I make diagrams using that module? Assuming you are asking about modules for writing CSV files, then look at the csv module. CSV (comma-separated value) is a simple text format th

[Tutor] List to dictionary question

2006-12-06 Thread Morpheus
I'm new to programming, and trying to learn the Python language. The following code does what I want it to do, but I have not idea how it works. def scanList(names,temp): for i in names: temp[i] = 0 print temp Names = [] temp = {} I have a list of names (Names[]) and want to

[Tutor] WXPython Listbox Problem

2006-12-06 Thread Toon Pieton
Hey friendly users! I'm trying to make a simple program to calculate the odds when playing poker. The idea is that you select both your cards from listboxes. However, no matter what I try, I just can't select a entry in either of the listboxes! I can click all I want, it just won't select. Here's

Re: [Tutor] List to dictionary question

2006-12-06 Thread Mike Hansen
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Morpheus > Sent: Wednesday, December 06, 2006 9:00 AM > To: tutor@python.org > Subject: [Tutor] List to dictionary question > > I'm new to programming, and trying to learn the Python language. > T

Re: [Tutor] order of arguments in function

2006-12-06 Thread Michael Lange
On Wed, 06 Dec 2006 04:29:54 -0800 Dick Moores <[EMAIL PROTECTED]> wrote: (...) > > > >def my_function(min, max=None): > > if max is None: > > max = min > > min = 0 > > # stuff > > Great! > > >I am not sure if this is more intuitive though. > > >>> > def my_function(min

Re: [Tutor] WXPython Listbox Problem

2006-12-06 Thread Jorgen Bodde
Try ID's higher then 1 ... low ID's are usually taken by wxWidgets. To be safe simply create them with wx.ID_ANY (from the top of my head) and after that: self.box1.Bind(wx.EVT_LISTBOX, self.b1func,id=self.box1.GetId()) Which is a bit more dynamic anyway and saves you some constants. Further

[Tutor] (no subject)

2006-12-06 Thread rumpy
Hi Folks, I'm working through Magnus Lie Hetland's excellent book "Beginning Python" and I have a few basic (I think) questions. Specifically, regarding his first project in Chapter 20 (Instant Markup). The outline of the project is to take a plain text file and "mark it up" into HTML or XML.

Re: [Tutor] How to create variable length bar chart ??

2006-12-06 Thread Alan Gauld
"Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote in > What I want is the height of the bar chart should be determined > dynamically > (basically it means the length of the Y-axis), as per the number of > data-items being displayed. Hmm, I thought we ansdwered this recently... Anyhow you just calcu

[Tutor] Generator questions.

2006-12-06 Thread rumpy
Hi Folks, I'm working through Magnus Lie Hetland's excellent book "Beginning Python" and I have a few basic (I think) questions. Specifically, regarding his first project in Chapter 20(Instant Markup). The outline of the project is to take a plain text file and "mark it up" into HTML or XML.

Re: [Tutor] How to create variable length bar chart ??

2006-12-06 Thread Asrarahmed Kadri
I got that point, what I want is how the dimensions of the canvas would be adjusted so as to incorporate this Y-axis variable length? Do I need a scrollbar for that?? Thanks in advance. Regards, Asrarahmed Kadri On 12/6/06, Alan Gauld <[EMAIL PROTECTED]> wrote: "Asrarahmed Kadri" <[EMAIL PR

Re: [Tutor] Generator questions.

2006-12-06 Thread wesley chun
> def lines(file): >for line in file: yield line >yield '\n' > > del blocks(file): >block = [] >for line in lines(file): >if line.strip(): > block.append(line) >elif block: > yield ''.join(block).strip() > block = [] > > 1.) Does the yie

[Tutor] Beautiful Soup

2006-12-06 Thread Shitiz Bansal
Hi, I am using beautiful soup to get links from an html document. I found that beautiful Soup changes the & in the links to & due to which some of the links become unusable. Is there any way I could stop this behaviour? Regards, Shitiz - Access over 1 million so

Re: [Tutor] Running drPython and other Pythonscript on Macintosh OS/X

2006-12-06 Thread Markus Rosenstihl
Am 05.12.2006 um 09:44 schrieb Anders Persson: > Hi! > > I try to learn my son Development using Python. > I have found that drPython was a great enviroment and easy for him to > understand. > > Is't a problem running om Macintosh OS/X i have to start on > commandline, > OS/X > dosen't understan

Re: [Tutor] Generator questions.

2006-12-06 Thread rumpy
Hi Wesley, Thank you very much for the feeback. It helped a lot! Quoting wesley chun <[EMAIL PROTECTED]>: >> def lines(file): >>for line in file: yield line >>yield '\n' >> >> del blocks(file): >>block = [] >>for line in lines(file): >>if line.strip(): >> bloc

Re: [Tutor] order of arguments in function

2006-12-06 Thread Eike Welk
On Wednesday 06 December 2006 13:29, Dick Moores wrote: > I meant that the order "min, max" is more intuitive than "max, > min". Don't you agree? And it's the order used in random.randint(), > random.randrange(), and random.uniform(), for examples. What about two intuitively named functions, like

Re: [Tutor] How to create variable length bar chart ??

2006-12-06 Thread ALAN GAULD
--- Asrarahmed Kadri <[EMAIL PROTECTED]> wrote: > I got that point, what I want is how the dimensions of the > canvas would be > adjusted so as to incorporate this Y-axis variable length? > You provide the size of the canvas when you create it normally. But you can use at least 2 approaches.

[Tutor] Create a script to make bootable USB device.

2006-12-06 Thread Chris Hengge
Is this something I can do using just python and libraries? I know I could automate other utilities, but I'd like to write some kind of neat utility myself that I could play with for more experience. Goal: make USB drive bootable to a dos prompt (dont care what dos, assuming I need a bootable ima

Re: [Tutor] subprocess & pyw conflict ?

2006-12-06 Thread Luke Paireepinart
Dave S wrote: > Hi all, > > I thought I had my solution with subprocess ... my test code ... > > > > #!/usr/bin/env python > # -*- coding: iso8859_1 -*- > > import subprocess > > a = subprocess.Popen('tasklist.exe', bufsize=0, stdout=subprocess.PIPE, > universal_newlines=True) > op = a.s

[Tutor] Is there any good turtorial about numeric python for beginners?

2006-12-06 Thread linda.s
Is there any good tutorial about numeric python for beginners? I have googled around and many of them are either too old or aims at experienced users... Thanks, Linda ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] List to dictionary

2006-12-06 Thread Morpheus
I'm new to programming, and trying to learn the Python language. The following code does what I want it to do, but I have not idea how it works. def scanList(names,temp): for i in names: temp[i] = 0 print temp Names = [] temp = {} I have a list of names (Names[]) and want to

Re: [Tutor] Is there any good turtorial about numeric python for beginners?

2006-12-06 Thread Dave Kuhlman
On Wed, Dec 06, 2006 at 05:49:22PM -0800, linda.s wrote: > Is there any good tutorial about numeric python for beginners? > I have googled around and many of them are either too old or aims at > experienced users... Look here: http://new.scipy.org/Wiki/Documentation Dave -- Dave Kuhlman ht

Re: [Tutor] ***SPAM*** List to dictionary

2006-12-06 Thread Bill Campbell
On Wed, Dec 06, 2006, Morpheus wrote: >I'm new to programming, and trying to learn the Python language. >The following code does what I want it to do, but I have not idea how it >works. > >def scanList(names,temp): >for i in names: >temp[i] = 0 >print temp > >Names = [] >temp =

Re: [Tutor] ***SPAM*** List to dictionary

2006-12-06 Thread Luke Paireepinart
>> I have a list of names (Names[]) and want to remove duplicate names in >> the list. [snip] >> > > The way I usually do this is something like: > > outDict = dict(map(lambda x: (x, 1), inList)) > names = outDict.keys() > names.sort() > How about this :D # Remove duplicates from a list:

Re: [Tutor] List to dictionary

2006-12-06 Thread Dick Moores
At 09:53 PM 12/6/2006, Luke Paireepinart wrote: > >> I have a list of names (Names[]) and want to remove duplicate names in > >> the list. [snip] > >> > > > > The way I usually do this is something like: > > > > outDict = dict(map(lambda x: (x, 1), inList)) > > names = outDict.keys() > > names.so