Python 3.X: nonlocal support in eval/exec?

2011-08-11 Thread Paddy
nt is that there seems to be no support for nonlocal in eval/exec (unless, trivially, nonlocal==global). - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3.X: nonlocal support in eval/exec?

2011-08-11 Thread Paddy
On Aug 11, 8:48 am, Terry Reedy wrote: > On 8/11/2011 3:19 AM, Paddy wrote: > > > We can access nonlocal variables in a function, but if we were to eval/ > > exec the function we cannot set up a nested stack of evironment dicts. > > We are limited to just two: global an

functools.partial doesn't work without using named parameter

2011-03-24 Thread Paddy
t; >>> fsf1 = partial(fs, f=f1) >>> fsf1(s) Traceback (most recent call last): File "", line 1, in fsf1(s) TypeError: fs() got multiple values for keyword argument 'f' >>> # BUT >>> fsf1(s=s) [0, 2, 4, 6] >>> Would someone help? - Thanks in advance, Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: functools.partial doesn't work without using named parameter

2011-03-24 Thread Paddy
P.S: Python 3.2! -- http://mail.python.org/mailman/listinfo/python-list

Re: functools.partial doesn't work without using named parameter

2011-03-25 Thread Paddy
Thanks Ian, Benjamin, and Steven. I now know why it works as it does. Thinking about it a little more, Is it reasonable to *expect* partial acts as it does, rather than this way being an implementation convenience? (That was written as a straight question not in any way as a dig). I had though

Re: functools.partial doesn't work without using named parameter

2011-03-25 Thread Paddy
Aha! Thanks Ian for this new snippet. It is what I will use for my current example. (But please see my third posting on this too). -- http://mail.python.org/mailman/listinfo/python-list

Re: Testing for performance regressions

2011-04-04 Thread Paddy
In an extended case when you try and capture how a function works over a range of inputs, you might want to not assume some relationship between input size and time, as this mnight limit your ability to change algorithms and still have acceptable performance. I.e. instead of this: input_range

Re: Guido rethinking removal of cmp from sort method

2011-04-04 Thread Paddy
On Tuesday, April 5, 2011 2:16:07 AM UTC+1, harrismh777 wrote: > Steven D'Aprano wrote: > > I prefer to consider Python 2.7 and Python 3.x as different dialects of > > the same language. There are a very few handful of incompatibilities, > > most of which can be automatically resolved by the 2to3 f

Re: User-defined augmented assignment

2005-09-29 Thread Paddy
I thought along these lines: It is an augmented ASSIGNMENT. (It even has an equals sign in it). tuples are immutable so you should not be able to assign to one of its elements. - So there is no problem for me - I shouldn't be messing with an element of an immutable type! - Cheers,

Re: Some set operators

2005-10-16 Thread Paddy
Hi Bearophile, Nah, you don't want to change 'em. I can remember 'em just fine :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: can a cut-down Python still be Python?

2005-10-17 Thread Paddy
If you mean missing out some of the libraries then that would be different to missing out core functionality sucjh as generators or list expressions,... In general, if the end task is not to present the world with a new programming language then it's usually best to choose from the available, supp

Re: Help: Quick way to test if value lies within a list of lists of ranges?

2005-10-27 Thread Paddy
Would this help? ''' >>> pp(name2ranges) {'a': [[5, 12], [27, 89], [120, 137]], 'b': [[6, 23], [26, 84], [200, 222]], 'c': [[2, 22], [47, 60], [67, 122]]} >>> names4val(28) ['a', 'b'] >>> names4val(11) ['a', 'c', 'b'] >>> names4val(145) [] >>> ''' from pprint import pprint as pp name2ranges =

Re: MSH (shell)

2005-10-28 Thread Paddy
Albert Their "Extract the title and author elements from every item in the rss.channel tag" example is also impressive. Looks like an innovative new shell. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonising the vim (e.g. syntax popups)

