Re: Expression can be simplified on list

2016-09-28 Thread Rustom Mody
On Thursday, September 15, 2016 at 1:43:05 AM UTC+5:30, Terry Reedy wrote: > On 9/14/2016 3:16 AM, Rustom Mody wrote: > > > In THOSE TYPES that element can justifiably serve as a falsey (empty) type > > > > However to extrapolate from here and believe that ALL TYPES can have a > > falsey > > valu

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steven D'Aprano
On Thursday 29 September 2016 16:13, Gregory Ewing wrote: > Philosophical question: Is a function that never > returns actually a function? Mathematically, all functions return, instantly. Or rather, mathematics occurs in an abstract environment where there is no time. Everything happens simult

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Gregory Ewing
Paul Moore wrote: What "allows side effects" in languages like Haskell is the fact that the runtime behaviour of the language is not defined as "calculating the value of the main function" but rather as "making the process that the main functon defines as an abstract monad actually happen". Tha

Re: A regular expression question

2016-09-28 Thread Ben Finney
Cpcp Cp writes: > Look this > > >>> import re > >>> text="asdfnbd]" > >>> m=re.sub("n*?","?",text) > >>> print m > ?a?s?d?f?n?b?d?]? > > I don't understand the 'non-greedy' pattern. Since ‘n*’ matches zero or more ‘n’s, it matches zero adjacent to every actual character. It's non-greedy because

A regular expression question

2016-09-28 Thread Cpcp Cp
Look this >>> import re >>> text="asdfnbd]" >>> m=re.sub("n*?","?",text) >>> print m ?a?s?d?f?n?b?d?]? I don't understand the 'non-greedy' pattern. I think the repl argument should replaces every char in text and outputs "". -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Chris Angelico
On Thu, Sep 29, 2016 at 1:53 PM, Steve D'Aprano wrote: > John Cook suggests that functional programming gets harder and harder to do > right (both for the compiler and for the programmer) as you asymptotically > approach 100% pure, and suggests the heuristic that (say) 85% pure is the > sweet spot

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steve D'Aprano
On Wed, 28 Sep 2016 07:18 pm, Chris Angelico wrote: > On Wed, Sep 28, 2016 at 6:52 PM, Gregory Ewing > wrote: >> Chris Angelico wrote: >>> >>> >>> wrote: >>> * No side effects (new variable bindings may be created, but existing ones cannot be changed; no mutable data structures). >>>

Re: Syncing up iterators with gaps

2016-09-28 Thread Steve D'Aprano
On Thu, 29 Sep 2016 11:38 am, Tim Chase wrote: > This seems to discard the data's origin (data1/data2/data3) which is > how I determine whether to use process_a(), process_b(), or > process_c() in my original example where N iterators were returned, > one for each input iterator. So add another s

Re: Nested for loops and print statements

2016-09-28 Thread Larry Hudson via Python-list
On 09/27/2016 09:20 PM, Steven D'Aprano wrote: On Wednesday 28 September 2016 12:48, Larry Hudson wrote: As they came through in the newsgroup, BOTH run correctly, because both versions had leading spaces only. (I did a careful copy/paste to check this.) Copying and pasting from the news clie

Re: Syncing up iterators with gaps

2016-09-28 Thread Tim Chase
On 2016-09-29 10:20, Steve D'Aprano wrote: > On Thu, 29 Sep 2016 05:10 am, Tim Chase wrote: > > data1 = [ # key, data1 > > (1, "one A"), > > (1, "one B"), > > (2, "two"), > > (5, "five"), > > ] > > So data1 has keys 1, 1, 2, 5. > Likewise data2 has keys 1, 2, 3, 3, 3, 4 and d

Re: How to make a foreign function run as fast as possible in Windows?

2016-09-28 Thread jfong
Paul Moore at 2016/9/28 11:31:50PM wrote: > Taking a step back from the more detailed answers, would I be right to assume > that you want to call this external function multiple times from Python, and > each call could take days to run? Or is it that you have lots of calls to > make and each on

Re: How to make a foreign function run as fast as possible in Windows?

