Re: Idea for key parameter in all() builting, would it be feasible?

2013-06-20 Thread Chris Angelico
On Fri, Jun 21, 2013 at 12:49 AM, Russel Walker wrote: > On Thursday, June 20, 2013 12:45:27 PM UTC+2, Antoon Pardon wrote: >> Op 19-06-13 18:14, russ.po...@gmail.com schreef: >> >> > >> >> all(map(lambda x: bool(x), xrange(10**9))) >> >> Since you already have your answer, I just like to get

Re: Idea for key parameter in all() builting, would it be feasible?

2013-06-20 Thread Russel Walker
On Thursday, June 20, 2013 12:45:27 PM UTC+2, Antoon Pardon wrote: > Op 19-06-13 18:14, russ.po...@gmail.com schreef: > > > > > all(map(lambda x: bool(x), xrange(10**9))) > > > > Since you already have your answer, I just like to get your attention > > to the fact the the lambda is super

Re: Idea for key parameter in all() builting, would it be feasible?

2013-06-20 Thread Antoon Pardon
Op 19-06-13 18:14, russ.po...@gmail.com schreef: > all(map(lambda x: bool(x), xrange(10**9))) Since you already have your answer, I just like to get your attention to the fact the the lambda is superfluous here. Your expression above is equivallent to all(map(bool, xrange(10**9))) -- ht

Re: Idea for key parameter in all() builting, would it be feasible?

2013-06-20 Thread Russel Walker
> If you're getting this via the mailing list, just hit Reply, and then > > change the To: address to python-list@python.org - that's the simplest > > (assuming you don't have a Reply To List feature, but you wouldn't be > > saying the above if you had one). That way, you get a citation line, >

Re: Idea for key parameter in all() builting, would it be feasible?

2013-06-19 Thread russ . pobox
>All you need is the iterator version of map(). In Python 3, that's the >normal map(); in Python 2, use this: from itertools import imap all(imap(lambda x: bool(x), xrange(10**9))) >False >It's roughly instant, like you would expect. >ChrisA This probably isn't the way to post a reply

Re: Idea for key parameter in all() builting, would it be feasible?

2013-06-19 Thread Chris Angelico
On Thu, Jun 20, 2013 at 2:32 AM, wrote: >>All you need is the iterator version of map(). In Python 3, that's the >>normal map(); in Python 2, use this: > > from itertools import imap > all(imap(lambda x: bool(x), xrange(10**9))) >>False > >>It's roughly instant, like you would expect. > >

Re: Idea for key parameter in all() builting, would it be feasible?

