[newbie] plotting pairs of data

2012-12-19 Thread hugocoolens
I have a data set for which x and y-values are presented as pairs of
floating point numbers:
e.g. 0.0364771 0.55569 is the first pair
. 0.132688 0.808496 is the second pair
.
.

The data is available in Python in this format:
['0.0364771 0.55569', '0.132688 0.808496', '0.232877 0.832833',
'0.332702 0.849128', '0.432695 0.862158']

I suppose it is possible to plot x versus y using matplotlib, maybe
separating the data first in two arrays, but I'm not sure whether this
is necessary.
Can anyone here help me further

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


Re: plotting pairs of data

2012-12-19 Thread hugocoolens
On 19 dec, 15:38, Thomas Bach  wrote:
> On Wed, Dec 19, 2012 at 05:47:30AM -0800,hugocoolenswrote:
> > The data is available in Python in this format:
> > ['0.0364771 0.55569', '0.132688 0.808496', '0.232877 0.832833',
> > '0.332702 0.849128', '0.432695 0.862158']
>
> > I suppose it is possible to plot x versus y using matplotlib, maybe
> > separating the data first in two arrays, but I'm not sure whether this
> > is necessary.
>
> I think, yes it is necessary to split the data in separate
> lists/arrays. Although I find it annoying, too.
>
> In case that not only the if, but also the how is the matter of your
> question something like
>
> xs = [ float(x) for x, _ in map(str.split, l) ]
> ys = [ float(y) for _, y in map(str.split, l) ]
>
> should do the trick.
>
> Regards,
>         Thomas Bach.

thanks Thomas this works nicely

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


[newbie] how to make program suggest to install missing modules

2014-12-08 Thread hugocoolens
I'd like to add the following to a python-program:

when a module (take rtlsdr as an example) is not installed on the system I'd 
like to ask the program something like:

module rtlsdr is missing, shall I install it? y or n
if n -->sorry but then I can't run this program and quit program
if y -->execute this command: 
os.system(sudo pip install pyrtlsdr)

continue program

can anyone here show me how to perform this properly?

thanks in advance
hugo

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


[newbie] how to make program suggest to install missing modules

2014-12-09 Thread hugocoolens
I'd like to add the following to a python-program:

when a module (take rtlsdr as an example) is not installed on the system I'd 
like to ask the program something like:

module rtlsdr is missing, shall I install it? y or n
if n -->sorry but then I can't run this program and quit program
if y -->execute this command:
os.system(sudo pip install pyrtlsdr)

continue program

can anyone here show me how to perform this properly?

thanks in advance
hugo

--- SoupGate-Win32 v1.05
 * Origin: [email protected]> (1:249/999)
--- Synchronet 3.15b-Win32 NewsLink 1.92
SpaceSST BBS Usenet <> Fidonet Gateway
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] how to make program suggest to install missing modules

2014-12-12 Thread hugocoolens
On Monday, December 8, 2014 9:00:13 PM UTC+1, [email protected] wrote:
> On Monday, December 8, 2014 10:46:47 AM UTC-8, Jean-Michel Pichavant wrote:
> > - Original Message -
> > > From: [email protected]
> > > try:
> > > import someModule
> > > except ImportError:
> > > print "Module is missing"
> > > # handle it!
> > > 
> > > Just make sure to attempt to import it again after making the call to
> > > pip to install it.
> > 
> > Note that ImportError may be raised for other reasons than a missing module.
> > 
> > Check https://docs.python.org/2/library/imp.html and the imp.find_module, 
> > it could be a safer way to check for a missing module.
> > 
> > JM
> > 
> > 
> > -- IMPORTANT NOTICE: 
> > 
> > The contents of this email and any attachments are confidential and may 
> > also be privileged. If you are not the intended recipient, please notify 
> > the sender immediately and do not disclose the contents to any other 
> > person, use it for any purpose, or store or copy the information in any 
> > medium. Thank you.
> Good point.
> Of course, imp.find_module ALSO throws ImportError if the module can't be 
> found, but at least in that case, you'd know the exact cause.

Thanks for the suggestions, you can see here below what I came up with.
All suggestions/corrections welcome:

#!/usr/bin/env python
import imp
import os
import sys
try:
imp.find_module('rtlsdr')
except ImportError:
print('Module rtlsdr is missing')
print("I'll try to install it")
os.system('sudo pip install pyrtlsdr')
try:
imp.find_module('rtlsdr')
except ImportError:
sys.exit('Sorry could not install module rtlsdr, contact your
local Python-guru')
import rtlsdr
print('Module rtlsdr succesfully imported')



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


how to install automatically missing modules on a debian-system

2014-02-19 Thread hugocoolens
It often happens I start a python-script I wrote some time ago on another
system and get messages like "module_x is missing". I then perform an apt-cache 
search module_x, followed by an apt-get install name_of_missing_module.deb
I was wondering whether someone here has a kind of method which automatically
looks for the missing modules as debian-packages and offers to install them?

hugo
-- 
https://mail.python.org/mailman/listinfo/python-list