2005-11-09 Thread Paddy
Hi, I am using gvim 6.4 which has Python colorising, and The menu tools->folding->fold method->indent :help folding May give you more info. Cheers, Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Death to tuples!

2005-11-28 Thread Paddy
I would consider t = ([1,2], [3,4]) to be assigning a tuple with two list elements to t. The inner lists will be mutable but I did not know you could change the outer tuple and still have the same tuple object. - Pad. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Equivalent to Text::Autoformat

2005-12-03 Thread Paddy
Google is your freind. Try searching for: python text wrapping - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Favorite non-python language trick?

2005-06-29 Thread Paddy
etary languages with this feature, here is an example written in Cadence's Specman 'e' language: http://www.asic-world.com/specman/specman_one_day2.html Cheers, Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Favorite non-python language trick?

2005-06-29 Thread Paddy
Sadly, its not a solution that I'm after, but a particular toolkit that can be used for solving that type of problem. - Pad. -- http://mail.python.org/mailman/listinfo/python-list

Re: A replacement for lambda

2005-07-30 Thread Paddy
onsistant with simple function definitions. - Cheers, Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Thaughts from an (almost) Lurker.

2005-07-31 Thread Paddy
he replies. Rather like dropping a stone in the river and watching pythonistas return c.l.p. to its normal, helpful, and polite norm. Fascinating. I only hope that if thats the case, then they should post their findings here. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Thaughts from an (almost) Lurker.

2005-07-31 Thread Paddy
L.OL :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Decline and fall of scripting languages ?

2005-08-06 Thread Paddy
Do you know anyone who has dropped LAMP for a proprietary Web solution? Or vice versa? Know any sys-admins that have dropped their use of scripting languages for something else? What are the alternatives that are supposedly driving scripting languages out? - I'm unconvinced. -- http://mail.pytho

Interface type checking

2005-08-10 Thread Paddy
Hi, I read a blog entry by GVR on interfaces in which he mentioned that you had to be able to state the type signature of, say, a function. That got me thinking along the lines of: If you have some typical data, then transform it into a string showing its sub-types. Could not a regular expre

Re: list to tuple

2005-08-11 Thread Paddy
Try this: >>> a,b,c = list('tab'),list('era'),list('net') >>> a,b,c (['t', 'a', 'b'], ['e', 'r', 'a'], ['n', 'e', 't']) >>> tuple(((x,y,z) for x,y,z in zip(a,b,c))) (('t', 'e', 'n'), ('a', 'r', 'e'), ('b', 'a', 't')) >>> - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Software bugs aren't inevitable

2005-09-12 Thread Paddy
example at work and circulated it amongst the resident perl mongers. - Gosh it fealt good :-) So, How do I get feedback from Praxis, Do they already read comp.lang.py? Cheers, Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Software bugs aren't inevitable

2005-09-14 Thread Paddy
Hmm, They seem to have reorganised things. As I write, the main article starts here: http://www.spectrum.ieee.org/sep05/2164 With the sidebar here: http://www.spectrum.ieee.org/sep05/2164/extsb1 - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Software bugs aren't inevitable

2005-09-14 Thread Paddy
ts of their flow. Maybe they don't see scripting as part of their flow, but as merely occasional 'duct tape'? I did find an email address on the page you specified and have invited Praxis to join in on this thread, or comment on Python in general. - Paddy. -- http://mail.python.

Re: Oh Yes, They Are [was: Re: Software bugs aren't inevitable]

2005-09-15 Thread Paddy
.S. I like your suggestion about pycon, but I have no reply from anyone at Praxis after emailing them yesterday. - Cheers, Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Software bugs aren't inevitable

2005-09-16 Thread Paddy
The article states that their method calls for them to have much more than normal access to many more people in the clients organisation than is normal; from the CEO to the receptionist. The specification stage can take a year without the customer seeing a line of code. And they deliberately "write

Re: How to program efficient pattern searches in a list of float numbers?

2005-09-19 Thread Paddy
How about posting example data and results? -- http://mail.python.org/mailman/listinfo/python-list

Re: combining several lambda equations

2005-02-18 Thread Paddy
generated). Thanks again for the interest, - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