2013-06-19 Thread Chris Angelico
On Thu, Jun 20, 2013 at 2:14 AM, wrote: > And the following, although the same thing really as all(xrange(10**9)), is > not as instant and will take even longer than the above. > all(map(lambda x: bool(x), xrange(10**9))) > > However if all by some chance (I don't know how this stuff works

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
> You code fail, see below for other comment > > Traceback (most recent call last): >   File "Download/pastie-2379978.rb", line 108, in >     make_template(template1) >   File "Download/pastie-2379978.rb", line 60, in make_template >     ast.fix_missing_locations(astFromSrc) >   File "/usr/lib/pyt

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
On Aug 17, 5:23 am, Irmen de Jong wrote: > On 16-08-11 13:33, Paul Wray wrote: > > > > > > > > > > > The idea: > > Python syntax allows a statement to be a bare literal or identifier. > > These have no effect on the program. > > > So the function below is legal python: > > > def myFunc(): > > 'a'

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Tim Roberts
"Paul Wray" wrote: > >Ive had what I think is a great idea for pure-python templates (I can almost >hear the groans, bear with me...) >... >The idea: >Python syntax allows a statement to be a bare literal or identifier. These >have no effect on the program. >... >So is this (within the appropria

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Chris Angelico
On Wed, Aug 17, 2011 at 12:57 AM, Paul Wray wrote: > Thanks yes ama aware of docstrings but did not consider. > They are easy to strip out though. > Maybe. You'd have to take notice of what's a docstring and what's the first element to be outputted. Or alternatively, just forbid docstrings on tho

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
On Aug 17, 2:14 am, Chris Angelico wrote: > On Tue, Aug 16, 2011 at 12:33 PM, Paul Wray wrote: > > The idea is simply to use python ASTs to transform this code so that it > > accumulates the values of the bare expressions. > > That'd be similar to what the interactive loop does. Are you aware, >

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Irmen de Jong
On 16-08-11 13:33, Paul Wray wrote: The idea: Python syntax allows a statement to be a bare literal or identifier. These have no effect on the program. So the function below is legal python: def myFunc(): 'a' x = 45 'b'; 'c'; x So is this (within the appropriate class context of course): def

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Chris Angelico
On Tue, Aug 16, 2011 at 12:33 PM, Paul Wray wrote: > The idea is simply to use python ASTs to transform this code so that it > accumulates the values of the bare expressions. That'd be similar to what the interactive loop does. Are you aware, though, that docstrings are bare expressions? You may

Re: Idea for pure-python templates using AST.

2011-08-16 Thread anand jeyahar
Hi all, I did it. Finally managed to port mysqltuner.pl to python. Was a real pain in the butt doing it from bottom up manually, without ever really learing perl syntax. But i finally got it done. Now i need help testing it. find it here. g...@github.com:anandjeyahar/mysqlDbAdmin-python.git. A

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Terry Reedy
On 8/16/2011 7:33 AM, Paul Wray wrote: Hello all Ive had what I think is a great idea for pure-python templates (I can almost hear the groans, bear with me...) For the impatient, proof of concept is at http://pastie.org/2379978 demonstrating simple substitution, balanced tags using context mana

Re: Idea for pure-python templates using AST.

2011-08-16 Thread aspineux
On Aug 16, 1:33 pm, "Paul Wray" wrote: > Hello all > > Ive had what I think is a great idea for pure-python templates (I can almost > hear the groans, bear with me...) > > For the impatient, proof of concept is athttp://pastie.org/2379978 > demonstrating simple substitution, balanced tags using co

Re: Idea for removing the GIL...

2011-02-28 Thread Stefan Behnel
Aahz, 01.03.2011 03:02: Carl Banks wrote: The real reason they never replaced the GIL is that fine-grained locking is expensive with reference counting. The only way the cost of finer-grained locking would be acceptable, then, is if they got rid of the reference counting altogether, and that w

Re: Idea for removing the GIL...

2011-02-28 Thread Aahz
In article , Carl Banks wrote: > >The real reason they never replaced the GIL is that fine-grained >locking is expensive with reference counting. The only way the cost >of finer-grained locking would be acceptable, then, is if they got rid >of the reference counting altogether, and that was cons

Re: Idea for removing the GIL...

2011-02-08 Thread Jean-Paul Calderone
On Feb 8, 7:12 pm, Paul Rubin wrote: > But the refcount scheme is just an implementation hack > that gets rationalized way too much.  I hope PyPy abandons it. Done. :) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Idea for removing the GIL...

2011-02-08 Thread Paul Rubin
sturlamolden writes: > comes with a cost. The interpreter will sometimes pause to collect > garbage. The memory use will be larger as well, as garbage remain > uncollected for a while and is not immediately reclaimed. Many rely on > CPython because the interpreter does not pause and a Python proce

Re: Idea for removing the GIL...

2011-02-08 Thread sturlamolden
On 8 Feb, 10:39, Vishal wrote: > Is it possible that the Python process, creates copies of the > interpreter for each thread that is launched, and some how the thread > is bound to its own interpreter ? In .NET lingo this is called an 'AppDomain'. This is also how tcl works -- one interpreter p

Re: Idea for removing the GIL...

2011-02-08 Thread Carl Banks
On Feb 8, 11:49 am, John Nagle wrote: >     The real reason for the GIL, though, is to support dynamic > code modification in multi-thread progrems.  It's the ability > to replace a function while it's being executed in another thread > that's hard to do without a global lock.  If it were just a d

Re: Idea for removing the GIL...

2011-02-08 Thread John Nagle
On 2/8/2011 1:39 AM, Vishal wrote: Hello, This might sound crazy..and dont know if its even possible, but... Is it possible that the Python process, creates copies of the interpreter for each thread that is launched, and some how the thread is bound to its own interpreter ? This will increase

Re: Idea for removing the GIL...

2011-02-08 Thread Adam Tauno Williams
On Tue, 2011-02-08 at 11:52 -0500, Roy Smith wrote: > In article , > Robert Kern wrote: > > Unlike a UNIX fork, CreateProcess() does not have the same copy-on-write > > semantics for initializing the memory of the new process. If you want to > > pass > > data to the children, the data must be

Re: Idea for removing the GIL...

2011-02-08 Thread Stefan Behnel
Roy Smith, 08.02.2011 17:52: Robert Kern wrote: Unlike a UNIX fork, CreateProcess() does not have the same copy-on-write semantics for initializing the memory of the new process. If you want to pass data to the children, the data must be pickled and sent across the process boundary. He's not sa

Re: Idea for removing the GIL...

2011-02-08 Thread Roy Smith
In article , Robert Kern wrote: > Unlike a UNIX fork, CreateProcess() does not have the same copy-on-write > semantics for initializing the memory of the new process. If you want to pass > data to the children, the data must be pickled and sent across the process > boundary. He's not saying t

Re: Idea for removing the GIL...

2011-02-08 Thread Robert Kern
On 2/8/11 10:11 AM, Brian Curtin wrote: On Tue, Feb 8, 2011 at 06:34, Vishal mailto:vsapr...@gmail.com>> wrote: Also, multiprocessing has issues on Windows (most probably because of the way CreateProcess() functions...) Such as? Unlike a UNIX fork, CreateProcess() does not have the sa

Re: Idea for removing the GIL...

2011-02-08 Thread Brian Curtin
On Tue, Feb 8, 2011 at 06:34, Vishal wrote: > Also, multiprocessing has issues on Windows (most probably because of > the way CreateProcess() functions...) Such as? -- http://mail.python.org/mailman/listinfo/python-list

Re: Idea for removing the GIL...

2011-02-08 Thread Jean-Paul Calderone
On Feb 8, 7:34 am, Vishal wrote: > On Feb 8, 3:05 pm, Adam Tauno Williams wrote: > > > On Tue, 2011-02-08 at 01:39 -0800, Vishal wrote: > > > Is it possible that the Python process, creates copies of the > > > interpreter for each thread that is launched, and some how the thread > > > is bound to

Re: Idea for removing the GIL...

2011-02-08 Thread Vishal
On Feb 8, 3:05 pm, Adam Tauno Williams wrote: > On Tue, 2011-02-08 at 01:39 -0800, Vishal wrote: > > Is it possible that the Python process, creates copies of the > > interpreter for each thread that is launched, and some how the thread > > is bound to its own interpreter ? > > and it "may" also a

Re: Idea for removing the GIL...

2011-02-08 Thread Adam Tauno Williams
On Tue, 2011-02-08 at 01:39 -0800, Vishal wrote: > Is it possible that the Python process, creates copies of the > interpreter for each thread that is launched, and some how the thread > is bound to its own interpreter ? > and it "may" also allow the two threads to run in parallel, assuming > the

Re: idea

2009-05-07 Thread Diez B. Roggisch
r-w wrote: > Redirect sys.stderr to the log file in ANUGA logging. > This might catch unexpected exceptions. brillant. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Idea to support public/private.

2009-01-23 Thread Bruno Desthuilliers
Brian Allen Vanderburg II a écrit : Okay so I don't really care about public/private but I was watching the lists (Does python follow its idea of readability or something like that) and I thought of a 'possible' way to add this support to the language. It has already been done at least a coup

Re: Idea to support public/private.

2009-01-22 Thread Brian Allen Vanderburg II
There was a small error in setprivate/getprivate: import sys import inspect def get_private_codes(class_): codes = [] for i in class_.__dict__: value = class_.__dict__[i] if inspect.isfunction(value): codes.append(value.func_code) return codes def get_protect

Re: Idea for P3K

2008-05-08 Thread Diez B. Roggisch
M�ta-MCI (MVP) wrote: > Hi! > >> I don't often feel like using this word > > Look at languages like OCAML or F # The point being? Yes, shockingly enough other languages have other syntax & semantics. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Idea for P3K

2008-05-07 Thread [EMAIL PROTECTED]
On 7 mai, 23:20, John Roth <[EMAIL PROTECTED]> wrote: > On May 7, 3:03 pm, "[EMAIL PROTECTED]" > > > > <[EMAIL PROTECTED]> wrote: > > On 7 mai, 21:41, Gary Herron <[EMAIL PROTECTED]> wrote: > > > > Méta-MCI (MVP) wrote: > > > > Hi! > > > > >> I don't often feel like using this word > > > > > Look

Re: Idea for P3K

2008-05-07 Thread John Roth
On May 7, 3:03 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On 7 mai, 21:41, Gary Herron <[EMAIL PROTECTED]> wrote: > > > Méta-MCI (MVP) wrote: > > > Hi! > > > >> I don't often feel like using this word > > > > Look at languages like OCAML or F # > > > > @-salutations > > > Well of course,

Re: Idea for P3K

2008-05-07 Thread [EMAIL PROTECTED]
On 7 mai, 21:41, Gary Herron <[EMAIL PROTECTED]> wrote: > Méta-MCI (MVP) wrote: > > Hi! > > >> I don't often feel like using this word > > > Look at languages like OCAML or F # > > > @-salutations > > Well of course, we're all well aware of other languages that allow > variables to be bound in the

Re: Idea for P3K

2008-05-07 Thread Daniel Fetchinson
> > I don't often feel like using this word > > Look at languages like OCAML or F # > I looked at OCAML and F#. Now what? Cheers, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Idea for P3K

2008-05-07 Thread Arnaud Delobelle
"Méta-MCI (MVP)" <[EMAIL PROTECTED]> writes: > Hi! > >> I don't often feel like using this word > > Look at languages like OCAML or F # While I like Objective Caml, it is definitively not Python! -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

Re: Idea for P3K

2008-05-07 Thread Gary Herron
Méta-MCI (MVP) wrote: Hi! I don't often feel like using this word Look at languages like OCAML or F # @-salutations Well of course, we're all well aware of other languages that allow variables to be bound in the middle of an expression. It's just that Python was purposely created without

Re: Idea for P3K

2008-05-07 Thread M�ta-MCI (MVP)
Hi! I don't often feel like using this word Look at languages like OCAML or F # @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Idea for P3K

2008-05-07 Thread Arnaud Delobelle
"Méta-MCI (MVP)" <[EMAIL PROTECTED]> writes: > Hi! > > print become a function ; OK > > I thought: and why the affection (=) would not become, also, a function? > Examples: >a = 123return 123 >b,c = 543.21, "LOL"return (543.21, "LOL") Do you m

Re: idea for testing tools

2007-02-08 Thread Eduardo \"EdCrypt\" O. Padoan
> That's hardly desirable. If one is writing a test library that goes as > far as reparsing the assert statements, I can't see the point of > requiring the user to clutter his test suite with such spurious print > statements. After all, that's one of the main points of test suites in > the first pl

Re: idea for testing tools

2007-02-08 Thread Paul Rubin
Jens Theisen <[EMAIL PROTECTED]> writes: > def test_some(): > assert a == b > > didn't reveal the values for a and b, though some more complex cases > showed something. I usually use assert a == b, (a,b) -- http://mail.python.org/mailman/listinfo/python-list

Re: idea for testing tools

2007-02-08 Thread Eduardo \"EdCrypt\" O. Padoan
> #!/usr/bin/python > > a = 1 > b = 2 > > def test_some(): > assert a == b > > didn't reveal the values for a and b, though some more complex cases > showed something. def test_some(): print 'a:', a, 'b:', b assert a == b http://codespeak.net/py/current/doc/test.html#debug-w

Re: idea for testing tools

2007-02-08 Thread Jens Theisen
Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > http://codespeak.net/py/current/doc/test.html#assert-with-the-assert-statement Ok, I didn't come across this before. I didn't work for me though, even the simple case #!/usr/bin/python a = 1 b = 2 def test_some(): assert a == b

Re: idea for testing tools

2007-02-07 Thread Bruno Desthuilliers
Jens Theisen a écrit : > Hello, > > I find it annoying that one has to write > > self.assertEqual(x, y) > > rather than just > > assert x == y > > when writing tests. This is a nuisance in all the programming > languages I know of (which are not too many). http://codespeak.net/py/current/doc/

Re: idea on how to get/set nested python dictionary values

2006-08-16 Thread [EMAIL PROTECTED]
metaperl wrote: > [EMAIL PROTECTED] wrote: > > > | would use a recursive approach for this - given that you have a sort > > of recursive datastructure: > > > > py> def SetNewDataParam2(Data, NewData): > > ... if type(Data[Data.keys()[0]]) == type(dict()): > > ... SetNewDataParam2(Data[

Re: idea on how to get/set nested python dictionary values

2006-08-16 Thread metaperl
[EMAIL PROTECTED] wrote: > | would use a recursive approach for this - given that you have a sort > of recursive datastructure: > > py> def SetNewDataParam2(Data, NewData): > ... if type(Data[Data.keys()[0]]) == type(dict()): > ... SetNewDataParam2(Data[Data.keys()[0]], NewData) > ...

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread jojoba
Once again, Thanks to all I did not expect to receive such a response. Very very helpful indeed, jojoba o(-_-)o -- http://mail.python.org/mailman/listinfo/python-list

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread Simon Forman
[EMAIL PROTECTED] wrote: > | would use a recursive approach for this - given that you have a sort > of recursive datastructure: > > py> def SetNewDataParam2(Data, NewData): > ... if type(Data[Data.keys()[0]]) == type(dict()): Note: |>> type(dict()) is dict True "dict" *is* a type... -- ht

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread bearophileHUGS
Like for the list.sort() method, to remind you that this function operate by side effect, maybe it's better if it doesn't return the modified nested dict: def setNested(nest, path, val): nest2 = nest for key in path[:-1]: nest2 = nest2[key] nest2[path[-1]] = val Bye, bearophil

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread bearophileHUGS
[EMAIL PROTECTED] wrote: > py> def SetNewDataParam2(Data, NewData): > ... if type(Data[Data.keys()[0]]) == type(dict()): > ... SetNewDataParam2(Data[Data.keys()[0]], NewData) > ... else: > ... Data[Data.keys()[0]] = NewData > ... > ... return Data > py> Data = {'a':{'b':

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread jojoba
hey thank you so much! that should work fantastically i like your method much better more elegant thanks! jojoba =) -- http://mail.python.org/mailman/listinfo/python-list

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread [EMAIL PROTECTED]
jojoba wrote: > hello! > > i am trying to come up with a simple way to access my values in my > nested python dictionaries > > here is what i have so far, but i wanted to run it by the geniuses out > there who might see any probems with this... > here is an example: > > +++

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread jojoba
... -- http://mail.python.org/mailman/listinfo/python-list

Re: Idea/request for new python mailing list/newsgroup.

2006-07-07 Thread Simon Forman
Kenneth McDonald wrote: > Would a mailing list and newsgroup for "python contributions" be of > interest? I currently have a module which is built on top of, and is ... > I'd very much likes a ML/newsgroup wherein potential python contributors > could > > * Post alphas/betas and seek feedback. > *

Re: idea: add an asynchronous exception class

2006-03-03 Thread Steven D'Aprano
On Fri, 03 Mar 2006 22:31:49 -0800, Paul Rubin wrote: > I'd like to suggest adding a builtin abstract class to Python called > AsynchronousException, which would be a subclass of Exception. [snip rationale] +1 on this. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list

Re: idea of building python module using pyrex

2005-12-09 Thread [EMAIL PROTECTED]
Hello David, Is SciPy works with python 2.4.2, Windows XP? I thought it is only for python 2.3? pujo -- http://mail.python.org/mailman/listinfo/python-list

Re: idea of building python module using pyrex

2005-12-09 Thread David M. Cooke
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > For example stastical module like commulative probability function for > t distribution, or other numerical module which incorporate looping to > get the result. > > I found that pyrex is very helpfull when dealing with looping > things. Pyrex is

Re: idea of building python module using pyrex

2005-12-09 Thread [EMAIL PROTECTED]
For example stastical module like commulative probability function for t distribution, or other numerical module which incorporate looping to get the result. I found that pyrex is very helpfull when dealing with looping things. pujo -- http://mail.python.org/mailman/listinfo/python-list

Re: idea of building python module using pyrex

2005-12-09 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I just wonder if someone has already build it. built what? it's not like nobody's ever built a Python module using Pyrex before, so I guess you have to be a bit more precise if you want feedback. -- http://mail.python.org/mailman/listinfo/python-list

Re: idea of building python module using pyrex

2005-12-09 Thread [EMAIL PROTECTED]
Hello, I just wonder if someone has already build it. Thanks for the response. Best Regards, pujo -- http://mail.python.org/mailman/listinfo/python-list

Re: idea of building python module using pyrex

2005-12-09 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I have an idea to build python module to speed up python code in some > of field where pyrex shines such as numeric, code which needs a lot of > looping etc. > > What do you think? I don't think you need anyone's permission to do that, really. Just grab the tools and s

Re: idea of building python module using pyrex

2005-12-09 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hello, > > I have an idea to build python module to speed up python code in some > of field where pyrex shines such as numeric, code which needs a lot of > looping etc. Isn't numeric already written in C? -- Regards, Diez B. Roggisch -- http://mail.python.org/mailma