Re: Looking for a way to include Pyhtho scripting INSIDE a python program

2008-04-13 Thread Paddy
back? > > I know I can do something very ugly -- call a C method that calls a new > python interpreter but that seems VERY ugly. > > Help? > > Thanks. You might try ipython at http://ipython.scipy.org/moin/; or 'python - i'; or the exec and eval statements. There is

Re: How to make a "command line basd" interactive program?

2008-04-15 Thread Paddy
On Apr 15, 6:35 am, Evan <[EMAIL PROTECTED]> wrote: > that's great, a custom shell is what I need. > > Thanks all > Evan And for the quick-n-dirty there is: python -i yourscript.py Which runs your script then drops you into the interpreter. - Paddy. -- http://mail.pyth

Re: How to make this unpickling/sorting demo faster?

2008-04-17 Thread Paddy
y rejected by users on those grounds > alone. > """ > THe above is applied slavishly by those who value machine time over peoples time. Do you want to work with them? - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Wanted: Citation supporting Duck Typing

2008-05-09 Thread Paddy
27;t see the problem, but who has written about it). Thanks, Paddy. -- http://mail.python.org/mailman/listinfo/python-list

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

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

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

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

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

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

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: why no block comments in Python?

2006-03-08 Thread Paddy
already given by others, readabiity! Cheers, Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Love :)

2006-03-12 Thread Paddy
Spread the love - tell your Java freinds :-) -- http://mail.python.org/mailman/listinfo/python-list

doctest-alike for a unix shell?

2006-03-13 Thread Paddy
Hi, Anyone know of something that can turn an interactive bash or tcsh session into a test the way doctest does? - Cheers, Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Love :)

2006-03-13 Thread Paddy
BWill wrote: > and ixnay on the ubyray or else I'll tell you where to stick your > endblock delimiter :P Umm, Did you mean to write the above? What has it to do with Ruby? -- http://mail.python.org/mailman/listinfo/python-list

Re: doctest-alike for a unix shell?

2006-03-13 Thread Paddy
that there before me was most of my tests! If only their was doctest for tcsh, I could tell the tool what my prompt strings were, cut-n-paste my shell session, and Bobs yer uncle! I guess doctest-alikes could be created for a lot of shell type interfaces with distinct prompts. - Paddy. -- http

Re: filter list fast

2006-03-18 Thread Paddy
What was the speed-up ? -- http://mail.python.org/mailman/listinfo/python-list

Re: filter list fast

2006-03-18 Thread Paddy
Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Have you ever considered of mousing ambidextrously?

2006-03-18 Thread Paddy
t hand for the odd keystroke. I would however prefer the numeric pad on the left. - Paddy. -- http://paddy3118.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Design mini-lanugage for data input

2006-03-20 Thread Paddy
Hmm, Do you know about JSON and YAML? http://en.wikipedia.org/wiki/JSON http://en.wikipedia.org/wiki/YAML They have the advantage of being maintained by a group of people and being available for a number of languages. (as well as NOT being XML :-) - Cheers, Paddy. -- http://paddy3118

Re: RELEASED Python 2.4.3, release candidate 1

2006-03-23 Thread Paddy
n the day of this posting. - Paddy -- http://paddy3118.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: RELEASED Python 2.4.3, release candidate 1

2006-03-23 Thread Paddy
I just Googled and found the Python-Dev thread 'About "Coverity Study Ranks LAMP Code Quality" '. I was heartened by the type of issues raised in the discussion - it leaves me content with whats 'under-the-hood' in Python. You maintainers don't seem to bang your own drum, which is a good thing, bu

Re: What's the best way to learn perl for a python programmer?

2006-03-24 Thread Paddy
erl, which helped me remember. I used the Well House manual and the Camel book for reference. (http://www.wellho.net/ - Tell Graham Paddy sent you). P.S. I don't have any connection to Well House, apart from learning Perl through them. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Slogan

2006-03-26 Thread Paddy
In the style of the Pepsi 'Lip smakin' add of the 70's... In-dentin easy-readin object-orientin motivatin good buzzin literate programmin' abstractin fast runnin ever givin dynamic PYTHON! - I know, too much free time can be harmful ;-) - Pad. -- http://mail.python.org/ma

Re: using a perl mod

2006-03-27 Thread Paddy
Don't know if there is a way to call perl from Python but the perl inline python module allows you to call perl from python from within an outer perl interpreter. Thts what I make of the following anyway: http://aspn.activestate.com/ASPN/CodeDoc/Inline-Python/Python.html - Paddy. --

Re: using a perl mod

2006-03-27 Thread Paddy
There is also:PyPerl at: http://search.cpan.org/dist/pyperl/perlmodule.pod But you need to check if it is current. - Pad. -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to index numerical data ?

2006-03-31 Thread Paddy
What do you want to search for in the file? how big is the file? What format is the data in the file? - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: DO NOT USE JAVA BECAUSE IT IS NOT OPEN SOURCE

2006-04-02 Thread Paddy
LoL :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: a simple regex question

2006-04-02 Thread Paddy
ion gave the following. >>> import re >>> s ="aMNHiRFLoDLFb" >>> re.findall(r'[A-Z]{3}([a-z])(?=[A-Z]{3})', s) ['i', 'o'] >>> - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: overloading constructor in python?

2006-04-03 Thread Paddy
to parameters: class C2(object): def __init__(self, x=None, y=None, s=""): pass C2 can be initialised with any one, two, three, or zero arguments; those not given would take the default values shown to the right of the equals sign above. - Cheers, Paddy. -- Signs of spring here i

Re: pre-PEP: The create statement

2006-04-05 Thread Paddy
I wonder if the resulting code would look like Python. It seems a great way to unify how things are defined, but I would not want to mix the syntax with the current style. - Pad. -- http://mail.python.org/mailman/listinfo/python-list

Re: efficiency of range() and xrange() in for loops

2006-04-06 Thread Paddy
I wondered at the tone of some of the replies, re-read the repliess and your original message. On first readings ithought that your original message was OK and that the replies were a bit 'strong' . On second reading I thought that the original could be interpreted a little less nicely, but I had t

Re: Automated Graph Plotting in Python

2006-04-09 Thread Paddy
Hi, I saw you mentioned gnuplot and did a search on Google of 'gnuplot python-wrapper' which lead me eventually to: http://gnuplot-py.sourceforge.net/ I have not tried it, but if you would try it and report back if it works that might help someone else too. - Cheerio, Paddy.

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

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

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

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

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

2005-02-03 Thread Paddy McCarthy
be a more intelligent way, maybe type inferencing? But no, please, nothing like the above, it would just get in the way. -- Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Choosing the right parser for parsing C headers

2005-02-08 Thread Paddy McCarthy
t you want. I often find that some simpler tools do 95% of the work and it is easier to treat the other five percent as broken-input. try http://ctags.sourceforge.net/ - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python as capable as Perl for sysadmin work?

2005-02-08 Thread Paddy McCarthy
Jeff Epler wrote: No. Unlike Perl, Python implements only a *finite turning machine* model of computation. An easy way to see this limitation is in the following code: >>> 1.0 / 10.0 0.10001 <> Jeff Nice, Made my evening :-) - Pad. -- http://mail.python.org/mailman/listinfo/pyt

combining several lambda equations

2005-02-18 Thread Paddy McCarthy
ithout referencing # globals x and y as they are artificial in that I will start of with # probably a list of lambda equations. Your help would be appreciated. Thanks, Paddy. -- 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: 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: 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-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: 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
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: "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: 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: Run a python script as an exe and run a new process from it

2009-02-27 Thread Paddy O'Loughlin
2009/2/27 [email protected] : > 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

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

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

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

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

Re: Python not giving free memory back to the os get's me in real problems ...

2007-04-25 Thread Donald &#x27;Paddy' McCarthy
g > > The moment I close the application that launched the macro, my > ressources get freed. > > So is there a way to free my memory inside my nested loops? > > thanks in advance, > tim > Could you split the program into one handling the outer loop and calling another prog

Re: Where did my post go?

2007-04-25 Thread Donald &#x27;Paddy' McCarthy
[EMAIL PROTECTED] wrote: > I posted to this newsgroup earlier about my annoyances with python and > now I can't find the post. What did you do with it? > I notice a gmail address. Google groups was not updated for over a day and is still 'behind'. Try another news r

Re: EuroPython vs PyconUK

2007-04-26 Thread Donald &#x27;Paddy' McCarthy
EuGeNe Van den Bulke wrote: > I do realize that the UK is not really part of Europe (no polemic :P) > but I am nevertheless curious about the logic behind creating another > major Python event in Europe. Wasn't EuroPython enough? > > Like many I am sure, I probably won't be able to attend both (

Re: Is Python really a scripting language?

2007-12-12 Thread Donald &#x27;Paddy' McCarthy
nside. I'm with Doug on this. Python *is* a scripting language which is a *good* thing. It's their perceptions of what scripting languages are capable of that are out-of-date. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: alternating string replace: Extended input (Long).

2008-01-09 Thread Donald &#x27;Paddy' McCarthy
cesco wrote: I created some more test strings and ran posters solutions against them. results attached. - Paddy. # alternating_replacements.py tests = " 1 2_ 3_4 5_6_ 7_8_9 10_11_12_ 13_14_15_16 17_18_19_20_" \ " _ _21 _22_ _23_24 _25_26_ _27_28_29 _30_31_3

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

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.

pprint module and newer standard types

2008-04-17 Thread Donald &#x27;Paddy' McCarthy
pp >>> pp(list(range(3)), width=4) [0, 1, 2] >>> pp(set(range(3)), width=4) {0, 1, 2} - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.5 adoption

2008-04-19 Thread Donald &#x27;Paddy' McCarthy
Joseph Turian wrote: > Basically, we're planning on releasing it as open-source, and don't > want to alienate a large percentage of potential users. Then develop for 2.5 with an eye on what is to come this year in 2.6 with regard to already planned deprecations. -

<    2   3   4   5   6   7