On eval and its substitution of globals

2005-02-19 Thread Paddy
Hi, I got tripped up on the way eval works with respect to modules and so wrote a test. It seems that a function carries around knowledge of the globals() present when it was defined. (The .func_globals attribute)? When evaluated using eval(...) the embedded globals can be overridden with the one

Re: On eval and its substitution of globals

2005-02-22 Thread Paddy
I have had no reply so on revisiting this I thought I would re-submit it and point out that there is a question way down at the end :-) Thanks. = Original Post = Hi, I got tripped up on the way eval works with respect to modules and so wrote a test. It seems that a function carries arou

Re: On eval and its substitution of globals

2005-02-23 Thread Paddy
was first implimented that way and no-one has submitted a patch of course. Could someone clue me in? Ta, Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: On eval and its substitution of globals

2005-02-23 Thread Paddy
Leif wrote: " If globals were deeply substituted when using eval, the program would presumably print "42\n24", which would be far from intuitive. If you limit the deep substitution to functions in the same module, you're creating a confusing special case. " I guess I need outside opinions on what

Re: Is it possible to pass a parameter by reference?

2005-02-27 Thread Paddy
It is usually clearer to explicitely return values that are changed by a function and re-assign it to the same variable, x=something1 a = something2 def f1(s,t): # do something with t, # do something to s return s a = f1(a,x) Be aware however that you can wrap 'a' in a list for the same eff

Re: Why tuple with one item is no tuple

2005-03-15 Thread Paddy
Hmm, going 'the other way', you are allowed an extra , but you can't have (,) as the empty tuple.: >>> (1,2,) (1, 2) >>> (1,) (1,) >>> (,) ... Traceback ( File "", line 1 (,) ^ SyntaxError: invalid syntax -- Pad. -- http://mail.python.org/mailman/listinfo/python-list

Re: Injecting code into a function

2005-04-25 Thread Paddy
Try searching for: 'python aspect-oriented' as aspect oriented programming is about modifying existing class-methods (not exactly functions which is what you asked for). You might also do a search for "AOP considered harmful" http://www.infosun.fmi.uni-passau.de/st/papers/EIWAS04/stoerzer04aop_harm

"Natural" use of cmp= in sort

2014-11-10 Thread Paddy
Hi, I do agree with Raymond H. about the relative merits of cmp= and key= in sort/sorted, but I decided to also not let natural uses of cmp= pass silently. In answering this question, http://stackoverflow.com/a/26850434/105

Re: "Natural" use of cmp= in sort

