Function to show time to execute another function

2015-06-06 Thread Cecil Westerhof
Sometimes I just want to know how much time a function takes, but at the same time I also want the result of the function. For this I wrote the following function: def time_test(function, *args): startTime = time.time() results = function(*args) endTime = time.

Testing random

2015-06-06 Thread Cecil Westerhof
I wrote a very simple function to test random: def test_random(length, multiplier = 1): number_list = length * [0] for i in range(length * multiplier): number_list[random.randint(0, length - 1)] += 1 minimum = min(number_list) maximum = max(number

Re: Find in ipython3

2015-06-06 Thread Cecil Westerhof
On Saturday 6 Jun 2015 13:07 CEST, Laura Creighton wrote: > The !find version is C code optimised to do one thing, find files in > your directory structure, which happens to be what you want to do. > General regular expression matching is harder. > > Carl Friedrich Bolz investigated regular expre

Re: Using "import math".

2015-06-06 Thread Chris Warrick
On 7 Jun 2015 00:06, "Steve Burrus" wrote: > > I need some help/assistance with using the python "import math" function. Like I am trying to do a = math.sqrt(1000) > a.sqrt > but it fails. what am I doing wrong? Thanx for anyone's help. > > > -- > https://mail.python.org/mailman/

Re: Embedded Python and C Callback functions

2015-06-06 Thread dieter
doc.mefi...@gmail.com writes: > Hi. I'm a newbie in python. But I want embed it in my C program. > > There is such method of my class: > @staticmethod > def install_instr_callback(callback): > # set hook for every change of PC > m68k.set_instr_hook_callback(callback) > > And in my C code t

Re: Can Python function return multiple data?

2015-06-06 Thread Steven D'Aprano
On Sat, 6 Jun 2015 03:32 pm, Rustom Mody wrote: > On Saturday, June 6, 2015 at 10:20:49 AM UTC+5:30, Steven D'Aprano wrote: >> On Sat, 6 Jun 2015 01:20 pm, Rustom Mody wrote: >> > As a parallel here is Dijkstra making fun of AI-ers use of the word >> > 'intelligent' >> > http://www.cs.utexas.edu/

Re: Can Python function return multiple data?

2015-06-06 Thread Steven D'Aprano
On Sat, 6 Jun 2015 03:28 pm, Rustom Mody wrote: > There was a list: [1,2,3] > At some point that list is found to be(come) [1,2,3,4] > They dont look same to me. When you pour water into an empty bottle, does it turn into a different bottle? When you append items to a list (or remove them), it i

Re: Can Python function return multiple data?

2015-06-06 Thread Amir Arsalan
Tnx Steven, You are right completly.I try more subtilize thanks for your hint. On Sun, Jun 7, 2015 at 10:03 AM, Steven D'Aprano wrote: > Hi Amir, and welcome! > > On Sun, 7 Jun 2015 02:38 am, Amir Arsalan wrote: > > > you can use yield structure in python for multiple return. ex: > > > > def f

Re: Can Python function return multiple data?

2015-06-06 Thread Steven D'Aprano
On Sun, 7 Jun 2015 03:57 am, fl wrote: > Excuse me. I input the following according to your idea, but I do not > understand how to use it from the echo. It does not show how to use > the multiple output results. I am a new Python user. Please give a little > more explanation if you could. > > >

Re: Can Python function return multiple data?

2015-06-06 Thread Steven D'Aprano
Hi Amir, and welcome! On Sun, 7 Jun 2015 02:38 am, Amir Arsalan wrote: > you can use yield structure in python for multiple return. ex: > > def func(a): > yield a*2 > print "a*2" > yield a*3 > print "a*3" > ... > > data = func(5) --> data = (10,15,... ) That's actually wron

Re: Can Python function return multiple data?

2015-06-06 Thread Rustom Mody
On Saturday, June 6, 2015 at 11:27:29 PM UTC+5:30, fl wrote: > On Saturday, June 6, 2015 at 9:39:19 AM UTC-7, Amir Arsalan wrote: > > you can use yield structure in python for multiple return. ex: > > > > > > def func(a): > >     yield a*2 > >     print "a*2" > >     yield a*3 > >     print "a*3"

Re: Keypress Input

2015-06-06 Thread Michael Torrie
On 06/06/2015 12:28 PM, John McKenzie wrote: > > Laura and Gary, thank you for your replies. I have three physical > buttons connected to a Kade device emulating a keyboard. These buttons > control an LED light strip. So there is no screen, so a GUI did not cross > my mind. I thought it made s

Re: Find in ipython3

2015-06-06 Thread Laura Creighton
In a message of Sat, 06 Jun 2015 15:42:27 -0700, Albert-Jan Roskam via Python-l ist writes: >"To run any command at the system shell, simply prefix it with !" >See: https://ipython.org/ipython-doc/dev/interactive/tutorial.html Please don't top post. 2. He knows this. He's doing this for fun and

Re: Find in ipython3

2015-06-06 Thread Albert-Jan Roskam via Python-list
"To run any command at the system shell, simply prefix it with !" See: https://ipython.org/ipython-doc/dev/interactive/tutorial.html-- https://mail.python.org/mailman/listinfo/python-list

Re: Using "import math".

2015-06-06 Thread Cameron Simpson
On 06Jun2015 15:03, Steve Burrus wrote: I need some help/assistance with using the python "import math" function. Like I am trying to do a = math.sqrt(1000) a.sqrt but it fails. what am I doing wrong? Thanx for anyone's help. Please post a tiny but complete example piece of c

Re: Using "import math".

2015-06-06 Thread MRAB
On 2015-06-06 23:03, Steve Burrus wrote: I need some help/assistance with using the python "import math" function. Like I am trying to do a = math.sqrt(1000) a.sqrt but it fails. what am I doing wrong? Thanx for anyone's help. In what way does it fail? If it printed an erro

Using "import math".

2015-06-06 Thread Steve Burrus
I need some help/assistance with using the python "import math" function. Like I am trying to do a = math.sqrt(1000) a.sqrt but it fails. what am I doing wrong? Thanx for anyone's help. -- https://mail.python.org/mailman/listinfo/python-list

Re: Can Python function return multiple data?

2015-06-06 Thread Amir Arsalan
yield structure can able to you that return list of return by nest in function. for example you want send a value as enter value to function and wanna after some calculate send value as return data. 2 way for this : a) send data as a list b) send data with yield example: a) def func(a):

