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: 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

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: 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. > <> >

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: "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-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-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 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

"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: 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

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: 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: 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: 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: 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-24 Thread Paddy
P.S: Python 3.2! -- http://mail.python.org/mailman/listinfo/python-list

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: Whats new in Python 3: concurrent-futures example error?

2011-02-22 Thread Paddy
My thanks. -- http://mail.python.org/mailman/listinfo/python-list

Whats new in Python 3: concurrent-futures example error?

2011-02-22 Thread Paddy
t(shutil.copy, 'src2.txt', 'dest2.txt') e.submit(shutil.copy, 'src3.txt', 'dest3.txt') e.submit(shutil.copy, 'src3.txt', 'dest4.txt') Should the last line show a copy of src4.txt rather than src3.txt going to dest4.txt? - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: EXOR or symmetric difference for the Counter class

2010-08-17 Thread Paddy
On Aug 17, 2:29 am, Raymond Hettinger wrote: > I would like to see someone post a subclass to the ASPN Cookbook that > adds a number of interesting, though not common operations.  Your > symmetric_difference() method could be one.  A dot_product() operation > could be another.  Elementwise arithm

Re: EXOR or symmetric difference for the Counter class

2010-08-17 Thread Paddy
On Aug 17, 10:47 pm, Paddy wrote: > On 17 Aug, 02:29, Raymond Hettinger wrote: > > > > > [Paddy] > > > > Lets say you have two *sets* of integers representing two near-copies > > > of some system, then a measure of their difference could be calculated >

Re: EXOR or symmetric difference for the Counter class

2010-08-17 Thread Paddy
On 17 Aug, 02:29, Raymond Hettinger wrote: > [Paddy] > > > Lets say you have two *sets* of integers representing two near-copies > > of some system, then a measure of their difference could be calculated > > as: > > > len(X.symmetric_difference(Y)) / (len(X) +

Re: EXOR or symmetric difference for the Counter class

2010-08-16 Thread Paddy
On 14 Aug, 18:14, Raymond Hettinger wrote: > On Aug 12, 1:20 pm, Paddy wrote: > > > I find myself needing to calculate the difference between two Counters > > or multisets or bags. > > > I want those items that are unique to each bag. > > Tell us about your use

Re: EXOR or symmetric difference for the Counter class

2010-08-13 Thread Paddy
On Aug 13, 6:36 am, Steven D'Aprano wrote: > On Thu, 12 Aug 2010 13:20:19 -0700, Paddy wrote: > > I find myself needing to calculate the difference between two Counters > > or multisets or bags. > > Is this collections.Counter from Python 3.1? If so, you should say so

EXOR or symmetric difference for the Counter class

2010-08-12 Thread Paddy
>>> (b - c) Counter({'b': 1}) >>> (c - b) Counter({'a': 2}) >>> diff Counter({'a': 2, 'b': 1}) But thought why doesn't this operation appear already as a method of the class? - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessing a method from within its own code

2009-11-02 Thread Paddy O'Loughlin
> > I suspect that the "inspection" module has your answer, but that it'll be > bulkier, and much slower than just doing what you're doing already. > Hmm. Yeah, it does appear to be bulky. I don't think it's really any more use than what I'm doing already. Why not use the default arguments gimmic

Accessing a method from within its own code

2009-11-02 Thread Paddy O'Loughlin
e and create it only if it doesn't exist. However, typing out .. everytime is pretty long and susceptible to refactoring issues, so I was wondering if there was a way in Python that I am missing which allows you to reference the method that the code is in (like __module__ gives a reference

Rosetta Code: request for help

2009-06-20 Thread Paddy
ht forward; or could do with an example translated to Python 3.x if it would change a lot from 2.x etc. Please take a look, I know I know I enjoy being involved. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: sorted() erraticly fails to sort string numbers

2009-04-30 Thread Paddy O'Loughlin
iting the old one. Not when, as pointed out by uuid, container is not list-like (at least as far as the sort() method goes). :) Paddy -- "Ray, when someone asks you if you're a god, you say YES!" -- http://mail.python.org/mailman/listinfo/python-list

Reading an exact number of characters from input

