On Tue, Oct 13, 2009 at 12:33, Tim Golden <m...@timgolden.me.uk> wrote: > I suspect you're coming from a C background? Or something > similar. Python's a very versatile language and tries to > help you avoid boilerplate. So you can do things like this:
Yeah... similar, I guess. C++ to some degree, VB, Basic, a smattering of perl, Java, and so on... I can read C for the most part (even some of the nasty stuff at the OS and hardware level) but I couldn't really write C if my life depended on it. To be honest, I started working in Perl about 9 years ago, and got about half way through learning it when I discovered Python, and how much easier Python is to write as well as read (especially when reading someone else's code). So I started learning python then. Then I got laid off a few months later, and haven't really done anything with it in ages. So I still remember just enough Python to be dangerous, and I'm trying to re-learn it as I go along... > <code> > import wmi > > c = wmi.WMI () > numProcs = len (c.Win32_Processor ()) > print "Number ...:", numProcs > # or > print "Number ...: %s" % numProcs > </code> Yeah... there's a lot I need to pick up again... and that's probably the hardest part. I have no idea where to even start. Which is why I'm doing this little exercise. It'll get me some class writing, importing, and doing some other stuff, but I'll end up missing some of the most basic stuff, like output formatting and such... Though I was interested in finding the functions to output to stdout and stderr directly, which will be nice too... > I blush. But in fact (he says, giving away all his secrets) my > magic incantation was simply this: > > http://www.google.co.uk/search?q=site%3Amicrosoft.com+win32_processor > > Of course, I have done that once or twice before ;) Heh... honstly, outside of some nice long BASH scripts, this is the first chance in years that I've had to actually write real code. I was a "software engineer" for 6 years, and I very rarely ever engineered any software. Most of what I wrote were shell scripts, though some were rather complex and did some neat things. That's where I picked up the little bit of C I have, as I had to sometimes instrument drivers and user-space applications to find out why a particular test was failing, but that was limited use stuff. I have a very long history with the general theory of programming and writing code, but what I lack is current experience, and most importantly, the vocabulary. Which is why I'm asking so many basic questions that I really could eventually find on my own. I know WHAT I want to do with this program, I just don't know how to tell Python just yet, though I'm pretty close at least to a proof of concept. Just like I know WHAT I want to search the Google for, but I don't know exactly what words to search on, and in that last case, it was really so simple that it never even occurred to me. My second big failing... I sometimes overthink things. :-) My next Python project (which I'll probably start working on later this week as I get bored) is going to be a web CGI to search multiple craigslist sites and display links to matching hits. I know that's been done to death, but it's something I thought of long before the various aggregating sites started popping up, and it looks like it would be fun. Besides, it gives me a definite goal and a definite product that will get me back into some web programming too... something else I haven't done in ages. By the way, I also figured out my own issues with finding memory. CIM_OperatingSystem includes a TotalVisibleMemorySize attribute that is what I was looking for. I kept looking at things that had PhysicalMemory in their names and I missed that one until I read a little deeper into another WMI option... That one gives the total physical memory available to the OS, which is the total Physical minus any shared memory... so on this machine, my 1024MB ends up being 1022MB... which is close enough for my purposes. Cheers Jeff -- Samuel Goldwyn - "I'm willing to admit that I may not always be right, but I am never wrong." - http://www.brainyquote.com/quotes/authors/s/samuel_goldwyn.html _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32