Re: How can i create a random array of floats from 0 to 5 in python

2013-03-12 Thread llanitedave
On Tuesday, March 12, 2013 2:59:29 PM UTC-7, Oscar Benjamin wrote: > On 12 March 2013 20:21, llanitedave wrote: > > > On Tuesday, March 12, 2013 10:47:25 AM UTC-7, Maarten wrote: > > >> On Tuesday, March 12, 2013 6:11:10 PM UTC+1, Norah Jones wrote: > > >> > > >> > I want to create a random fl

Re: del not working for (exhausted) dict iterable value (Python 3.3)

2013-03-12 Thread Thomas Rachel
Am 12.03.2013 06:52 schrieb alex23: You're effectively doing this: event = dict(Items=[1,2,3]) for e in event['Items']: ... del event['Items'] ... Traceback (most recent call last): File "", line 2, in KeyError: 'Items' You want to move your del statement up an indentation level so i

Re: Finding the Min for positive and negative in python 3.3 list

2013-03-12 Thread Steven D'Aprano
On Tue, 12 Mar 2013 17:03:08 +, Norah Jones wrote: > For example: > a=[-15,-30,-10,1,3,5] > > I want to find a negative and a positive minimum. > > example: negative > print(min(a)) = -30 > > positive > print(min(a)) = 1 Thank you for providing examples, but they don't really cover all th

Re: A string and an integer to appear in tuple (python 2.7)

2013-03-12 Thread Vlastimil Brom
2013/3/13 Jiewei Huang : > Hi all, > > I'm currently stuck at this question on > > Writing a function len_str that takes a string as an argument and returns a > pair consisting of the length of the string and the string itself. > > Example: len_str('Meaning of life') should return the tuple (15, '

Re: A string and an integer to appear in tuple (python 2.7)

2013-03-12 Thread Oscar Benjamin
On 13 March 2013 00:21, Jiewei Huang wrote: > Hi all, > > I'm currently stuck at this question on > > Writing a function len_str that takes a string as an argument and returns a > pair consisting of the length of the string and the string itself. > > Example: len_str('Meaning of life') should ret

A string and an integer to appear in tuple (python 2.7)

2013-03-12 Thread Jiewei Huang
Hi all, I'm currently stuck at this question on Writing a function len_str that takes a string as an argument and returns a pair consisting of the length of the string and the string itself. Example: len_str('Meaning of life') should return the tuple (15, 'Meaning of life'). I can only thi

Re: Pygame mouse cursor load/unload

2013-03-12 Thread Alex Gardner
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote: > I am in the process of making a pong game in python using the pygame library. > My current problem is that when I move the mouse, it turns off as soon as > the mouse stops moving. The way I am doing this is by making the default

Re: del not working for (exhausted) dict iterable value (Python 3.3)

2013-03-12 Thread Nick Mellor
Thanks Alex! Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: How can i create a random array of floats from 0 to 5 in python

2013-03-12 Thread Oscar Benjamin
On 12 March 2013 20:21, llanitedave wrote: > On Tuesday, March 12, 2013 10:47:25 AM UTC-7, Maarten wrote: >> On Tuesday, March 12, 2013 6:11:10 PM UTC+1, Norah Jones wrote: >> >> > I want to create a random float array of size 100, with the values in the >> > array ranging from 0 to 5. I have tri

Re: How can i create a random array of floats from 0 to 5 in python

2013-03-12 Thread Dave Angel
On 03/12/2013 01:11 PM, Norah Jones wrote: I want to create a random float array of size 100, with the values in the array ranging from 0 to 5. I have tried random.sample(range(5),100) but that does not work. How can i get what i want to achieve? None of the responses so far actually give y

Re: How can i create a random array of floats from 0 to 5 in python

2013-03-12 Thread llanitedave
On Tuesday, March 12, 2013 10:47:25 AM UTC-7, Maarten wrote: > On Tuesday, March 12, 2013 6:11:10 PM UTC+1, Norah Jones wrote: > > > I want to create a random float array of size 100, with the values in the > > array ranging from 0 to 5. I have tried random.sample(range(5),100) but > > that does