2016-09-28 Thread jfong
eryk sun at 2016/9/28 1:05:32PM wrote: > In Unix, Python's os module may have sched_setaffinity() to set the > CPU affinity for all threads in a given process. > > In Windows, you can use ctypes to call SetProcessAffinityMask, > SetThreadAffinityMask, or SetThreadIdealProcessor (a hint for the > s

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steve D'Aprano
On Thu, 29 Sep 2016 03:46 am, Chris Angelico wrote: > That's exactly how a function works in an imperative language, and > it's exactly what the FP advocates detest: opaque state. So is the > difference between "function" and "monad" in Haskell the same as "pure > function" and "function" in other

Re: Syncing up iterators with gaps

2016-09-28 Thread Steve D'Aprano
On Thu, 29 Sep 2016 05:10 am, Tim Chase wrote: > I've got several iterators sharing a common key in the same order and > would like to iterate over them in parallel, operating on all items > with the same key. I've simplified the data a bit here, but it would > be something like > > data1 = [

Re: how to automate java application in window using python

2016-09-28 Thread Lawrence D’Oliveiro
On Thursday, September 29, 2016 at 11:54:46 AM UTC+13, Emile van Sebille wrote: > Which worked for me! You should try it. Sloppy programming has always > been unreliable. So it is clear you don’t have an answer to the OP’s question after all. Just some vague, meaningless generalities. -- https:

Re: Can this be easily done in Python?

2016-09-28 Thread Mario R. Osorio
I'm not sure I understand your question, but I 'think' you area talking about executing dynamically chunks of code. If that is the case, there are a couple of ways to do it. These are some links that might interest you: http://stackoverflow.com/questions/3974554/python-how-to-generate-the-code-o

Re: how to automate java application in window using python

2016-09-28 Thread Emile van Sebille
On 09/28/2016 02:52 PM, Lawrence D’Oliveiro wrote: On Thursday, September 29, 2016 at 4:57:10 AM UTC+13, Emile van Sebille wrote: My point was that it is possible to automate windows reliably as long as the programming is robust. Sounds like circular reasoning. Which worked for me! You shou

Re: how to automate java application in window using python

2016-09-28 Thread Lawrence D’Oliveiro
On Thursday, September 29, 2016 at 4:57:10 AM UTC+13, Emile van Sebille wrote: > My point was that it is possible to automate windows reliably as long as the > programming is robust. Sounds like circular reasoning. -- https://mail.python.org/mailman/listinfo/python-list

Re: Using the Windows "embedded" distribution of Python

2016-09-28 Thread eryk sun
On Wed, Sep 28, 2016 at 2:35 PM, Paul Moore wrote: > So I thought I'd try SetDllDirectory. That works for python36.dll, but if I > load > python3.dll, it can't find Py_Main - the export shows as "(forwarded to > python36.Py_Main)", maybe the forwarding doesn't handle SetDllDirectory? It works f

Re: Syncing up iterators with gaps

2016-09-28 Thread Peter Otten
Tim Chase wrote: > I've got several iterators sharing a common key in the same order and > would like to iterate over them in parallel, operating on all items > with the same key. I've simplified the data a bit here, but it would > be something like > > data1 = [ # key, data1 > (1, "one A"

Re: Syncing up iterators with gaps

2016-09-28 Thread Chris Kaynor
Here is a slight variation of Chris A's code that does not require more than a single look-ahead per generator. It may be better depending on the exact data passed in. Chris A's version will store all of the items for each output that have a matching key, which, depending on the expected data, cou

Re: Syncing up iterators with gaps

2016-09-28 Thread Chris Angelico
On Thu, Sep 29, 2016 at 5:10 AM, Tim Chase wrote: > And I'd like to do something like > > for common_key, d1, d2, d3 in magic_happens_here(data1, data2, data3): > for row in d1: > process_a(common_key, row) > for thing in d2: > process_b(common_key, row) > for thing in d3

Re: Syncing up iterators with gaps

2016-09-28 Thread Terry Reedy
On 9/28/2016 3:10 PM, Tim Chase wrote: I've got several iterators sharing a common key in the same order and would like to iterate over them in parallel, operating on all items with the same key. I've simplified the data a bit here, but it would be something like data1 = [ # key, data1 (1

Syncing up iterators with gaps

2016-09-28 Thread Tim Chase
I've got several iterators sharing a common key in the same order and would like to iterate over them in parallel, operating on all items with the same key. I've simplified the data a bit here, but it would be something like data1 = [ # key, data1 (1, "one A"), (1, "one B"), (2, "tw

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Chris Angelico
On Thu, Sep 29, 2016 at 2:43 AM, Random832 wrote: > On Wed, Sep 28, 2016, at 11:41, Paul Moore wrote: >> What "allows side effects" in languages like Haskell is the fact that the >> runtime behaviour of the language is not defined as "calculating the >> value of the main function" but rather as "m

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Chris Angelico
On Thu, Sep 29, 2016 at 2:33 AM, Steve D'Aprano wrote: Procedural programming under another name... >>> >>> Only in the sense that procedural programming is unstructured programming >>> under another name. What is a procedure call but a disguised GOSUB, and >>> what is GOSUB but a pair of GOT

Re: How to call this method from main method

2016-09-28 Thread Peter Pearson
On Tue, 27 Sep 2016 23:44:11 -0700 (PDT), prasanthk...@gmail.com wrote: [snip] > > if __name__ == '__main__': > > GenAccessToken("This_is_a_Test_QED_MAC_Key_Which_Needs_to_be_at_Least_32_Bytes_Long", > "default", "default", 6, >"g,m,a,s,c,p,d") > > When i am calling the abov

Re: Can this be easily done in Python?

2016-09-28 Thread Peter Pearson
On Tue, 27 Sep 2016 12:58:40 -0700 (PDT), TUA wrote: > Is the following possible in Python? > > Given how the line below works > > TransactionTerms = 'TransactionTerms' > > > have something like > > TransactionTerms = > > that sets the variable TransactionTerms to its own name as string > represe

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Random832
On Wed, Sep 28, 2016, at 11:41, Paul Moore wrote: > What "allows side effects" in languages like Haskell is the fact that the > runtime behaviour of the language is not defined as "calculating the > value of the main function" but rather as "making the process that the > main functon defines as an

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steve D'Aprano
On Wed, 28 Sep 2016 11:05 pm, Jussi Piitulainen wrote: > Steve D'Aprano writes: > >> On Wed, 28 Sep 2016 08:03 pm, Lawrence D’Oliveiro wrote: >> >>> On Wednesday, September 28, 2016 at 9:53:05 PM UTC+13, Gregory Ewing >>> wrote: Essentially you write the whole program in continuation- p

Re: how to automate java application in window using python

2016-09-28 Thread Emile van Sebille
On 09/23/2016 05:02 PM, Lawrence D’Oliveiro wrote: On Thursday, September 22, 2016 at 8:34:20 AM UTC+12, Emile wrote: Hmm, then I'll have to wait longer to experience the unreliability as the handful of automated gui tools I'm running has only been up 10 to 12 years or so. You sound like you h

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Paul Moore
On Wednesday, 28 September 2016 10:19:01 UTC+1, Chris Angelico wrote: > If monads allow mutations or side effects, they are by definition not > pure functions, and violate your bullet point. Languages like Haskell > have them not because they are an intrinsic part of functional > programming langu

Re: How to make a foreign function run as fast as possible in Windows?

2016-09-28 Thread Paul Moore
On Tuesday, 27 September 2016 02:49:08 UTC+1, jf...@ms4.hinet.net wrote: > This function is in a DLL. It's small but may run for days before complete. I > want it takes 100% core usage. Threading seems not a good idea for it shares > the core with others. Will the multiprocessing module do it? A

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread alister
On Wed, 28 Sep 2016 21:48:20 +1000, Steve D'Aprano wrote: > On Wed, 28 Sep 2016 08:03 pm, Lawrence D’Oliveiro wrote: > >> On Wednesday, September 28, 2016 at 9:53:05 PM UTC+13, Gregory Ewing >> wrote: >>> Essentially you write the whole program in continuation- >>> passing style, with a state obj

Using the Windows "embedded" distribution of Python

2016-09-28 Thread Paul Moore
This is probably more of a Windows question than a Python question, but as it's related to embedding Python, I thought I'd try here anyway. I'm writing some command line applications in Python, and I want to bundle them into a standalone form using the new "embedding" distribution of Python. The

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Jussi Piitulainen
Steve D'Aprano writes: > On Wed, 28 Sep 2016 08:03 pm, Lawrence D’Oliveiro wrote: > >> On Wednesday, September 28, 2016 at 9:53:05 PM UTC+13, Gregory Ewing >> wrote: >>> Essentially you write the whole program in continuation- >>> passing style, with a state object being passed down an >>> infinit

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steve D'Aprano
On Wed, 28 Sep 2016 08:03 pm, Lawrence D’Oliveiro wrote: > On Wednesday, September 28, 2016 at 9:53:05 PM UTC+13, Gregory Ewing > wrote: >> Essentially you write the whole program in continuation- >> passing style, with a state object being passed down an >> infinite chain of function calls. > >

Re: Can this be easily done in Python?

2016-09-28 Thread Matt Wheeler
On Tue, 27 Sep 2016 at 20:58 TUA wrote: > Is the following possible in Python? > > Given how the line below works > > TransactionTerms = 'TransactionTerms' > > > have something like > > TransactionTerms = > > that sets the variable TransactionTerms to its own name as string > representation with

Re: Why searching in a set is much faster than in a list ?

2016-09-28 Thread Steve D'Aprano
On Wed, 28 Sep 2016 07:07 pm, Chris Angelico wrote: > On Wed, Sep 28, 2016 at 6:46 PM, Marko Rauhamaa wrote: >> Lawrence D’Oliveiro : >> >>> On Wednesday, September 28, 2016 at 6:51:17 PM UTC+13, ast wrote: I noticed that searching in a set is faster than searching in a list. >>> >>> That’s

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Chris Angelico
On Wed, Sep 28, 2016 at 9:25 PM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> If you've Py_DECREFed it and then peek into its internals, you're >> aiming a gun at your foot. > > > That's true. A safer way would be to look at the refcount > *before* decreffing and verify that it's what you ex

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Gregory Ewing
Chris Angelico wrote: If you've Py_DECREFed it and then peek into its internals, you're aiming a gun at your foot. That's true. A safer way would be to look at the refcount *before* decreffing and verify that it's what you expect. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Why searching in a set is much faster than in a list ?

2016-09-28 Thread Michiel Overtoom
Hi, Brandon Rhodes gave a talk about dictionaries (similar to sets), 'The Mighty Dictionary': https://www.youtube.com/watch?v=C4Kc8xzcA68 You also might be interested in his talk about Python data structures, 'All Your Ducks In A Row': https://www.youtube.com/watch?v=fYlnfvK

Re: Case insensitive replacement?

2016-09-28 Thread Tim Chase
On 2016-09-27 18:10, MRAB wrote: > The disadvantage of your "string-hacking" is that you're assuming > that the uppercase version of a string is the same length as the > original: Ah, good point. I went with using the regexp version for now since I needed to move forward with something, so I'm gl

Re: Why searching in a set is much faster than in a list ?

2016-09-28 Thread ast
"Steven D'Aprano" a écrit dans le message de news:57eb7dff$0$1598$c3e8da3$54964...@news.astraweb.com... On Wednesday 28 September 2016 15:51, ast wrote: Hello I noticed that searching in a set is faster than searching in a list. [...] I tried a search in a tuple, it's not different that i

Re: Why searching in a set is much faster than in a list ?

2016-09-28 Thread Marko Rauhamaa
Chris Angelico : > On Wed, Sep 28, 2016 at 6:46 PM, Marko Rauhamaa wrote: >> I would have thought the point of sets is to have set semantics, just >> like the point of lists is to have list semantics. > > And set semantics are what, exactly? Membership is a primary one. With sets, you can only c

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steven D'Aprano
On Wednesday 28 September 2016 15:27, Gregory Ewing wrote: > * No side effects (new variable bindings may be created, but >existing ones cannot be changed; no mutable data structures). As I understand it, for some advanced functional languages like Haskell, that is only true as far as the in

Re: How to reduce the DRY violation in this code

2016-09-28 Thread Lorenzo Sutton
On 27/09/2016 17:49, Steve D'Aprano wrote: I have a class that takes a bunch of optional arguments. They're all optional, with default values of various types. For simplicity, let's say some are ints and some are floats: class Spam: def __init__(self, bashful=10.0, doc=20.0, dopey=30.0,

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Lawrence D’Oliveiro
On Wednesday, September 28, 2016 at 9:53:05 PM UTC+13, Gregory Ewing wrote: > Essentially you write the whole program in continuation- > passing style, with a state object being passed down an > infinite chain of function calls. Procedural programming under another name... -- https://mail.python.

Re: How to make a foreign function run as fast as possible in Windows?

2016-09-28 Thread alister
On Tue, 27 Sep 2016 19:13:51 -0700, jfong wrote: > eryk sun at 2016/9/27 11:44:49AM wrote: >> The threads of a process do not share a single core. The OS schedules >> threads to distribute the load across all cores > > hmmm... your answer overthrow all my knowledge about Python threads > comp

Re: what's the difference of Template.append(...) and Template.prepend(...) in pipes module

2016-09-28 Thread Cpcp Cp
https://docs.python.org/2/library/pipes.html -- https://mail.python.org/mailman/listinfo/python-list

Re: How to reduce the DRY violation in this code

2016-09-28 Thread Yann Kaiser
You could use `attrs` for this along with the convert option, if you're open to receiving mixed arguments: >>> @attr.s ... class C(object): ... x = attr.ib(convert=int) >>> o = C("1") >>> o.x 1 https://attrs.readthedocs.io/en/stable/examples.html#conversion On Tue, Sep 27, 2016, 16:51 Steve D'Ap

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Chris Angelico
On Wed, Sep 28, 2016 at 6:56 PM, Gregory Ewing wrote: > dieter wrote: >> >> dl l writes: >> >>> When I debug in C++, I see the reference count of a PyObject is 1. > >>> How can I find out where is referencing this object? >> >> >> Likely, it is the reference, you are holding: > > > Unless you've

Re: How to reduce the DRY violation in this code

2016-09-28 Thread alister
On Wed, 28 Sep 2016 01:49:56 +1000, Steve D'Aprano wrote: > I have a class that takes a bunch of optional arguments. They're all > optional, with default values of various types. For simplicity, let's > say some are ints and some are floats: > > > class Spam: > def __init__(self, bashful=10.

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Chris Angelico
On Wed, Sep 28, 2016 at 6:52 PM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> >> wrote: >> >>> * No side effects (new variable bindings may be created, but >>> existing ones cannot be changed; no mutable data structures). >> >> >> If that's adhered to 100%, the language is useless for any

Re: Why searching in a set is much faster than in a list ?

2016-09-28 Thread Chris Angelico
On Wed, Sep 28, 2016 at 6:46 PM, Marko Rauhamaa wrote: > Lawrence D’Oliveiro : > >> On Wednesday, September 28, 2016 at 6:51:17 PM UTC+13, ast wrote: >>> I noticed that searching in a set is faster than searching in a list. >> >> That’s why we have sets. > > I would have thought the point of sets

Re: Why searching in a set is much faster than in a list ?

2016-09-28 Thread Steven D'Aprano
On Wednesday 28 September 2016 15:51, ast wrote: > Hello > > I noticed that searching in a set is faster than searching in a list. [...] > I tried a search in a tuple, it's not different that in a list. > Any comments ? A list, array or tuple is basically a linear array that needs to be searche

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Gregory Ewing
dieter wrote: dl l writes: When I debug in C++, I see the reference count of a PyObject is 1. >> How can I find out where is referencing this object? Likely, it is the reference, you are holding: Unless you've just Py_DECREFed it, expecting it to go away, and the recfcount is still 1, in

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Gregory Ewing
Chris Angelico wrote: wrote: * No side effects (new variable bindings may be created, but existing ones cannot be changed; no mutable data structures). If that's adhered to 100%, the language is useless for any operation that cannot be handled as a "result at end of calculation" function.

Re: Why searching in a set is much faster than in a list ?

2016-09-28 Thread Marko Rauhamaa
Lawrence D’Oliveiro : > On Wednesday, September 28, 2016 at 6:51:17 PM UTC+13, ast wrote: >> I noticed that searching in a set is faster than searching in a list. > > That’s why we have sets. I would have thought the point of sets is to have set semantics, just like the point of lists is to have

Re: How to call a method returning a value from a main function

2016-09-28 Thread Paul Moore
On Wednesday, 28 September 2016 07:47:38 UTC+1, prasanth kotagiri wrote: > def GenAccessToken(mackey,authid,configid,tokenexp,*perm): > args=JWTParms() > args.configurationId=configid > args.authzSystemMacKey=mackey > args.authzSystemId=authid > args.tokenExpiryInSeconds=tokene

Re: what's the difference of Template.append(...) and Template.prepend(...) in pipes module

2016-09-28 Thread Steven D'Aprano
On Wednesday 28 September 2016 16:47, Cpcp Cp wrote: > Template.append(cmd, kind) and Template.prepend(cmd, kind) > Append a new action at the end.The cmd variable must be a valid bourne shell > command. The kind variable consists of two letters. "Append" means to put at the end. "Prepend" means

Re: Why searching in a set is much faster than in a list ?

2016-09-28 Thread Lawrence D’Oliveiro
On Wednesday, September 28, 2016 at 6:51:17 PM UTC+13, ast wrote: > I noticed that searching in a set is faster than searching in a list. That’s why we have sets. -- https://mail.python.org/mailman/listinfo/python-list

Re: what's the difference of Template.append(...) and Template.prepend(...) in pipes module

2016-09-28 Thread Lawrence D’Oliveiro
On Wednesday, September 28, 2016 at 7:47:46 PM UTC+13, Cpcp Cp wrote: > My os is windows 7.But this module is used for POSIX. Windows 10 has a Linux layer, I believe. Why not try that? -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Peter Otten
Lawrence D’Oliveiro wrote: > On Wednesday, September 28, 2016 at 3:35:58 AM UTC+13, Peter Otten wrote: >> is Python actually a "functional language"? > > Yes [snip] No. To replace the mostly irrelevant link with something addressing my question:

Re: Why searching in a set is much faster than in a list ?

2016-09-28 Thread Christian Gollwitzer
Am 28.09.16 um 07:51 schrieb ast: Hello I noticed that searching in a set is faster than searching in a list. Because a set is a hashtable, which has constant-time lookup, whereas in a list it needs to compare with every element. from timeit import Timer from random import randint l = [i

Re: Why searching in a set is much faster than in a list ?

2016-09-28 Thread dieter
"ast" writes: > ... > I noticed that searching in a set is faster than searching in a list. A "set" is actually similar to a degenerated "dict". It is using hashing to quickly access its content which could give you (amortized asymptotically) contant runtime. With a list, you iterate over its ele

Re: How to call this method from main method

2016-09-28 Thread Ben Finney
prasanthk...@gmail.com writes: > When i am calling the above method from main method You don't have a main method, and you don't specify what “the above method” is. I assume you mean “… calling the ‘GenAccessToken’ function” (which is not a method of anything, in the code you showed). But maybe

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread dieter
Peng Yu writes: > Hi, In many other functional language, one can change the closure of a > function. Is it possible in python? I do not think so: the corresponding attributes/types ("__closure__", "cell") are explicitely designed to be read only. However, I never missed closure changebility. Sho

Re: Python C API: How to debug reference leak?

2016-09-28 Thread dieter
dl l writes: > When I debug in C++, I see the reference count of a PyObject is 1. I don't > know where is referencing this object. How can I find out where is > referencing this object? Likely, it is the reference, you are holding: typically, whenever you can access a Python object, this object

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread ast
"jmp" a écrit dans le message de news:mailman.31.1474987306.2302.python-l...@python.org... On 09/27/2016 04:01 PM, Peng Yu wrote: Note: function are objects, and can have attributes, however I rarely see usage of these, there could be good reasons for that. It could be use to implemen

Re: Python C API: How to debug reference leak?

2016-09-28 Thread dieter
dl l writes: > Thanks for reply. Is there any function in C to get the reference objects > of a object? I want to debug where are referencing the object. Depending on your understanding of "reference objects", this would be "gc.get_referents" or "gc.get_referrers". Of course, those are not "C"

Re: what's the difference of Template.append(...) and Template.prepend(...) in pipes module

2016-09-28 Thread Cpcp Cp
Please give me a simple example.Thanks! -- https://mail.python.org/mailman/listinfo/python-list