2009-04-16 Thread Paddy O'Loughlin
it keeps accepting input (and doesn't return) until I press Enter. My initial thoughts are that a function like C's fgetc would be the easiest way to do it, but I haven't been able to find an equivalent in my google search, so I was wondering if anyone here might have some ideas. Wha

Re: Introducing Python to others

2009-03-26 Thread Paddy O'Loughlin
Thanks for all your replies. A lot of very strong answers :) 2009/3/26 Mensanator : > What would you have to do to make this work? > x+x+x      # expecting [3,6] > [2, 4, 1, 2] What's happening is that the call to map() is returning a list object. So after it calculates the first "x+x", you

Introducing Python to others

2009-03-26 Thread Paddy O'Loughlin
ango (seems to be the "biggest"/most used), or something else? Any other suggestions for a possible "wow" reaction from an audience like that? Thanks, Paddy -- "Ray, when someone asks you if you're a god, you say YES!" -- http://mail.python.org/mailman/listinfo/python-list

Re: Is their an expression to create a class?

2009-03-17 Thread Donald &#x27;Paddy' McCarthy
Chris Rebert wrote: On Tue, Mar 17, 2009 at 2:24 PM, Robert Kern wrote: On 2009-03-17 16:13, Paddy wrote: We the def statement and the lambda expression. We have the class statement, but is their an expression to create a class? Or: def F(): pass type(F) # Is to: F2 = lambda : none type

Is their an expression to create a class?

2009-03-17 Thread Paddy
> class O(object): pass >>> type(O) >>> # is to: >>> # Thanks. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Run a python script as an exe and run a new process from it

2009-02-27 Thread Paddy O'Loughlin
2009/2/27 venutaurus...@gmail.com : > Thanks for the reply,, >            I am trying to use the above application using psexec()in > command line.But it failed returning the error message > >  exited with error code 255. > >              But when I ran the application normally it worked > fine.Do

Re: Run a python script as an exe and run a new process from it

2009-02-26 Thread Paddy O'Loughlin
Try this as an outline: script1.py from subprocess import Popen if __name__ == '__main__': scriptname = "script2.py" Popen("python %s" % scriptname, shell=True) print "I'm done" script2.py from time import sleep if __name__ == '__main__': while (True):

Re: "Byte" type?

2009-02-24 Thread Paddy O'Loughlin
y relevant if ALL the people contributing are being paid by Google to do the work, which I'm pretty sure is not the case. There are people are spending lots of personal, unpaid and voluntary time developing Python. Paddy -- "Ray, when someone asks you if you're a god, you say YES!" -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I declare global vars or class vars in Python ?

2009-02-20 Thread Paddy O'Loughlin
To do so would be over-generalising and not useful to discussion I guess it's your pedantry that I'm questioning. Something like "don't use goto's" works as a GoldenRule because it's been observed that without it, people start using goto statements in places where it's not really appropriate. When you said that "[you] usually shouldn't [use properties] - unless you have a very compelling reason", your tone implied that properties are easy to misuse and tend to be. Not being familiar with properties and seeing them as being pretty harmless, I was intrigued by this, which is why I asked for an explanation. Your explanation seems to show that your tone was likely to be more personal bias than any real issue with properties. Paddy -- "Ray, when someone asks you if you're a god, you say YES!" -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I declare global vars or class vars in Python ?

2009-02-20 Thread Paddy O'Loughlin
eal, for it to described as anything like a "GoldenRule" or to advise against its overuse. You use it when its appropriate and don't use it when you it's not, like any other feature. Paddy -- "Ray, when someone asks you if you're a god, you say YES!" -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I declare global vars or class vars in Python ?

2009-02-20 Thread Paddy O'Loughlin
2009/2/20 Bruno Desthuilliers : > Note that while you *can* do direct access to the implementation attribute > (here, '_A' for property 'A'), you don't *need* to so (and usually shouldn't > - unless you have a very compelling reason). Interesting. Why shouldn't you? I haven't used the property() f

Re: Pythonic way to determine if a string is a number