programming course

2013-03-12 Thread leonardo
sorry for bothering you, i found www.code.org, do you think is that useful? i am a beginner and i would really like to learn, but i need a step by step website or books, any recommendations? thanks! Inizio messaggio inoltrato: > Da: Ned Deily > Oggetto: Re: [Python-Help] idle doesn't work

Re: [Python-Help] idle doesn't work

2013-03-12 Thread leonardo
thanks now python shell works Il 12/03/2013 17.52, Ned Deily ha scritto: In article <513f5080.6030...@libero.it>, leonardo wrote: first of all thanks for trying to help me. the text of my email was the following: i have a mac os x 10.8, i had already python 2.7, i downloaded python 3.3 an

Re: Finding the Min for positive and negative in python 3.3 list

2013-03-12 Thread Wolfgang Maier
Wolfgang Maier biologie.uni-freiburg.de> writes: > > Norah Jones gmail.com> writes: > > > > > For example: > > a=[-15,-30,-10,1,3,5] > > I want to find a negative and a positive minimum. > > example: negative > > print(min(a)) = -30 > > positive > > print(min(a)) = 1 > > > > > > > > try t

image transforming web proxy?

2013-03-12 Thread Skip Montanaro
I stumbled upon an old FFT tutorial on astro.berkeley.edu website whose images are in xbm format. Neither Chrome nor Firefox knows how to display X bitmap format and for Chrome at least, I've been unable to find an extension to do the conversion (didn't hunt for a FF extension). I can clearly dow

Re: Finding the Min for positive and negative in python 3.3 list

2013-03-12 Thread Terry Reedy
On 3/12/2013 1:03 PM, Norah Jones wrote: For example: a=[-15,-30,-10,1,3,5] I want to find a negative and a positive minimum. example: negative print(min(a)) = -30 positive print(min(a)) = 1 If this is homework, stop reading and do it yourself ;-) Otherwise... >>> min(i for i in a if i >0) 1

Re: Finding the Min for positive and negative in python 3.3 list