2014-11-10 Thread Paddy
On Monday, 10 November 2014 19:44:39 UTC, Ian wrote: > On Mon, Nov 10, 2014 at 12:19 PM, Peter Otten wrote: > > I'm not sure this works. I tried: > > Here's a simpler failure case. > > >>> ineq = """f2 > f3 > ... f3 > f1""" > > [Previously posted code elided] > > >>> greater_thans > set([('f3

Re: "Natural" use of cmp= in sort

2014-11-10 Thread Paddy
On Monday, 10 November 2014 18:45:15 UTC, Paddy wrote: > Hi, I do agree with >Raymond H. about the relative merits of cmp= and key= in > sort/sorted, but I decided to also not let natural uses of cmp= pass

Re: "Natural" use of cmp= in sort

2014-11-10 Thread Paddy
On Tuesday, 11 November 2014 06:37:18 UTC, Ian wrote: > On Mon, Nov 10, 2014 at 8:09 PM, Paddy wrote: > > On Monday, 10 November 2014 18:45:15 UTC, Paddy wrote: > >> Hi, I do agree with > >> Ra

Re: "Natural" use of cmp= in sort

2014-11-11 Thread Paddy
On Tuesday, 11 November 2014 09:07:14 UTC, Ian wrote: > On Tue, Nov 11, 2014 at 12:44 AM, Paddy wrote: > > Thanks Ian. The original author states "...and it is sure that the given > > inputs will give an output, i.e., the inputs will always be valid.", which > >

Re: "Natural" use of cmp= in sort

2014-11-12 Thread Paddy
On Tuesday, 11 November 2014 18:07:27 UTC, Ian wrote: > The example that I posted is one that I recall being brought up on > this list in the past, but I don't have a link for you. THanks Ian for your help in this. -- https://mail.python.org/mailman/listinfo/python-list

Re: Bug in timsort!?

2015-02-25 Thread Paddy
On Wednesday, 25 February 2015 00:08:32 UTC, Chris Angelico wrote: > On Wed, Feb 25, 2015 at 10:50 AM, Skip Montanaro > wrote: > > Even if/when we get to the point where machines can hold an array of > > 2**49 elements, I suspect people won't be using straight Python to > > wrangle them. > <> >

Need opinions on P vs NP

2015-04-17 Thread Paddy
Having just seen Raymond's talk on Beyond PEP-8 here: https://www.youtube.com/watch?v=wf-BqAjZb8M, it reminded me of my own recent post where I am soliciting opinions from non-newbies on the relative Pythonicity of different versions of a routine that has non-simple array manipulations. The bl

Re: Need opinions on P vs NP

2015-04-17 Thread Paddy
On Saturday, 18 April 2015 03:34:57 UTC+1, Ian wrote: > On Fri, Apr 17, 2015 at 7:19 PM, Paddy wrote: > > Having just seen Raymond's talk on Beyond PEP-8 here: > > https://www.youtube.com/watch?v=wf-BqAjZb8M, it reminded me of my own > > recent post where I am so

Re: Need opinions on P vs NP

2015-04-18 Thread Paddy
On Saturday, 18 April 2015 08:09:06 UTC+1, wxjm...@gmail.com wrote: > Le samedi 18 avril 2015 03:19:40 UTC+2, Paddy a écrit : > > Having just seen Raymond's talk on Beyond PEP-8 here: > > https://www.youtube.com/watch?v=wf-BqAjZb8M, it reminded me of my own > > recent

Re: Online Ruby

2005-12-14 Thread Paddy
That reminds me of TclTutor: http://www.msen.com/~clif/TclTutorTour.html TclTutor is a great Tk application that teaches Tcl/Tk by having all the lessons and examples set up waiting in the app. The examples can be edited/fixed and re-executed. I still bring up TclTutor when I delve into Tcl pro

Re: python coding contest

2005-12-31 Thread Paddy
So, testosterone wins again! We get to boast: "Mine's smaller than your's" Lets wait for Pythonic to go to bed, then sneak downstairs, go to that tripple-X rated 'shortest solutions' website, and 'whack-off' some solutions. Unghhh, my solution... its coming!!! Well don't forget to clean up be

Re: list comprehention

2006-01-19 Thread Paddy
t more thought, the intermediate calculation of tmp can be removed with a little loss in clarity though, to give: >>> answer = [ val for val in set(ref) for x in range(min(lst.count(val), >>> ref.count(val)))] >>> answer [2, 2, 4] - Cheers, Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: instances

2006-07-14 Thread Paddy
Quenton Bonds wrote: > Hello > I am trying to understand the abilities and limitation of creating an > instance. First I will give you my understanding then please steer me > in the right direction. > > Abiities > 1. The two ways to create an instance is def method(self) & > __int__(self, other,

Re: using names before they're defined

2006-07-19 Thread Paddy
or1.upstream) # ... With a bit more effort you can create component and link factories that will name instances with the variable they are assigned to without having to put that information in twice. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Language Design: list_for scope?

2006-07-21 Thread Paddy
otal Privacy via Encryption = It is hard to answer your "Why doesn't this wirk question|", and it must be hard to approach Python as a new user by looking at the grammer. Why not try looking at examples, trying them out in the Idle IDE, and only then compare your wor

Re: Type signature

2006-07-23 Thread Paddy
6XW473VSflcJ:www.mindview.net/WebLog/log-0053+%2B%22duck+typing%22+%2B+%22static+typing%22+%2Bpython&hl=en&gl=uk&ct=clnk&cd=3&client=firefox-a It seems that the latent or duck typing, used in dynamic languages is counter-intuitve to those from a static typing background. Nevertheless, it does work, and work well. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Need a compelling argument to use Django instead of Rails

2006-07-24 Thread Paddy
e creator of the language > himself working there. > > 3. Python emphasizes readability instead of cleverness/conciseness. > > 4. What else? I haven't tried RoR so I can't argue meaningfully on > whether using Django will put us at an advantage. > > Can you help me with my argument? Meanwhile I think I'll give RoR a try > as well. > > Thank you, > Ray Ruby does not have doctest :-) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Threads vs Processes

2006-07-26 Thread Paddy
ld and Release > MontaVista Software Carl, OS writers provide much more tools for debugging, tracing, changing the priority of, sand-boxing processes than threads (in general) It *should* be easier to get a process based solution up and running andhave it be more robust, when compared to a threaded s

Re: Using iterators to write in the structure being iterated through?

2006-07-26 Thread Paddy
__(self, p): return self.value[p] obj1 = C1(5) obj2 = C1(5) io1 = iter(obj1) io2 = iter(obj2) print "obj1 pre loop",[r.param for r in obj1.value] try: while 1: io1.next().param += io2.next().param except StopIteration: pass print "obj1 post loop",[r.param for r in obj1.value] - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Using iterators to write in the structure being iterated through?

2006-07-26 Thread Paddy
Paddy wrote: > Pierre Thibault wrote: > > Hello! > > > > I am currently trying to port a C++ code to python, and I think I am stuck > > because of the very different behavior of STL iterators vs python > > iterators. What I need to do is a simple arithmetic opera

Re: Scope, type and UnboundLocalError

2006-07-26 Thread Paddy
Paddy wrote: > Hi, > I am trying to work out why I get UnboundLocalError when accessing an > int from a function where the int is at the global scope, without > explicitly declaring it as global but not when accessing a list in > similar circumstances. > > Th

Re: metaclass : parse all class once before doing anything else ?

2006-07-29 Thread Paddy
Laurent Rahuel wrote: > Hi, > > I have a much to smart problem for my brain. > > Here is the deal : > > I got a metaclass named Foo > > Then I got two others classes: > > class Bar(Foo): > pass > > class Baz(Foo): > pass > > I know how to add some attrs, methods to Bar and Baz when

Re: Static Variables in Python?

2006-07-31 Thread Paddy
orator: initialises function attributes" func.__dict__.update(kw) return func return func2 def accumulator(n): """ return an accumulator function that starts at n >>> x3 = accumulator(3) >>> x3.acc 3 >>> x3(4)

Re: Railroad track syntax diagrams

2006-08-01 Thread Paddy
release of pyparsing, and > also online at the pyparsing.wikispaces.com - but I have no graph-generating > tools to go the next step: generation of the railroad diagrams (in something > more legible/appealing than ASCII-art!). > > Anyone interested in helping complete this last step? > > Thanks, > -- Paul I googlled and got these: http://www.informatik.uni-freiburg.de/~thiemann/haskell/ebnf2ps/ http://www.antlr.org/share/1107033888258/SDG2-1.5.zip - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Railroad track syntax diagrams

2006-08-01 Thread Paddy
Paddy wrote: > Paul McGuire wrote: > > Back in the mid-90's, Kees Blom generated a set of railroad syntax diagrams > > for Python > > (http://python.project.cwi.nl/search/hypermail/python-1994q3/0286.html). > > This pre-dates any Python awareness on my part, but I

Re: More int and float attributes

2006-08-05 Thread Paddy
the ability to choose between hardware supported float s? e.g. float and double precision? Or to be able to just interrogate the float implementation so your prog can adjust to whatever implementation it is running under? Something like: assert float.mant_dig > 20 - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Something for PyPy developers?

2006-08-05 Thread Paddy
I just found this: http://www.cs.princeton.edu/~dpw/popl/06/Tim-POPL.ppt And thought of you... :-) called "The Next Mainstream Programming Languages", Tim Sweeney of Epic Games presents on problems that game writers see and muses on possible solutions. - Pad. -- http://mail.python.org/mailman

Re: More int and float attributes

2006-08-05 Thread Paddy
[EMAIL PROTECTED] wrote: > Paddy: > > Or do you mean the ability to choose between hardware supported float > > s? e.g. float and double precision? > > No, I mean just having the ability to ask the float (his attribute) > what are the max and min values it can represent, e

Re: More int and float attributes

2006-08-05 Thread Paddy
Paddy wrote: > [EMAIL PROTECTED] wrote: > > Paddy: > > > Or do you mean the ability to choose between hardware supported float > > > s? e.g. float and double precision? > > > > No, I mean just having the ability to ask the float (his attribute) > > wha

Re: Static Variables in Python?

2006-08-07 Thread Paddy
Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > Paddy <[EMAIL PROTECTED]> wrote: > . > [substantial thread > with many serious > alternatives] > . >

Re: singleton decorator

2006-08-08 Thread Paddy
Andre Meyer wrote: > Am I missing something here? What is the preferred pythonic way of > implementing singleton elegantly? > > Thanks for your help > André Hi Andre, You might also google for python borg pattern As a discussion on the 'borg' design pattern might be informative. - Pad. -- ht

Re: What's the cleanest way to compare 2 dictionary?

2006-08-09 Thread Paddy
& keyb common_eq = set(k for k in _common if a[k] == b[k]) common_neq = _common - common_eq If you now simple set arithmatic, it should read OK. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the cleanest way to compare 2 dictionary?

2006-08-10 Thread Paddy
cleanest way to do it? (I am sure you will > > come up with ways that astonishes me :=) ) > > > > Paddy has already pointed out a necessary addition to your requirement > definition: common keys with different values. > > Here's another possible addition: you say

Re: What's the cleanest way to compare 2 dictionary?

2006-08-11 Thread Paddy
x27;: 'C', 'B': 'B'}, 4: {'4': '4'}} b ={2: {'2': '2'}, 3: {'C': 'D', 'B': 'B', 'E': 'E'}, 5: {'5': '5'}} comp_result = {'A excl keys': set([1, 4]), 'B excl keys': set([5]), 'Common & eq': set([2]), 'Common keys neq values': [(3, {'A excl keys': set(['A']), 'B excl keys': set(['E']), 'Common & eq': set(['B']), 'Common keys neq values': set(['C'])})]} - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: List match