2009-02-17 Thread Paddy O'Loughlin
g python's own casting rules (given that you are trying to emulate the way python behaves? Or, alternatively, using a regular expression (as Nick Craig-Wood did). Given these solutions, type-conversion and catching the ValueError appears, to me, to be correct, the most concise, and the most r

Re: How do I declare global vars or class vars in Python ?

2009-02-17 Thread Paddy O'Loughlin
ialised in the module. Of course, if you try to call that function before the global has been initialised, python will complain [and rightly so :)] Paddy -- "Ray, when someone asks you if you're a god, you say YES!" -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I declare global vars or class vars in Python ?

2009-02-17 Thread Paddy O'Loughlin
nd sets and all) in python. Paddy 2009/2/17 Linuxguy123 : > How do I do this in Python ? > > # > declare A,B > > function getA >return A > > function getB >return B > > function setA(value) > A = value > > functio

Re: Pythonic way to determine if a string is a number

2009-02-16 Thread Paddy
2 >         -12.34 >         .0 >         . >         1 2 3 >         1 . 2 >         just text >     """ > >     for test in tests.split( '\n' ): >         print 'test (%0s), isnumber: %1s' % \ >           ( test.strip(), isnumber( test ) ) > > Their is a good answer given on Rosetta Code here: http://www.rosettacode.org/wiki/IsNumeric#Python - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Will multithreading make python less popular?

2009-02-16 Thread Paddy
rowing threadds or multiple processes alone when using a poor underlying algorithm. I was just exploring different ways of solving a problem on my blog: http://paddy3118.blogspot.com/2009/02/comparison-of-python-solutions-to.html (But no parallel solutions were attempted). Have fun programmi

Python Fractions issue.

2008-09-22 Thread Paddy
I wonder where the problem lies? (For the Table, please see the blog entry). - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: ctypes: loading .so file on Linux

2008-08-26 Thread Paddy
On Aug 23, 2:33 pm, Paddy <[EMAIL PROTECTED]> wrote: > Hi, > I am am falling at the first hurdle when trying to access a library > using ctypes. > > I have a file libucdb.so which the file command says is shared object, > but I cannot get it to load: > >

Re: Regex on a huge text

2008-08-24 Thread Paddy
the concept. > # > > Regards Try and pre-filter your file on a line basis to cut it down , then apply a further filter on the result. For example, if you were looking for consecutive SPAM records with the same Name field then you might first extract only the SPAM records from the gi

Re: Psyco == tracing optimization?

2008-08-24 Thread Paddy
e trees are widely used?  Got any references for that? > > I too feel that if Perl had such optimizations as Psyco gives Python then they would shout about it. I wonder about the new term and if it fits in the same 'box' as what Psyco does, for example, who was aware of whose work? -

ctypes: loading .so file on Linux

2008-08-23 Thread Paddy
-soft/linux/ActivePython-2.5.1.1-linux-x86_64/ lib/pyth= on2.5/ctypes/__init__.py", line 340, in __init__ self._handle =3D _dlopen(self._name, mode) OSError: /opt/questasim_6.4/questasim/linux/libucdb.so: cannot open shared o= bject file: No such file or directory >>> ^[[A File "", line 1 ^ SyntaxError: invalid syntax >>> - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python one-liner??

2008-08-22 Thread Paddy
ve been known to construct multi-line -c arguments using the bash shell on Unix (as bash supports multi-line quotes), but creating and then deleting a temporary file saves me from 'quoting hell'. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Should Python raise a warning for mutable default arguments?

2008-08-22 Thread Paddy
fying parameter (a) with a default value may have unexpected > consequences > > Though it might be interesting to ask a newbie what he expects when warned > of "unexpected consequences" ;) > > Peter +1 on this. It seems an obvious think to add to a lint-like tool rather than burdening core Python. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Psyco == tracing optimization?

2008-08-22 Thread Paddy
Just wondered if this: http://arstechnica.com/news.ars/post/20080822-firefox-to-get-massive-javascript-performance-boost.html, is a new name for what is done by Psyco? - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Validation of parameters

2008-08-10 Thread Paddy
gt;>> dummy = tmp() Traceback (most recent call last): File "", line 1, in dummy = tmp() File "", line 3, in __init__ self._foo AttributeError: 'tmp' object has no attribute '_foo' >>> - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: What Python looks like

2008-08-05 Thread Paddy
impenetrable. I am not sure if J attracts good programmers or if learning J forces you to think about solutions in different or useful ways. I've learnt A LISP-like language, dabbled with forth & prolog & constraints - maybe its time to learn J and find out if this array pro

Re: Native Code vs. Python code for modules

2008-07-30 Thread Paddy
to think of it as working smarter rather than harder - the brains a much better muscle :-) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing VHDL with python, where to start.

2008-07-29 Thread Paddy
lex. You might not have such problems if your VHDL is all in one library. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Doubt

2008-07-23 Thread Paddy
$a++){ > > } in Python > > Jagan > Linguist This might help you generally: http://wiki.python.org/moin/PerlPhrasebook - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Bidirectional Generators

2008-07-22 Thread Paddy
works a bit more like > what I currently understand. > > Surely some other people have worked with this feature... Are there > any pages that discuss how it's been useful? > > No, I don't want to see an implementation of coroutines. I get that > one already. :-) > &

Re: software engineering foundations?

2008-07-22 Thread Paddy
asic software development practices for scientists and engineers that can reduce the time they spend programming by 20-25%. All of the material is open source: it may be used freely by anyone for educational or commercial purposes, and research groups in academia and industry are actively encouraged to adapt it to their needs. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: question

2008-07-20 Thread Paddy
On Jul 20, 6:39 pm, <[EMAIL PROTECTED]> wrote: > Nobody any sensible answers. Too complicated I suppose! The sensible question was? -- http://mail.python.org/mailman/listinfo/python-list

Re: Question

2008-07-19 Thread Paddy
ice when looking for weapons of mass destruction in Iraq. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: singletons

2008-07-18 Thread Paddy
Craig, This might be good for a general background on Design Patters in Python: http://uk.youtube.com/watch?v=0vJJlVBVTFg - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: read file into list of lists

2008-07-11 Thread Paddy
On Jul 11, 9:32 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jul 11, 11:35 pm, Paddy <[EMAIL PROTECTED]> wrote: > > > > > On Jul 11, 2:15 pm, antar2 <[EMAIL PROTECTED]> wrote: > > > > Hello, > > > > I can not find out how to read a

Re: read file into list of lists

2008-07-11 Thread Paddy
s (3 > columns and 3 rows), so that when I make the print statement list[0] > [0], that the word pear appears > > pear noun singular > books nouns plural > table noun singular > > Can someone help me? > > Thanks lofl = [line.strip().split() for line in the_opened_file]

Re: re.search much slower then grep on some regular expressions

2008-07-05 Thread Paddy
On Jul 5, 4:13 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > It seems like an appropriate moment to point out *this* paper: > > http://swtch.com/~rsc/regexp/regexp1.html > That's the one! Thanks Mark. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: re.search much slower then grep on some regular expressions

2008-07-05 Thread Paddy
On Jul 5, 7:01 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Paddy wrote: > > It is not a smarter algorithm that is used in grep. Python RE's have > > more capabilities than grep RE's which need a slower, more complex > > algorithm. > > So you'r

Re: re.search much slower then grep on some regular expressions

2008-07-04 Thread Paddy
e core developers. > So you can either write a patch yourself or use a workaround. > > re.search('[^ "=]*/', row) if "/" in row else None > > might be good enough. > > Peter It is not a smarter algorithm that is used in grep. Python RE's have

Re: Sorting two dimentional array by column?

2008-07-02 Thread Paddy
at the proper item in the > current row?  I can't quite visualize how to pull > the item out of the dictionary. > > Thanks > > ** Posted fromhttp://www.teranews.com** Hi Tobiah, Try this: arrayofdicts.sort( key = lambda dictinarray: dictinarray.get(sortkeyname) ) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting sorting order

2008-07-01 Thread Paddy
gspot.com/2007/02/unzip-un-needed-in-python.html - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Question: How do I format printing in python

2008-06-25 Thread Donald &#x27;Paddy' McCarthy
7;s printf, and data sequence may be tuple or list. Dictionary may also be used for data, but it has its own way to specify string formatting since dictionary is unordered but "indexed" by the dict key. I have attached a prog I wrote to answer someones elses similar problem. - Paddy.

Propose slight change to tutorial glossary entry on Duck Typing

2008-06-25 Thread Paddy
ture is wrong, then its the excecution of the code using the attribute that will find that out so it is redundant. Best to use EAFP for Duck typing as we trust you know what it is you are doing. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there any way to find out sizeof an object

2008-06-24 Thread Paddy
gt;         self.fn_name = fn_name >         self.args = args >         self.kwds = kwds > Thanks, > Srini > >       Bollywood, fun, friendship, sports and more. You name it, we have it > onhttp://in.promos.yahoo.com/groups/bestofyahoo/ Check memory Create a million

Ruby doctest

2008-06-22 Thread Paddy
://github.com/tablatom/rubydoctest/wikis/special-directives - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: ISO dict => xml converter

2008-06-20 Thread Paddy
nywhere similar to the one illustrated > above.) > > TIA! > > Kynn > > -- > NOTE: In my address everything before the first period is backwards; > and the last period, and everything after it, should be discarded. Try: http://pyxml.sourceforge.net/topics/howto/node26.html - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Pattern Matching Over Python Lists

2008-06-19 Thread Paddy
do you match nested '[' ... ']' brackets? - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Summing a 2D list

2008-06-13 Thread Paddy
"try: ... except KeyError:" instead of the "if") > * list approach: 0.9s > > BTW this was inspired by the book "Programming Pearls" I read some > years ago where a similar approach saved some magnitudes of time > (using a bit field instead of a list to store reserved/free phone > numbers IIRC). > > Yours, > Karsten How does your solution fare against the defaultdict solution of: d = collections.defaultdict(int) for u,s in zip(users,score): d[u] += s - Paddy -- http://mail.python.org/mailman/listinfo/python-list

Re: Mapping None. Why?

2008-06-13 Thread Paddy
On Jun 13, 12:49 pm, David C. Ullrich <[EMAIL PROTECTED]> wrote: > On Thu, 12 Jun 2008 12:05:02 -0700 (PDT), Paddy > > <[EMAIL PROTECTED]> wrote: > > >Iam wondering why the peculiar behavior of map when the function in > >given as None: > > If you start

Re: value is in list?

2008-06-12 Thread Paddy
i in list_ldap if i not in list_current] > seems to work. > > I'm sure there's a way to do it with set objects as well. > -Steven >>> list_current = [ "welcome", "search", "done", "result"] >>> list_ldap = [ "welcome", "hello"] >>> to_add = set(list_ldap) - set(list_current) >>> to_add set(['hello']) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Mapping None. Why?

2008-06-12 Thread Paddy
On Jun 12, 9:36 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Paddy" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | > | Iam wondering why the peculiar behavior of map when the function in > | given as None: > > The &#

Re: Mapping None. Why?

2008-06-12 Thread Paddy
On Jun 12, 9:48 pm, Robert Kern <[EMAIL PROTECTED]> wrote: > Paddy wrote: > > On looking up map on Wikipedia there is no mention of this special > > behaviour, > > So my question is why? > > My question is why you are looking up the semantics of Python functi

Re: Mapping None. Why?

2008-06-12 Thread Paddy
or nil or... ) as argument. > > Diez Oh no! Sorry to give that impression. I don't think that map should be like what Wikipedia says, I was just looking for another example of an implementation that might mention the behaviour. I just want to know the thoughts behind this behaviour in the P

Mapping None. Why?

2008-06-12 Thread Paddy
l2,l3 ('asdf', 'qwertyuip', [0, 1, 2]) >>> map(lambda *x: x, l1,l2,l3) == map(None, l1,l2,l3) True >>> On looking up map on Wikipedia there is no mention of this special behaviour, So my question is why? Thanks, Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Counting things fast - was Re: Summing a 2D list

2008-06-12 Thread Paddy
a few, including: > > 1) using a dictionary with a default value > > d = collections.defaultdict(lambda: 0) > d[key] += value > <> > -- Gerhard This might be faster, by avoiding the lambda: d = collections.defaultdict(int) d[key] += value - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Q re documentation Python style

2008-06-08 Thread Paddy
ted string statement before your function and put the bare essentials in the function itself. This would leave the def nearer the body of the function, but I don't know of anyone else that does this. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why Turn "Print" into "Print()"????

2008-05-27 Thread Paddy
e you should reconsider your stance? And if you do, then you as a group might find a more effective way to persuade others to change. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread Paddy
e methods whose docstrings say DO NOT USE EXTERNALLY" And if they still use them, then they'd be problematic no matter what language was used. Customers ey? Can't live without 'em... ... Actually that's customers Sir! :-) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: C-like assignment expression?

2008-05-21 Thread Paddy
27;) match = prog.match(line) for p in 'p1 p2 p3'.split(): if match.groupdict()[p]: do_something_for_prog(p) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Using Python for programming algorithms

2008-05-20 Thread Paddy
Python then re- implementing in a language closer to assembler - and this may well be the quicker way to your goal. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Using Python for programming algorithms

2008-05-20 Thread Paddy
On May 19, 8:09 pm, Lou Pecora <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Roel Schroeven <[EMAIL PROTECTED]> wrote: > > > > > Bruno Desthuilliers schreef: > > > 1/ being interpreted or compiled (for whatever definition of these > > > terms) is not a property of a language, but

Re: Misuse of list comprehensions?

2008-05-20 Thread Paddy
e result to anything (nor am I even using the result in any > > way). > > > What does everyone think about this? Should list comprehensions be used this > > way, or should they only be used to actually create a new list that will > > then be assigned to a variable/returned/etc.? > > Why not make the list comp the actual list you are trying to build? ... Because it obscures the intent of the code. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: usage of python

2008-05-18 Thread Paddy
t; Any pointers would be appreciated > > Thanks, > Rajarshi Ciranova uses Python and manages to allow its customers to migrate their Designs from a proprietary format that dominates the market using Python: http://www.ciranova.com/index.html - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Sanitised Newsgroup Feeds?

2008-05-14 Thread Paddy
eat and I will continue to read it, but It is more fun reading and posting to Python blog-posts via a Google Reader search, than it is c.l.p Python popularity is a double-edged sword. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is using range() in for loops really Pythonic?

2008-05-12 Thread Paddy
On May 12, 3:46 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-05-12, Ben Finney <[EMAIL PROTECTED]> wrote: > > > Paddy <[EMAIL PROTECTED]> writes: > > >> I've used Fortran and C and so would tend to use either i,j,k as the > >&

Re: Is using range() in for loops really Pythonic?

2008-05-11 Thread Paddy
itertools import repeat > for msg in repeat('hello', 10): > print msg I guess I would not go to the trouble of using itertools.repeat unless it was simplifying/homogenising a larger expression - i.e if it was part of some functional expression I've never fealt the need for a separa

Re: Mathematics in Python are not correct

2008-05-10 Thread Paddy
our titles a little more descriptive to help people filter/search on them. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: firefox add-on to grab python code handily?

2008-05-10 Thread Paddy
ood, as they don't seem to preserve line > breaks > properly or append the .py extension, etc. I've Googled for this and > so far > it seems it doesn't exist. Anyone know? Take a look at the crunchy project: http://crunchy.sourceforge.net/ - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is using range() in for loops really Pythonic?

2008-05-10 Thread Paddy
p >>> for x,y,z in izip(obj1, obj2, obj3): ...print x,y,z ... C a t S u m M e n >>> for i,x in enumerate(obj1): ...print x, obj2[i], obj3[i] ... C a t S u m M e n >>> for i in range(len(obj1)): ...print obj1[i], obj2[i], obj3[i] ... C a t S u m

Re: Wanted: Citation supporting Duck Typing

2008-05-09 Thread Paddy
On May 9, 6:30 pm, Paddy <[EMAIL PROTECTED]> wrote: > Hi, > The wikipedia article on Duck Typing has this criticism section that > needs a citation: > (Fron:http://en.wikipedia.org/wiki/Duck_typing#Criticism) > > An often cited criticism is this: > One issue with du

  1   2   3   4   5   6   7   >