2013-03-12 Thread Devin Jeanpierre
> min(a) This does not return a negative minimum on input [1] (because there is none). > and > > min([e for e in a if e >=0] This does not return a positive minimum on input [0] (because there is none). I would have said: pos_min = min(e for e in a if e > 0) neg_min = min(e for e in a

Re: How can i create a random array of floats from 0 to 5 in python

2013-03-12 Thread Maarten
On Tuesday, March 12, 2013 6:11:10 PM UTC+1, Norah Jones wrote: > I want to create a random float array of size 100, with the values in the > array ranging from 0 to 5. I have tried random.sample(range(5),100) but that > does not work. How can i get what i want to achieve? Use numpy import nump

Re: Finding the Min for positive and negative in python 3.3 list

2013-03-12 Thread Wolfgang Maier
Norah Jones gmail.com> writes: > > For example: > a=[-15,-30,-10,1,3,5] > I want to find a negative and a positive minimum. > example: negative > print(min(a)) = -30 > positive > print(min(a)) = 1 > > > try this: min(a) => -30 min([n for n in a if i>0]) => 1 of course, you have to figur

Re: Finding the Min for positive and negative in python 3.3 list

2013-03-12 Thread Jean-Michel Pichavant
- Original Message - > For example: > a=[-15,-30,-10,1,3,5] > I want to find a negative and a positive minimum. > example: negative > print(min(a)) = -30 > positive > print(min(a)) = 1 > -- > http://mail.python.org/mailman/listinfo/python-list min(a) and min([e for e in a if e >=0]

Re: How can i create a random array of floats from 0 to 5 in python

2013-03-12 Thread Gary Herron
On 03/12/2013 10:11 AM, Norah Jones wrote: I want to create a random float array of size 100, with the values in the array ranging from 0 to 5. I have tried random.sample(range(5),100) but that does not work. How can i get what i want to achieve? >>> [random.uniform(0,5) for i in range(10

Finding the Min for positive and negative in python 3.3 list

2013-03-12 Thread Norah Jones
For example: a=[-15,-30,-10,1,3,5] I want to find a negative and a positive minimum. example: negative print(min(a)) = -30 positive print(min(a)) = 1 -- http://mail.python.org/mailman/listinfo/python-list

Re: How can i create a random array of floats from 0 to 5 in python

2013-03-12 Thread Boris FELD
You can use [random.random() * 5 for x in range(100)] but works only on range [0, 5). If you want to include 5, you will need more code. Cheers, FELD Boris 2013/3/12 Norah Jones : > I want to create a random float array of size 100, with the values in the > array ranging from 0 to 5. I have tried

How can i create a random array of floats from 0 to 5 in python

2013-03-12 Thread Norah Jones
I want to create a random float array of size 100, with the values in the array ranging from 0 to 5. I have tried random.sample(range(5),100) but that does not work. How can i get what i want to achieve? -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Help] idle doesn't work

2013-03-12 Thread Ned Deily
In article <513f5080.6030...@libero.it>, leonardo wrote: > first of all thanks for trying to help me. the text of my email was the > following: > i have a mac os x 10.8, i had already python 2.7, i downloaded python > 3.3 and active tcl 8.5, but idle and the new version don't work, the > answe

Re: Snowed In?

2013-03-12 Thread Octothorpe
On Tue, 12 Mar 2013 15:28:27 +, BlindAnagram wrote: > Hi Geoff > > Are you snowed in? > > Its OK here. > >Brian Why Yes, matter if fact I am listening to snow blind -- http://mail.python.org/mailman/listinfo/python-list

Re: Reversing bits in a byte

2013-03-12 Thread 88888 Dihedral
Oscar Benjamin於 2013年3月12日星期二UTC+8下午11時44分50秒寫道: > On 12 March 2013 14:59, Oscar Benjamin wrote: > > > Numpy and matplotlib will do what you want: > > > > > > import numpy as np > > > import matplotlib.pyplot as plt > > > > > > def bits_to_ndarray(bits, shape): > > > abytes = np.frombuf

2-D drawing/map with python

2013-03-12 Thread Huseyin Emre Guner
Hello, I am newbie in Python. I would like to make a project using python. The main ideo of this project is that a user enters the x,y values to the Gui(PyQt or Gtk) and then a 2-D map is plotted due to the x,y values. First, I use Pygame commands "(pygame.draw.line(window, (255, 255, 255), (10

Re: [Python-Help] idle doesn't work

2013-03-12 Thread leonardo
first of all thanks for trying to help me. the text of my email was the following: i have a mac os x 10.8, i had already python 2.7, i downloaded python 3.3 and active tcl 8.5, but idle and the new version don't work, the answer is:"idle's subprocess didn't make connection or personal firewall

Re: Reversing bits in a byte

2013-03-12 Thread Oscar Benjamin
On 12 March 2013 14:59, Oscar Benjamin wrote: > Numpy and matplotlib will do what you want: > > import numpy as np > import matplotlib.pyplot as plt > > def bits_to_ndarray(bits, shape): > abytes = np.frombuffer(bits, dtype=np.uint8) > abits = np.zeros(8 * len(abytes), np.uint8) > for

Snowed In?

2013-03-12 Thread BlindAnagram
Hi Geoff Are you snowed in? Its OK here. Brian -- http://mail.python.org/mailman/listinfo/python-list

Re: Reversing bits in a byte

2013-03-12 Thread Oscar Benjamin
On 12 March 2013 13:28, Robert Flintham wrote: > Sorry, the subject line was for a related question that I decided not to ask, > I forgot to change it when I changed my email. I've changed it now! > > I'm using Python 3.3 on Windows with the pydicom module > (http://code.google.com/p/pydicom/).

Re: Reversing bits in a byte

2013-03-12 Thread Tim Chase
On 2013-03-11 15:32, Robert Flintham wrote: > I have a 'bytes' object which contains a simple bitmap image (i.e. > 1 bit per pixel). I can't work out how I would go about displaying > this image. Does anyone have any thoughts? You'd need to detail - how you want to display it (console, GUI, web

Matplotlib Slider Widget and changing colorbar threshold

2013-03-12 Thread kevin . khan27
I am currently trying to work on a program that will allow the user to display their dataset in the form of a colormap and through the use of sliders, it will also allow the user to adjust the threshold of the colormap and thus update the colormap accordingly. The best to describe this would be

Re: Running external module and accessing the created objects

2013-03-12 Thread Kene Meniru
Dave Angel davea.name> writes: > > The __import__() function is defined > http://docs.python.org/2/library/functions.html#__import__ > Thanks. The name of the imported file will change with each user and for each project so according to the this reference using this in my situation makes s

Re: Running external module and accessing the created objects

2013-03-12 Thread Kene Meniru
Michael Torrie gmail.com> writes: > It's not possible to setuid a python script, so I don't see how execfile > or exec is any more dangerous than the user creating a shell script that > rm -rf * things, and then running it. > > Bash "exec's" scripts all the time that users create and provide. H

RE: Reversing bits in a byte

2013-03-12 Thread Robert Flintham
Further to my earlier reply to Dave: I'd like to either display the image in a GUI, or save it in a format that can be opened easily in Windows (like a PNG or a 24-bit BMP). I know the dimensions as it's coming from the header of a DICOM file. I'm trying to analyse DICOM images where an 'overl

RE: Reversing bits in a byte

2013-03-12 Thread Robert Flintham
Sorry, the subject line was for a related question that I decided not to ask, I forgot to change it when I changed my email. I've changed it now! I'm using Python 3.3 on Windows with the pydicom module (http://code.google.com/p/pydicom/). Using pydicom, I've ended up with a "bytes" object of

Re: Reversing bits in a byte

2013-03-12 Thread Dave Angel
On 03/11/2013 11:32 AM, Robert Flintham wrote: Hi, I have a 'bytes' object which contains a simple bitmap image (i.e. 1 bit per pixel). I can't work out how I would go about displaying this image. Does anyone have any thoughts? All the best, Rob How does your subject line relate to your

Reversing bits in a byte

2013-03-12 Thread Robert Flintham
Hi, I have a 'bytes' object which contains a simple bitmap image (i.e. 1 bit per pixel). I can't work out how I would go about displaying this image. Does anyone have any thoughts? All the best, Rob Robert Flintham Trainee Clinical Scientist - MRI Tel: +44 (0)121 371 7000 Email: robert

Re: Store a variable permanently

2013-03-12 Thread Jean-Michel Pichavant
- Original Message - > On Mon, 11 Mar 2013 11:19:49 +0100, Jean-Michel Pichavant wrote: > > [...] > > While your point about security is fair, the others aren't. Pickle > > uses > > by default an ascii representation of the data, it's readable and > > writeable. > > > > import pickle > >

Re: Missing logging output in Python

2013-03-12 Thread W. Matthew Wilson
I made that code into a program like this: ### BEGIN import logging def configure_logging(): logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)8s %(message)s', datefmt='%Y-%m-%d\t%H:%M:%s', filename='/tmp/log

Re: Running external module and accessing the created objects

2013-03-12 Thread Dave Angel
On 03/12/2013 12:05 AM, Michael Torrie wrote: On 03/11/2013 06:48 PM, Dave Angel wrote: I hope you're just kidding. execfile() and exec() are two of the most dangerous mechanisms around. import or __import__() would be much better, as long as your user hasn't already run myapp.py as his script

Re: Store a variable permanently

2013-03-12 Thread Steven D'Aprano
On Mon, 11 Mar 2013 11:19:49 +0100, Jean-Michel Pichavant wrote: [...] > While your point about security is fair, the others aren't. Pickle uses > by default an ascii representation of the data, it's readable and > writeable. > > import pickle > a = 758 > pickle.dump(a, open('test.pickle', 'w'))