Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread dl l
I understood call PyGC_collect to release object cycles. But in my python test code, seems there is NO reference cycle on the Simple object in the python test code. Why needs to call PyGC_Collect() here? = class Simple: def __init__( se

Re: Cython taking more time than regular Python

2016-09-20 Thread Gregory Ewing
Christian Gollwitzer wrote: However, I'm not convinced it did succeed here. An evaluation of the Gauß formula would run in a few *nanoseconds* on any moddern machine. It may take a microsecond to call a functino from Python. a hundred microseconds means that the loop does run. Obviously the c

Re: Data Types

2016-09-20 Thread Steven D'Aprano
On Wednesday 21 September 2016 14:03, Cai Gengyang wrote: > So for example for "bool" , it only applies to True/False and nothing else? Correct. True and False are the only instances of the type 'bool'. > (2 data types), i.e. : > type(True) > type(False) > > > Are there any other d

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread dieter
dl l writes: > I found the problem is resolved if call PyGC_Collect() after > PyDict_DelItemString(). Is it expected to call PyGC_Collect() here for > Python 3.5 which is not needed for Python 3.3? Usually, Python uses reference counting to determine when an object can be deleted (and then reclai

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Random832
On Tue, Sep 20, 2016, at 23:34, Steve D'Aprano wrote: > One of us is badly missing something. The problem is the number of times next is called. Here, it'll be more clear if we wrap the iterator in the original example to print each time next is called. class WrappedIterator(): def __init__(s

Re: Data Types

2016-09-20 Thread Cai Gengyang
On Wednesday, September 21, 2016 at 11:22:42 AM UTC+8, Steve D'Aprano wrote: > On Wed, 21 Sep 2016 01:00 pm, Cai Gengyang wrote: > > > So I am going through chapter 7.1 (Data Types) of > > http://programarcadegames.com/index.php… What do these terms (input and > > output) mean --- Can someone expl

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread dl l
Thank you all for the help. I found the problem is resolved if call PyGC_Collect() after PyDict_DelItemString(). Is it expected to call PyGC_Collect() here for Python 3.5 which is not needed for Python 3.3? 2016-09-20 16:01 GMT+08:00 Chris Angelico : > On Tue, Sep 20, 2016 at 4:19 PM, dl l wrot

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Steve D'Aprano
On Wed, 21 Sep 2016 12:47 pm, Chris Angelico wrote: > On Wed, Sep 21, 2016 at 12:34 PM, Steve D'Aprano > wrote: >> "since values from the leaves of the tree have to be yielded >> multiple times to the top of the tree" >> >> Each leaf is yielded once, and I don't understand what you mean b

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Steve D'Aprano
On Wed, 21 Sep 2016 02:46 am, ROGER GRAYDON CHRISTMAN wrote: > I am trying to find a better (i.e. more efficient) way to implement a > generator that traverses a tree. > > The current model of the code (which is also used by a textbook I am > teaching from does this) > >def __iter__(node): >

Re: Data Types

2016-09-20 Thread Steve D'Aprano
On Wed, 21 Sep 2016 01:00 pm, Cai Gengyang wrote: > So I am going through chapter 7.1 (Data Types) of > http://programarcadegames.com/index.php… What do these terms (input and > output) mean --- Can someone explain in plain English and layman's terms ? http://www.dictionary.com/browse/input http

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Steve D'Aprano
On Wed, 21 Sep 2016 12:44 pm, Random832 wrote: > On Tue, Sep 20, 2016, at 22:34, Steve D'Aprano wrote: >> I'm afraid I don't understand this. This is a standard binary tree >> inorder traversal. Each node is visited once, and there are N nodes, >> so I make that out to be O(N) not O(N log N). I'm

Data Types

2016-09-20 Thread Cai Gengyang
So I am going through chapter 7.1 (Data Types) of http://programarcadegames.com/index.php… What do these terms (input and output) mean --- Can someone explain in plain English and layman's terms ? Thanks a lot ... >>> type(3) >>> type(3.145) >>> type("Hi there") >>> type(True) -- https://ma

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Chris Angelico
On Wed, Sep 21, 2016 at 12:34 PM, Steve D'Aprano wrote: > "since values from the leaves of the tree have to be yielded > multiple times to the top of the tree" > > Each leaf is yielded once, and I don't understand what you mean by yielding > to the top of the tree. Ultimately, yes. But AI

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Random832
On Tue, Sep 20, 2016, at 22:34, Steve D'Aprano wrote: > I'm afraid I don't understand this. This is a standard binary tree > inorder traversal. Each node is visited once, and there are N nodes, > so I make that out to be O(N) not O(N log N). I'm afraid I can't parse > your final clause: > > "si

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Steve D'Aprano
On Wed, 21 Sep 2016 02:46 am, ROGER GRAYDON CHRISTMAN wrote: > I am trying to find a better (i.e. more efficient) way to implement a > generator that traverses a tree. > > The current model of the code (which is also used by a textbook I am > teaching from does this) > >def __iter__(node): >

Re: automated comparison tool

2016-09-20 Thread Lawrence D’Oliveiro
On Wednesday, September 21, 2016 at 12:14:54 PM UTC+12, Bill Deegan wrote: > Use Git... at least you get can back what used to work.. That has become such a matter of programming habit, taken so much for granted that, to me, it’s like saying “don’t forget to breathe”. :) -- https://mail.python.o

Re: Idiomatic code validator?

2016-09-20 Thread Tim Johnson
* Steve D'Aprano [160920 16:29]: > On Wed, 21 Sep 2016 01:41 am, Tim Johnson wrote: > > > Not to confuse idiomatic code validation with pep8 validation (I use > > elpy on emacs) > > > > Is there such a thing as a validator for _idiomatic_ code? > > > Yes, it is called a linter. There are vario

Re: Idiomatic code validator?

2016-09-20 Thread Tim Johnson
* Steve D'Aprano [160920 16:29]: > On Wed, 21 Sep 2016 01:41 am, Tim Johnson wrote: > > > Not to confuse idiomatic code validation with pep8 validation (I use > > elpy on emacs) > > > > Is there such a thing as a validator for _idiomatic_ code? > > > Yes, it is called a linter. There are vario

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread ROGER GRAYDON CHRISTMAN
On Tue, Sep 20, 2016 at 9:46 AM, ROGER GRAYDON CHRISTMAN

Re: automated comparison tool

2016-09-20 Thread Steve D'Aprano
On Wed, 21 Sep 2016 07:20 am, Andrew Clark wrote: > I've restarted my code so many times i no longer have a working version of > anything. *Restarting* your code doesn't change it and cannot possibly stop it from working. My guess is that you actually mean that you've made so many random edits t

Re: list or dictionary

2016-09-20 Thread Steve D'Aprano
On Wed, 21 Sep 2016 04:04 am, Ganesh Pal wrote: > I am on python 2.7 and Linux > > I have the stdout in the below form , I need to write a function to get > hostname for the given id. > > > Example: > stdout > 'hostname-1 is array with id 1\nhostname-2 is array with id 2\nhostname-3 > is

Re: Idiomatic code validator?

2016-09-20 Thread Steve D'Aprano
On Wed, 21 Sep 2016 01:41 am, Tim Johnson wrote: > Not to confuse idiomatic code validation with pep8 validation (I use > elpy on emacs) > > Is there such a thing as a validator for _idiomatic_ code? Yes, it is called a linter. There are various linters available: pylint, pychecker, jedi, flak

Re: automated comparison tool

2016-09-20 Thread Bill Deegan
Use Git... at least you get can back what used to work.. On Tue, Sep 20, 2016 at 2:20 PM, Andrew Clark wrote: > On Tuesday, September 20, 2016 at 3:25:11 PM UTC-5, Lawrence D’Oliveiro > wrote: > > On Wednesday, September 21, 2016 at 7:44:22 AM UTC+12, Andrew Clark > wrote: > > > If anyone can he

Re: how to automate java application in window using python

2016-09-20 Thread Matt Wheeler
On Tue, 20 Sep 2016, 02:47 meInvent bbird, wrote: > can it contorl Maplesoft's maple which is a java executable file? > I don't know maple so I can't answer that. Which programming language an application is written in isn't really relevant for pywinauto, it's the graphical toolkit in use which

Re: get the sum of differences between integers in a list

2016-09-20 Thread John Pote
On 20/09/2016 12:52, Daiyue Weng wrote: Hi, I have a list numbers say, [1,2,3,4,6,8,9,10,11] First, I want to calculate the sum of the differences between the numbers in the list. At least for this first part a little pencil, paper and algebra yields a simple formula of constant and minimal c

Re: How to install Python.h on FreeBSD 10.3-RELEASE?

2016-09-20 Thread The Doctor
In article <201609...@crcomp.net>, Don Kuenz wrote: > >The Doctor wrote: >> In article <201609...@crcomp.net>, Don Kuenz wrote: >>> >>>It turns out that the question isn't "How to install Python.h?" The >>>question is "Why doesn't make find Python.h?" >>> >>>---

Re: pypy on windows much slower than linux/mac when using complex number type?

2016-09-20 Thread Chris Kaynor
On Tue, Sep 20, 2016 at 3:59 PM, Chris Angelico wrote: > On Wed, Sep 21, 2016 at 8:50 AM, Irmen de Jong > wrote: > >> Dunno if it's the cause or not, but you're running a 32-bit PyPy on a > >> 64-bit Windows. I could well imagine that that has some odd > >> significance. > >> > >> ChrisA > > > >

Re: pypy on windows much slower than linux/mac when using complex number type?

2016-09-20 Thread Chris Angelico
On Wed, Sep 21, 2016 at 8:50 AM, Irmen de Jong wrote: >> Dunno if it's the cause or not, but you're running a 32-bit PyPy on a >> 64-bit Windows. I could well imagine that that has some odd >> significance. >> >> ChrisA > > > Perhaps. Though I can't really imagine what's going on there then. The o

Re: pypy on windows much slower than linux/mac when using complex number type?

2016-09-20 Thread Irmen de Jong
On 20-9-2016 22:43, Chris Angelico wrote: > On Wed, Sep 21, 2016 at 6:38 AM, Irmen de Jong wrote: >> Windows: 64 bits Windows 7, Intel Core 2 Quad 3.4 Ghz >> Linux: 32 bits Mint 18, Virtualbox VM on above windows machine >> Mac mini: OS X 10.11.6, Intel Core 2 Duo 2.53 Ghz >> >> The test code I

Re: How to install Python.h on FreeBSD 10.3-RELEASE?

2016-09-20 Thread Don Kuenz
The Doctor wrote: > In article <201609...@crcomp.net>, Don Kuenz wrote: >> >>It turns out that the question isn't "How to install Python.h?" The >>question is "Why doesn't make find Python.h?" >> >> >> >># uname -v >>FreeBS

Re: automated comparison tool

2016-09-20 Thread Andrew Clark
On Tuesday, September 20, 2016 at 3:25:11 PM UTC-5, Lawrence D’Oliveiro wrote: > On Wednesday, September 21, 2016 at 7:44:22 AM UTC+12, Andrew Clark wrote: > > If anyone can help me out with sudo code or set me in the right direction > > would be nice. > > You know What Aesop said: “the gods* help

Re: list or dictionary

2016-09-20 Thread Chris Angelico
On Wed, Sep 21, 2016 at 4:04 AM, Ganesh Pal wrote: > 1. store it in list and grep for id and return > 2. store it in dict as key and value i.e hostname = { 'hostname1': 1} and > return key > 3. any other simple options. 4. Store it in dict, but the other way around. The key should be the thing yo

Re: Another å, ä, ö question

2016-09-20 Thread Chris Angelico
On Wed, Sep 21, 2016 at 6:21 AM, Martin Schöön wrote: > Den 2016-09-19 skrev Lawrence D’Oliveiro : >> On Tuesday, September 20, 2016 at 8:21:25 AM UTC+12, Martin Schöön wrote: >>> But -- now I tested using emacs instead using C-c C-c to execute. >>> Noting happens so I try to run the program from

Re: pypy on windows much slower than linux/mac when using complex number type?

2016-09-20 Thread Chris Angelico
On Wed, Sep 21, 2016 at 6:38 AM, Irmen de Jong wrote: > Windows: 64 bits Windows 7, Intel Core 2 Quad 3.4 Ghz > Linux: 32 bits Mint 18, Virtualbox VM on above windows machine > Mac mini: OS X 10.11.6, Intel Core 2 Duo 2.53 Ghz > > The test code I've been using is here: > https://gist.github.co

pypy on windows much slower than linux/mac when using complex number type?

2016-09-20 Thread Irmen de Jong
Hi, I've stumbled across a peculiar performance issue with Pypy across some different platforms. It was very visible in some calculation heavy code that I wrote that uses Python's complex number type to calculate the well-known Mandelbrot set. Pypy running the code on my Windows machine is doin

Re: Another å, ä, ö question

2016-09-20 Thread Peter Otten
Martin Schöön wrote: > Den 2016-09-19 skrev Christian Gollwitzer : >> Am 19.09.16 um 22:21 schrieb Martin Schöön: >>> I am studying some of these tutorials: >>> https://pythonprogramming.net/matplotlib-intro-tutorial/ >>> >>> I am recreating the code and I use my native Swedish for comments, >>> l

Re: list or dictionary

2016-09-20 Thread Lawrence D’Oliveiro
On Wednesday, September 21, 2016 at 6:05:41 AM UTC+12, Ganesh Pal wrote: > I am on python 2.7 ... Why? -- https://mail.python.org/mailman/listinfo/python-list

Re: automated comparison tool

2016-09-20 Thread Lawrence D’Oliveiro
On Wednesday, September 21, 2016 at 7:44:22 AM UTC+12, Andrew Clark wrote: > If anyone can help me out with sudo code or set me in the right direction > would be nice. You know What Aesop said: “the gods* help those who help themselves”. Start by posting an initial stab at your code for solving,

Re: Another å, ä, ö question

2016-09-20 Thread Martin Schöön
Den 2016-09-19 skrev Lawrence D’Oliveiro : > On Tuesday, September 20, 2016 at 8:21:25 AM UTC+12, Martin Schöön wrote: >> But -- now I tested using emacs instead using C-c C-c to execute. >> Noting happens so I try to run the program from command line and >> find that now Python can't stand my å, ä

Re: Another å, ä, ö question

2016-09-20 Thread Martin Schöön
Den 2016-09-19 skrev Christian Gollwitzer : > Am 19.09.16 um 22:21 schrieb Martin Schöön: >> I am studying some of these tutorials: >> https://pythonprogramming.net/matplotlib-intro-tutorial/ >> >> I am recreating the code and I use my native Swedish for comments, >> labels and titles. Until now I

Re: I am newbie who can explain this code to me?

2016-09-20 Thread Peter Otten
Nobody wrote: > On Tue, 20 Sep 2016 15:12:39 +0200, Peter Otten wrote: > >> because they don't build lists only to throw them away. > > The lists could have been avoided by using iterators, e.g. > > import itertools as it > keys = xrange(256) > vals = it.imap(chr, keys) > max(it.imap(operator.s

Re: how to automate java application in window using python

2016-09-20 Thread Lawrence D’Oliveiro
On Sunday, September 18, 2016 at 10:42:16 PM UTC+12, Paul Rubin wrote: > > Lawrence D’Oliveiro writes: >> > I'm quite sure there are Java bindings for all those protocols. Are any of these supported by the Java app in question? Doesn’t seem like it. >> Like I said, trying to automate a GUI is a

Re: how to automate java application in window using python

2016-09-20 Thread Lawrence D’Oliveiro
On Tuesday, September 20, 2016 at 1:11:20 PM UTC+12, Ned Batchelder wrote: > We get it, you don't like GUIs. Who says I don’t like GUIs ? I just assume we’ve moved on from the 1990s, when they were considered to be the pinnacl

Re: Idiomatic code validator?

2016-09-20 Thread Tim Johnson
* Terry Reedy [160920 11:48]: > On 9/20/2016 11:41 AM, Tim Johnson wrote: > > Not to confuse idiomatic code validation with pep8 validation > > Strictly speaking, there cannot be a mechanical PEP 8 validator, as any > mechanical checker violates the admonitions of the beginning sections > 'Introd

automated comparison tool

2016-09-20 Thread Andrew Clark
I'm trying to develop a tool in python that will allow me to compare two file. I know this sounds like it's been done before but there is a catch. Files are stored on a remote server. There are three separate directories. StartupConfig, RunningConfig, and ArchiveConfig I need to have the python

Re: Idiomatic code validator?

2016-09-20 Thread Terry Reedy
On 9/20/2016 11:41 AM, Tim Johnson wrote: Not to confuse idiomatic code validation with pep8 validation Strictly speaking, there cannot be a mechanical PEP 8 validator, as any mechanical checker violates the admonitions of the beginning sections 'Introductions' and 'A Foolish Consistency is t

Re: I am newbie who can explain this code to me?

2016-09-20 Thread Nobody
On Tue, 20 Sep 2016 15:12:39 +0200, Peter Otten wrote: > because they don't build lists only to throw them away. The lists could have been avoided by using iterators, e.g. import itertools as it keys = xrange(256) vals = it.imap(chr, keys) max(it.imap(operator.setitem, it.repeat(d), keys, vals))

Re: I am newbie who can explain this code to me?

2016-09-20 Thread Terry Reedy
On 9/20/2016 9:12 AM, Peter Otten wrote: 在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道: On 20/09/2016 13:12, 38016226...@gmail.com wrote: d = {} keys = range(256) vals = map(chr, keys) map(operator.setitem, [d]*len(keys), keys, vals) It is from python library. What does [d]*len(keys) mean? d is the

list or dictionary

2016-09-20 Thread Ganesh Pal
I am on python 2.7 and Linux I have the stdout in the below form , I need to write a function to get hostname for the given id. Example: >>> stdout 'hostname-1 is array with id 1\nhostname-2 is array with id 2\nhostname-3 is array with id 3\n' def get_hostname(id) return id what's a

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Peter Otten
ROGER GRAYDON CHRISTMAN wrote: > I am trying to find a better (i.e. more efficient) way to implement a > generator that traverses a tree. > > The current model of the code (which is also used by a textbook I am > teaching from does this) > >def __iter__(node): > for x in iter(node._

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread justin walters
On Tue, Sep 20, 2016 at 9:46 AM, ROGER GRAYDON CHRISTMAN wrote: > I am trying to find a better (i.e. more efficient) way to implement a > generator > that traverses a tree. > > The current model of the code (which is also used by a textbook I am > teaching > from does this) > >def __iter__(no

Re: get the sum of differences between integers in a list

2016-09-20 Thread mm0fmf
On 20/09/2016 12:52, Daiyue Weng wrote: What's the best way to implement this? With a python script. Show your work and people will help you. -- https://mail.python.org/mailman/listinfo/python-list

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Rob Gaddi
ROGER GRAYDON CHRISTMAN wrote: > I am trying to find a better (i.e. more efficient) way to implement a > generator > that traverses a tree. > > The current model of the code (which is also used by a textbook I am teaching > from does this) > >def __iter__(node): > for x in iter(node.

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Chris Angelico
On Wed, Sep 21, 2016 at 2:46 AM, ROGER GRAYDON CHRISTMAN wrote: > The current model of the code (which is also used by a textbook I am teaching > from does this) > >def __iter__(node): > for x in iter(node._left): > yield x > yield node._value > for x i

Linear Time Tree Traversal Generator

2016-09-20 Thread ROGER GRAYDON CHRISTMAN
I am trying to find a better (i.e. more efficient) way to implement a generator that traverses a tree. The current model of the code (which is also used by a textbook I am teaching from does this) def __iter__(node): for x in iter(node._left): yield x yield node

Re: get the sum of differences between integers in a list

2016-09-20 Thread Peter Otten
Daiyue Weng wrote: > Hi, I have a list numbers say, > > [1,2,3,4,6,8,9,10,11] > > First, I want to calculate the sum of the differences between the numbers > in the list. > Second, if a sequence of numbers having a difference of 1, put them in a > list, i.e. there are two such lists, > > [1,2,3

Idiomatic code validator?

2016-09-20 Thread Tim Johnson
Not to confuse idiomatic code validation with pep8 validation (I use elpy on emacs) Is there such a thing as a validator for _idiomatic_ code? I have Knupp's "Writing Idiomatic Python" and have bookmarked some advisory websites that illustrate idiomatic style. thanks -- Tim http://www.akwebsof

Re: How to install Python.h on FreeBSD 10.3-RELEASE?

2016-09-20 Thread The Doctor
In article <201609...@crcomp.net>, Don Kuenz wrote: > >It turns out that the question isn't "How to install Python.h?" The >question is "Why doesn't make find Python.h?" > > > ># uname -v >FreeBSD 10.0-RELEASE #0 r260789: Thu

Re: get the sum of differences between integers in a list

2016-09-20 Thread Steve D'Aprano
On Tue, 20 Sep 2016 09:52 pm, Daiyue Weng wrote: > Hi, I have a list numbers say, > > [1,2,3,4,6,8,9,10,11] > > First, I want to calculate the sum of the differences between the numbers > in the list. Sounds like homework. What have you tried? Hint: use the sum() function to sum a list of num

Re: How to install Python.h on FreeBSD 10.3-RELEASE?

2016-09-20 Thread Don Kuenz
It turns out that the question isn't "How to install Python.h?" The question is "Why doesn't make find Python.h?" # uname -v FreeBSD 10.0-RELEASE #0 r260789: Thu Jan 16 22:34:59 UTC 2014 # cd / # find . -name 'Python.h' /u

Re: What does this zip() code mean?

2016-09-20 Thread 380162267qq
在 2016年9月20日星期二 UTC-4上午9:35:50,Random832写道: > On Tue, Sep 20, 2016, at 09:19, 38016226...@gmail.com wrote: > > >>> x = [1, 2, 3] > > >>> y = [4, 5, 6] > > >>> zipped = zip(x, y) > > >>> list(zipped) > > [(1, 4), (2, 5), (3, 6)] > > >>> x2, y2 = zip(*zip(x, y)) > > >>> x == list(x2) and y == list(y2

Re: What does this zip() code mean?

2016-09-20 Thread Random832
On Tue, Sep 20, 2016, at 09:19, 38016226...@gmail.com wrote: > >>> x = [1, 2, 3] > >>> y = [4, 5, 6] > >>> zipped = zip(x, y) > >>> list(zipped) > [(1, 4), (2, 5), (3, 6)] > >>> x2, y2 = zip(*zip(x, y)) > >>> x == list(x2) and y == list(y2) > True > > My problem is >>> x2, y2 = zip(*zip(x, y)). >

Re: I am newbie who can explain this code to me?

2016-09-20 Thread 380162267qq
在 2016年9月20日星期二 UTC-4上午9:13:35,Peter Otten写道: > 38016226...@gmail.com wrote: > > > 在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道: > >> On 20/09/2016 13:12, 38016226...@gmail.com wrote: > >> d = {} > >> keys = range(256) > >> vals = map(chr, keys) > >> map(operator.setitem, [d]*len(key

What does this zip() code mean?

2016-09-20 Thread 380162267qq
>>> x = [1, 2, 3] >>> y = [4, 5, 6] >>> zipped = zip(x, y) >>> list(zipped) [(1, 4), (2, 5), (3, 6)] >>> x2, y2 = zip(*zip(x, y)) >>> x == list(x2) and y == list(y2) True My problem is >>> x2, y2 = zip(*zip(x, y)). zip return an iterator but x2 and y2 are different? I really need detail explanatio

Re: I am newbie who can explain this code to me?

2016-09-20 Thread Peter Otten
38016226...@gmail.com wrote: > 在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道: >> On 20/09/2016 13:12, 38016226...@gmail.com wrote: >> d = {} >> keys = range(256) >> vals = map(chr, keys) >> map(operator.setitem, [d]*len(keys), keys, vals) >> > >> > It is from python library. What does

Re: I am newbie who can explain this code to me?

2016-09-20 Thread 380162267qq
在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道: > On 20/09/2016 13:12, 38016226...@gmail.com wrote: > d = {} > keys = range(256) > vals = map(chr, keys) > map(operator.setitem, [d]*len(keys), keys, vals) > > > > It is from python library. What does [d]*len(keys) mean? > > d is the name

Re: I am newbie who can explain this code to me?

2016-09-20 Thread BartC
On 20/09/2016 13:12, 38016226...@gmail.com wrote: d = {} keys = range(256) vals = map(chr, keys) map(operator.setitem, [d]*len(keys), keys, vals) It is from python library. What does [d]*len(keys) mean? d is the name of dict but put d in [] really confused me. if len(keys) is 5 then [d]*5 is

I am newbie who can explain this code to me?

2016-09-20 Thread 380162267qq
>>> d = {} >>> keys = range(256) >>> vals = map(chr, keys) >>> map(operator.setitem, [d]*len(keys), keys, vals) It is from python library. What does [d]*len(keys) mean? d is the name of dict but put d in [] really confused me. -- https://mail.python.org/mailman/listinfo/python-list

get the sum of differences between integers in a list

2016-09-20 Thread Daiyue Weng
Hi, I have a list numbers say, [1,2,3,4,6,8,9,10,11] First, I want to calculate the sum of the differences between the numbers in the list. Second, if a sequence of numbers having a difference of 1, put them in a list, i.e. there are two such lists, [1,2,3] [8,9,10,11] and also put the rest nu

Re: Cython taking more time than regular Python

2016-09-20 Thread Peter Otten
Christian Gollwitzer wrote: > Am 20.09.16 um 09:44 schrieb Peter Otten: >> Stefan Behnel wrote: >> >>> Peter Otten schrieb am 19.09.2016 um 14:55: In [7]: %%cython def omega(int n): cdef long i cdef long result = 0 for i in range(n): result += i return

Re: Cython taking more time than regular Python

2016-09-20 Thread Christian Gollwitzer
Am 20.09.16 um 09:44 schrieb Peter Otten: Stefan Behnel wrote: Peter Otten schrieb am 19.09.2016 um 14:55: In [7]: %%cython def omega(int n): cdef long i cdef long result = 0 for i in range(n): result += i return result ...: In [8]: %timeit omega(10) 1 loops, best o

Re: Cython taking more time than regular Python

2016-09-20 Thread BartC
On 20/09/2016 06:27, Stefan Behnel wrote: Peter Otten schrieb am 19.09.2016 um 14:55: In [7]: %%cython def omega(int n): cdef long i cdef long result = 0 for i in range(n): result += i return result ...: In [8]: %timeit omega(10) 1 loops, best of 3: 91.6 µs per loop

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread Chris Angelico
On Tue, Sep 20, 2016 at 4:19 PM, dl l wrote: > Yes, it's a workaround to set the global variables to None. But My app just > provide a framework for my customers to run python scripts. That's means > the workaround requires my customers to update their python scripts. That > may make them unhappy

Re: Cython taking more time than regular Python

2016-09-20 Thread Peter Otten
Stefan Behnel wrote: > Peter Otten schrieb am 19.09.2016 um 14:55: >> In [7]: %%cython >> def omega(int n): >> cdef long i >> cdef long result = 0 >> for i in range(n): result += i >> return result >>...: >> >> In [8]: %timeit omega(10) >> 1 loops, best of 3: 91.6 µs p

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread Steven D'Aprano
On Tuesday 20 September 2016 16:19, dl l wrote: > Hi Steven, > > Thanks for reply. > > I logged bug https://bugs.python.org/issue28202. I added more info in this > bug :). > > Yes, it's a workaround to set the global variables to None. But My app just > provide a framework for my customers to r

Re: Another å, ä, ö question

2016-09-20 Thread Steven D'Aprano
On Tuesday 20 September 2016 06:21, Martin Schöön wrote: > I am puzzled: With Geany there is no problem but outside Geany > I am punished by Python for using Swedish. > > Any ideas? Yes, you are being punished for what Sweden did to Julian Assange. No, only kidding. We can't really help you if