2006-08-17 Thread Paddy
[EMAIL PROTECTED] wrote: > OriginalBrownster wrote: > > Hi there: > > > > I know this probably is a very easy thing to do in python, but i wanted > > to compare 2 lists and generate a new list that does not copy similar > > entries. An example below > > > > list= ["apple", "banana", "grape"] > > l

Re: List match

2006-08-17 Thread Paddy
ce the double entry would not show up? > > Is there a way to do this?? > > Stephen This solution uses sets; removes all duplicates and is order preserving. Remove the outer sorted wrapper if the order need not be preserved. >>> lst= ["apple", "banana", "

Re: New to python

2006-08-17 Thread Paddy
ou really do need to browse the Library Reference Docs. http://docs.python.org/lib/ You might also want to take a look at this page on the wiki: http://wiki.python.org/moin/PerlPhrasebook Of course, this is as well as going through whatever Python tutorial you are following. Have fun, - Padd

sum and strings

2006-08-17 Thread Paddy
m strings [use ''.join(seq) instead] >>> Well, after all the above, there is a question: Why not make sum work for strings too? It would remove what seems like an arbitrary restriction and aid duck-typing. If the answer is that the sum optimisations don't work for the strin

Re: sum and strings

2006-08-18 Thread Paddy
Sybren Stuvel wrote: > Paddy enlightened us with: > > Well, after all the above, there is a question: > > > > Why not make sum work for strings too? > > Because of "there should only be one way to do it, and that way should > be obvious". There are alrea

Re: sum and strings

2006-08-18 Thread Paddy
Sybren Stuvel wrote: > Paddy enlightened us with: > > Well, after all the above, there is a question: > > > > Why not make sum work for strings too? > > Because of "there should only be one way to do it, and that way should > be obvious". There are alrea

Re: sum and strings

2006-08-18 Thread Paddy
Fredrik Lundh wrote: > Paddy wrote: > > > Here is where I see the break in the 'flow': > > > >>>> 1+2+3 > > 6 > >>>> sum([1,2,3], 0) > > 6 > >>>> [1] + [2] +[3] > > [1, 2, 3] > >>>> sum([[1

Re: sum and strings

2006-08-18 Thread Paddy
Georg Brandl wrote: > Paddy wrote: <> > > I get where you are coming from, but in this case we have a function, > > sum, that is not as geeral as it could be. sum is already here, and > > works for some types but not for strings which seems an arbitrary > > l

Re: sum and strings: Summary

2006-08-18 Thread Paddy
Paul Rubin wrote: > "Paddy" <[EMAIL PROTECTED]> writes: > > Pythons designers seem to know and apply the advantages of having fewer > > 'themes' that can be applied with less constraints I am curious about > > such a constraint on sum. > > The

Re: sum and strings

2006-08-20 Thread Paddy
Rhamphoryncus wrote: > > It's worthwhile to note that the use of + as the concatenation operator > is arbitrary. It could just have well been | or &, and has no > relationship with mathematically addition. The effect of the string concatenation operator is only secondary. Secondary to the use o

Re: Regular Expression question

2006-08-21 Thread Paddy
of information on what matches. Try it. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: sum and strings

2006-08-21 Thread Paddy
Carl Banks wrote: > > and, you know, if you really want to concatenate strings with sum, you > can > > class noopadd(object): > def __add__(self,other): > return other > > sum(["abc","def","ghi"],noopadd()) ;-) - Pad. -- http://mail.python.org/mailman/listinfo/python-list

Re: Where is Python in the scheme of things?

2006-10-04 Thread Paddy
gord wrote: > As a complete novice in the study of Python, I am asking myself where this > language is superior or better suited than others. For example, all I see in > the tutorials are lots of examples of list processing, arithmetic > calculations - all in a DOS-like environment. > > What is pa

Re: help on pickle tool

2006-10-05 Thread Paddy
tp://pyyaml.org/wiki/PyYAML http://jyaml.sourceforge.net/ http://www.yaml.org/ http://www.json.org/ http://www.json.org/java/ - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: help on pickle tool

2006-10-06 Thread Paddy
hanumizzle wrote: > On 5 Oct 2006 22:25:58 -0700, Paddy <[EMAIL PROTECTED]> wrote: > > > You might try picking the data with a different pickle formatter that > > your Java can use. Maybe an XML pickler > > (http://www.gnosis.cx/download/Gnosis_Utils.More/Gnosis_Uti

Re: help on pickle tool

2006-10-06 Thread Paddy
Paddy wrote: > hanumizzle wrote: > > On 5 Oct 2006 22:25:58 -0700, Paddy <[EMAIL PROTECTED]> wrote: > > > > > You might try picking the data with a different pickle formatter that > > > your Java can use. Maybe an XML pickler > > > (http://www.g

Re: extract certain values from file with re

2006-10-06 Thread Paddy
Fabian Braennstroem wrote: > Hi, > > > I actually want to extract the lines with the numbers, write > them to a file and finally use gnuplot for plotting them. A > nicer and more python way would be to extract those numbers, > write them into an array according to their column and plot > t

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread Paddy
advance(bodies, 0.01, n) == This I like. It points to areas of python where maybe we should be adding to the standard library whilst also showing off the cream of the non-standard libraries out their. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie - Stuck

2006-10-08 Thread Paddy
line 1, in ? TypeError: unsupported operand type(s) for ^: 'str' and 'int' $ Please don't give up on Python. It *is* different to Perl. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Starting out.

2006-10-12 Thread Paddy
nd finally: Lets 'big-up' Python: http://www.paulgraham.com/pypar.html I hope you enjoy Python. All the best, Paddy. P.S. maybe your High school might be interested in teaching Python as a first language rather than Java? http://www.oreilly.com/pub/a/oreilly/frank/elkner_0300.htm

Re: Loops Control with Python

2006-10-13 Thread Paddy
(0, 2, 1) (0, 2, 2) Raised exception Outer >>> skip_loops(y2=2) (0, 0, 0) (0, 0, 1) Raised exception Inner (0,) (1, 0, 0) (1, 0, 1) Raised exception Inner (1,) (2, 0, 0) (2, 0, 1) Raised exception Inner (2,) >>> - Paddy. P.S. Welcome to Python! -- http://mail.python.org/mailman/listinfo/python-list

Re: Loops Control with Python

2006-10-13 Thread Paddy
hg wrote: > Paddy wrote: > > P.S. Welcome to Python! > > > How about a thread on GOTOs ? ;-) I'm trying to be nice on c.l.p. - Mind you, I do have that rant as part of my blog: http://paddy3118.blogspot.com/2006/03/whats-wrong-with-perl.html ;-) - Paddy. -- http://

Re: Standard Forth versus Python: a case study

2006-10-13 Thread Paddy
werty wrote: > Apples/oranges ? programmers are making very little $$ today . >Thats software ! No one is makin money on obsolete Forth , > so why a comparisom ? > > Ultimately the best OpSys will be free and millions of lines of code > obsoleted . Because no one can protect intellectu

Re: terminate execfile

2006-10-14 Thread Paddy
, does any > one know how to do it? I presume there is only one thread of execution here, so the file being execfiled would have to recognise an error condition and raise an un-caught exception. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with the 'math' module in 2.5?

2006-10-15 Thread Paddy
Ben Finney wrote: > "Chris" <[EMAIL PROTECTED]> writes: > > > Oh, ok that explains it. Is that why my 16-bit calculator gives me > > 0? > > Your calculator is probably doing rounding without you asking for it. > > Python refuses to guess what you want, and gives you the information > available. >

Re: How to use python in TestMaker

2006-10-18 Thread Paddy
kelin,[EMAIL PROTECTED] wrote: > Hello, > > Now I 'm learning python to do testing jobs, and want to use it in > TestMaker. > The problem is: I don't know how to use python in TestMaker. > Just write python program in it or call .py files in it? > I am really new about it and need some help. > >

Re: why does this unpacking work

2006-10-20 Thread Paddy
to:", sub0,"and:", sub1 ... tpl provides this when iterated over: (0, 1) each element unpacks to: 0 and: 1 tpl provides this when iterated over: (10, 11) each element unpacks to: 10 and: 11 tpl provides this when iterated over: (20, 21) each element unpacks to: 20 and: 21 >>> for sub0, sub1 in tpl: ... print "each element of tuple unpacked immediately to:", sub0,"and:", sub1 ... each element of tuple unpacked immediately to: 0 and: 1 each element of tuple unpacked immediately to: 10 and: 11 each element of tuple unpacked immediately to: 20 and: 21 >>> - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   6   7   >