Re: Keypress Input

2015-06-06 Thread Chris Angelico
On Sun, Jun 7, 2015 at 4:28 AM, John McKenzie wrote: > It turns out Tkinter is installed on Raspian and my Pi has it. Typing > import tkinter into the Python interpreter gave me an error, then I > corrected my spelling. The T should be upper case. No errors with "import > Tkinter". Ah, that mean

Re: Keypress Input

2015-06-06 Thread Laura Creighton
In a message of Sat, 06 Jun 2015 18:28:29 +, John McKenzie writes: > > > Laura and Gary, thank you for your replies. I have three physical >buttons connected to a Kade device emulating a keyboard. These buttons >control an LED light strip. So there is no screen, so a GUI did not cross >my mi

Re: [RELEASED] Python 3.5.0b2 is now available

2015-06-06 Thread Terry Reedy
On 6/6/2015 5:24 AM, Joonas Liik wrote: Perhaps its just me, but it seems to me that this release is mighty picky about annotations. More specifically everything is fine in the interactive interpreter but the same code won't fly when run as a file. example: def some_function(my_arg:"my random a

Re: Keypress Input

2015-06-06 Thread John McKenzie
Laura and Gary, thank you for your replies. I have three physical buttons connected to a Kade device emulating a keyboard. These buttons control an LED light strip. So there is no screen, so a GUI did not cross my mind. I thought it made sense as it is easily done by other scripting languages

Embedded Python and C Callback functions

2015-06-06 Thread doc . mefisto
Hi. I'm a newbie in python. But I want embed it in my C program. There is such method of my class: @staticmethod def install_instr_callback(callback): # set hook for every change of PC m68k.set_instr_hook_callback(callback) And in my C code there is such callback function: static PyObject

Re: Can Python function return multiple data?

2015-06-06 Thread fl
On Saturday, June 6, 2015 at 9:39:19 AM UTC-7, Amir Arsalan wrote: > you can use yield structure in python for multiple return. ex: > > > def func(a): >     yield a*2 >     print "a*2" >     yield a*3 >     print "a*3" >     ... > > > data = func(5) --> data = (10,15,... ) > > > On Wed, Jun 3

Re: Can Python function return multiple data?

2015-06-06 Thread Amir Arsalan
you can use yield structure in python for multiple return. ex: def func(a): yield a*2 print "a*2" yield a*3 print "a*3" ... data = func(5) --> data = (10,15,... ) On Wed, Jun 3, 2015 at 1:57 AM, fl wrote: > Hi, > > I just see the tutorial says Python can return value in fun

EuroPython 2015: Please configure your tickets

2015-06-06 Thread M.-A. Lemburg
The EuroPython website supports buying tickets for other people (friends, colleagues, etc.). As a result, it is necessary to “assign” the tickets you buy to either yourself or someone else. The assignment process is explained below. Please tell us your preferences ---

Re: Python.exe has stopped working

2015-06-06 Thread Laura Creighton
In a message of Fri, 05 Jun 2015 11:15:31 +0200, Christian Gollwitzer writes: >Am 05.06.15 um 11:03 schrieb Alexis Dubois: >> Anyone else for an idea on that? >> >Well, it is a crash on exit. Looks like a memory error inside of PyQT. >If you've got the time, you could run it inside of a debugger,

Re: Find in ipython3

2015-06-06 Thread Laura Creighton
The !find version is C code optimised to do one thing, find files in your directory structure, which happens to be what you want to do. General regular expression matching is harder. Carl Friedrich Bolz investigated regular expression algorithms and their implementation to see if this is the sort

Re: Find in ipython3

2015-06-06 Thread Cecil Westerhof
On Friday 5 Jun 2015 01:04 CEST, Cameron Simpson wrote: > On 04Jun2015 13:09, Michael Torrie wrote: >> Why not use Python for what it's good for and say pipe the results >> of find into your python script? Reinventing find poorly isn't >> going to buy you anything. > > And several others made si

Re: Find in ipython3

2015-06-06 Thread Cecil Westerhof
On Friday 5 Jun 2015 09:17 CEST, Cecil Westerhof wrote: > I was already thinking along those lines. I made it: > def find(directory, to_match): > to_match = to_match.lower() > results = [] > for dirpath, dirnames, filenames in os.walk(expanduser(directory)): > for filename in filenames: > if(fnma

Re: [RELEASED] Python 3.5.0b2 is now available

2015-06-06 Thread Steven D'Aprano
On Sat, 6 Jun 2015 07:24 pm, Joonas Liik wrote: > Perhaps its just me, but it seems to me that this release is mighty picky > about annotations. > > More specifically everything is fine in the interactive interpreter but > the same code won't fly when run as a file. > > example: > def some_funct

Re: [RELEASED] Python 3.5.0b2 is now available

2015-06-06 Thread Joonas Liik
Perhaps its just me, but it seems to me that this release is mighty picky about annotations. More specifically everything is fine in the interactive interpreter but the same code won't fly when run as a file. example: def some_function(my_arg:"my random annotation")->"my random return type annota