comp.lang.python
  Home FAQ Contact Sign in
comp.lang.python only
 
Advanced search
July 2008
motuwethfrsasuw
 123456 27
78910111213 28
14151617181920 29
21222324252627 30
28293031    31
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.python Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Newbie question         


Author: |e0
Date: Jul 8, 2008 23:37

Hi list,

i'm running Ubuntu Hardy Desktop and i've installed Tim Golden WMI.
However importing wmi module i have this error:
>>> import wmi
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.5/site-packages/wmi.py", line 141, in
from win32com.client import GetObject, Dispatch
ImportError: cannot import name GetObject

I can import win32com.client without problems.
Do i need to install any extra package?
On win i suppose i need win32 extensions, but on linux?

Thank you!

--
Regards,
Leonardo
no comments
  Returning the positions of a list that are non-zero         


Author: Benjamin Goudey
Date: Jul 8, 2008 22:26

I have a very large list of integers representing data needed for a
histogram that I'm going to plot using pylab. However, most of these
values (85%%-95%%) are zero and I would like to remove them to reduce
the amount of memory I'm using and save time when it comes to plotting
the data. To do this, I'm trying to find the best way to remove all of
the zero values and produce a list of indices of where the non-zero
values used to be.

For example, if my original list is [0,0,1,2,1,0,0] I would like to
produce the lists [1,2,1] (the non zero values) and [2,3,4] (indices
of where the non-zero values used to be). Removing non-zero values is
very easy but determining the indicies is where I'm having difficulty.

Thanks in advance for any help
7 Comments
  Re: (silly?) speed comparisons         


Author: Terry Reedy
Date: Jul 8, 2008 19:21

mk wrote:
> Out of curiosity I decided to make some speed comparisons of the same
> algorithm in Python and C++. Moving slices of lists of strings around
> seemed like a good test case.

If you use Python to, in effect, call well-written C functions, and most
of the computation time is spent in the C functions, then the total time
may be less than using C++ to call C or C++ functions that have not been
as heavily optimized. (Python is nearly 2 decades old, and several
people have perused the code base looking for speedups.)
no comments
  Re: a simple 'for' question         


Author: John McMonagle
Date: Jul 8, 2008 18:02

Ben Keshet wrote:
> Hi fans,
>
> I want to use a 'for' iteration to manipulate files in a set of folders,
> something like:
>
> folders= ['1A28','1A6W','56Y7']
> for x in folders:
> print x # print the current folder
> f = open('my/path/way/x/my_file.txt', 'r')
> ...
>

Use os.path.join

import os
folders = ['1A2B', '1A6W', '56Y7']
for x in folders:
f = open(os.path.join('my/path/way', x, 'my_file.txt'), 'r')
no comments
  Re: a simple 'for' question         


Author: Rajanikanth Jammalamadaka
Date: Jul 8, 2008 17:55

Thanks for correcting my typo norseman.

Ben: I forgot a slash after the first string as norseman pointed out.

Raj

On Tue, Jul 8, 2008 at 5:51 PM, norseman hughes.net> wrote:
>
> Almost correct: There is a typo. Should read:
>
> for x in folders:
> open('my/path/way/'+x+'/myfile.txt','r')
>
>
>
>
> Rajanikanth...
Show full article (1.92Kb)
no comments
  Re: a simple 'for' question         


Author: norseman
Date: Jul 8, 2008 17:51

Almost correct: There is a typo. Should read:

for x in folders:
open('my/path/way/'+x+'/myfile.txt','r')

Rajanikanth Jammalamadaka wrote:
> Hi!
>
> Try this
>
> for x in folders:
> open('my/path/way'+x+'myfile.txt','r')
>
> Cheers,
>
> Raj
>
> On Tue, Jul 8, 2008 at 5:08 PM, Ben Keshet
Show full article (1.49Kb)
no comments
  Re: a simple 'for' question         


Author: Rajanikanth Jammalamadaka
Date: Jul 8, 2008 17:32

Hi!

Try this

for x in folders:
open('my/path/way'+x+'myfile.txt','r')

Cheers,

Raj

On Tue, Jul 8, 2008 at 5:08 PM, Ben Keshet umbc.edu> wrote:
> Hi fans,
>
> I want to use a 'for' iteration to manipulate files in a set of folders,
> something like:
>
> folders= ['1A28','1A6W'...
Show full article (1.43Kb)
no comments
  a simple 'for' question         


Author: Ben Keshet
Date: Jul 8, 2008 17:08

Hi fans,

I want to use a 'for' iteration to manipulate files in a set of folders,
something like:

folders= ['1A28','1A6W','56Y7']
for x in folders:
print x # print the current folder
f = open('my/path/way/x/my_file.txt', 'r')
...

where 'x' in the pathway should iterate over '1A28','1A6W','56Y7'. How
should I identify 'x' in the pathway line as the same x that is
iterating over 'folders'?

I am getting the following error:
Show full article (0.99Kb)
1 Comment
  Re: numeric emulation and __pos__         


Author: Ethan Furman
Date: Jul 8, 2008 15:54

Terry Reedy wrote:
>
>
> Ethan Furman wrote:
>
>> Anybody have an example of when the unary + actually does something?
>> Besides the below Decimal example. I'm curious under what circumstances
>> it would be useful for more than just completeness (although
>> completeness for it's own sake is important, IMO).
>
>
> All true operators and some built-in functions translate to special
> method calls.
> -x == x.__neg__() == type(x).__neg__(x) == x.__class__.__neg__(x)
>
> What should happen to '+x'? Raise SyntaxError? Ignore the '+'? Or
> translate it to __pos__ in analogy with '-' and __neg__? Guido made the
> third choice: partly for consistency perhaps, but also for the benefit
> of user-written classes. Decimal started as user-contributed decimal.py.
> ...
Show full article (1.35Kb)
no comments
  find all ODBC databases ?         


Author: Stef Mientki
Date: Jul 8, 2008 15:43

hello,

I'm working on a general database manager,
which will be open source
and should preferable work under all OS.

Now in windows I can find the ODBC databases by reading some reg key.
I also know that ODBC is supported under Linux (I don't know anything of
Linux),
but how can I get all ODBC databases in a platform independant way ?

thanks,
Stef Mientki
no comments
1 2 3