Re: [ANN] pylint 0.18 / logilab-astng 0.19 / logilab-common 0.39

2009-03-26 Thread Sylvain Thénault
Le Wednesday 25 March 2009 13:43:37 Colin J. Williams, vous avez écrit : > Sylvain Thénault wrote: > > Le Wednesday 25 March 2009 11:58:37 andrew cooke, vous avez écrit : > >> python 3? :o) > > > > python 3 support is no much far away now that we support the new _ast > > module. logilab-common alre

Re: What way is the best to check an empty list?

2009-03-26 Thread Niklas Norrthon
On 26 Mar, 04:31, Steve Holden wrote: > Stef Mientki wrote: > > > Now it would be nice to allow iteration over others too, like None . > >    a = None > >    for item in a : > >          do_something_with_item > > To me that makes about as much sense as writing > >     for x in 1.0: >         prin

Re: What way is the best to check an empty list?

2009-03-26 Thread Niklas Norrthon
On 26 Mar, 08:18, Niklas Norrthon wrote: > But that can easily be achieved with the "or" operator as Michiel > Overton notes elsewhere in this thread: Michiel Overtoom was what I meant to write. My apologies! > def some_function(arg, coll=None): >     do_stuff(arg) >     for item in coll or []:

Is there a simple soap library for python?

2009-03-26 Thread 李田
To emluate a soap service or client. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

unsubscribe to send daily mails

2009-03-26 Thread Sudheer Rapolu
Hello Please unsubscribe to send daily mails to me. Warm Regards Sudheer -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a simple soap library for python?

2009-03-26 Thread *nixtechno
On Mar 26, 12:30 am, 李田 wrote: > To emluate a soap service or client. > Thanks. Perhaps this may help you out: http://pypi.python.org/pypi?%3Aaction=search&term=soap&submit=search I'm sorta new to it all, but I know this place has a LOAD of goodies! -- http://mail.python.org/mailman/listinfo/py

how to optimize zipimport

2009-03-26 Thread Coonay
in my mudule ,i import another mudule from a zip , when i call my mudle method,the module in the zip will be import from the zip every time,that slow down the operation, i try to search the some workarodnd or solution but i don't get one, could you help me ? -- http://mail.python.org/mailman/li

Re: How to get the version of a file on WinOS?

2009-03-26 Thread Tim Golden
Hill wrote: As you know , we can see the file version from by "right click menu and click the detail tab". Now i am wondering how to get this version number using python? Thanks very much! If you're talking about a .DLL then this is probably what you're looking for: http://timgolden.me.uk/pyth

Re: Does Python have certificate?

2009-03-26 Thread Hendrik van Rooyen
"Tim Roberts" wrote: > Steve Holden wrote: > > >Johannes Bauer wrote: > >> Sebastian Bassi schrieb: > >> > >>> No, there is no certification for Python. Maybe in the future... > >> > >> I'll hand out the "Johannes Bauer Python Certificate of Total > >> Awesomeness" for anyone who can write a

Re: PID lockfile (was: PEP 3143: Standard daemon process library)

2009-03-26 Thread Ben Finney
(replying in ‘comp.lang.python’ for wider feedback on this issue) On 26-Mar-2009, Francis Irving wrote: > On Thu, Mar 26, 2009 at 12:51:06AM +1100, Ben Finney wrote: > > The ‘python-daemon’ distribution includes a module, > > ‘daemon.pidlockfile’. The ‘daemon.pidlockfile.PIDLockFile’ class is > >

Re: PID lockfile

2009-03-26 Thread Ben Finney
Ben Finney writes: > (replying in ‘comp.lang.python’ for wider feedback on this issue) > > On 26-Mar-2009, Francis Irving wrote: > > ourlockfile.path = '/tmp/mydaemon.pid' > > context = daemon.DaemonContext( > > pidfile=ourlockfile, > > stdout=logout, > > stderr=logout > > ) > > > >

Re: Is there a simple soap library for python?

2009-03-26 Thread Hendrik van Rooyen
"ÀîÌï" wrote: > To emluate a soap service or client. look at Pyro, and look at xmlrpclib It may not be exactly what you are looking for, but if you are doing both sides, it will help. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list

autocomplete and printing Options

2009-03-26 Thread vitaliypolenko
En Tue, 24 Mar 2009 17:56:26 -0300, vikram moule escribió: > Q1. I want to access a database and just by pressing the first alphabet > will > showup a dropdown list of all the words starting from that alphabet how > can > I do that ? > ( I know how to access the database but the further problem

Re: Introducing Python to others

2009-03-26 Thread *nixtechno
On Mar 26, 2:35 am, "Paddy O'Loughlin" wrote: > Hi, > As our resident python advocate, I've been asked by my team leader to > give a bit of a presentation as an introduction to python to the rest > of our department. > It'll be less than an hour, with time for taking questions at the end. > > Ther

Re: unsubscribe to send daily mails

2009-03-26 Thread Matt Nordhoff
Sudheer Rapolu wrote: > Hello > > Please unsubscribe to send daily mails to me. > > Warm Regards > Sudheer > > > > > -- > http://mail.python.org/mailman/listinfo/python-list See the link in the signature of every message

Re: Ordered Sets

2009-03-26 Thread pataphor
Raymond Hettinger wrote: Right. Here's a link to a weakref version (though I think the previous __del__ version also does the trick): http://code.activestate.com/recipes/576696/ Interesting. But how about this one? Does it also have the reference problem? By the way collections.MutableS

Re: Introducing Python to others

2009-03-26 Thread Hendrik van Rooyen
"Paddy O'Loughlin" wrote: > Any other suggestions for a possible "wow" reaction from an audience like that? two simple demos: The first one is a simple client server thingy on the LAN. I have seen hardened people do a double take when they see how little code it takes to set up a server and a c

Introducing Python to others

2009-03-26 Thread Paddy O'Loughlin
Hi, As our resident python advocate, I've been asked by my team leader to give a bit of a presentation as an introduction to python to the rest of our department. It'll be less than an hour, with time for taking questions at the end. There's not going to be a whole lot of structure to it. First, I

how do you prevent distutils from downloading and building packages without consent?

2009-03-26 Thread lkcl
folks, hi, a number of people using pyjamas are not only encountering difficulties with setup.py endeavouring to download and install "setuptools" but also they are ... the best word to use is unfortunately "offended" - by the fact that distutils, in its default configuration, downloads and even _

Re: Is there a simple soap library for python?

2009-03-26 Thread Diez B. Roggisch
李田 schrieb: To emluate a soap service or client. http://72.249.21.88/nonintersecting/?year=2006&monthnum=11&day=15&name=the-s-stands-for-simple&page= There is no such thing as a "simple soap library". Neither for Python, nor for any other language.. If you can, use something different. O

Re: how do you prevent distutils from downloading and building packages without consent?

2009-03-26 Thread John Machin
On Mar 26, 9:59 pm, lkcl wrote: > folks, hi, > > a number of people using pyjamas are not only encountering > difficulties with setup.py endeavouring to download and install > "setuptools" but also they are ... the best word to use is > unfortunately "offended" - by the fact that distutils, in its

Re: Introducing Python to others

2009-03-26 Thread Jeremiah Dodds
On Thu, Mar 26, 2009 at 9:35 AM, Paddy O'Loughlin < patrick.olough...@gmail.com> wrote: > Hi, > As our resident python advocate, I've been asked by my team leader to > give a bit of a presentation as an introduction to python to the rest > of our department. > It'll be less than an hour, with time

complex sequence SOAP service parameter

2009-03-26 Thread xiaofeng xiong
Hi there, Please help me out. I want to use a SOAP web service. According to the wsdl, I need to pass a parameter of complex type, which contains a sequence. The parameter part of the wsdl is : {{{

Re: Debugging in Py

2009-03-26 Thread Jeremiah Dodds
On Wed, Mar 25, 2009 at 9:25 PM, *nixtechno wrote: > Big thanks tkc, and I was wondering what your thoughts are on logging > module: http://docs.python.org/library/logging.html > > "Instead of using many print statements for debugging, use > logger.debug: Unlike the print statements, which you wi

Extracted files form zip corrupted

2009-03-26 Thread Astley Le Jasper
I want to batch extract files from a directory of zips. The thing is that the files are excel spreadsheets. I don't want to read them in python, just dump them as extracted files in another directory. However, when I do a test the excel file becomes corrupted. Any clues? >>

Re: Introducing Python to others

2009-03-26 Thread Bruno Desthuilliers
Paddy O'Loughlin a écrit : (snip) Anything else you think could make PHP developers starting think that python is a better choice? The debugger ?-) (debugging PHP code is kind of nightmare). If I were to do a (very) short demonstration one web framework for the PHP devs, what should I use? Ch

Re: Extracted files form zip corrupted

2009-03-26 Thread MRAB
Astley Le Jasper wrote: I want to batch extract files from a directory of zips. The thing is that the files are excel spreadsheets. I don't want to read them in python, just dump them as extracted files in another directory. However, when I do a test the excel file becomes corrupted. Any clues?

Re: Introducing Python to others

2009-03-26 Thread Marco Mariani
Paddy O'Loughlin wrote: All of the audience will be experienced (4+ years) programmers, almost all of them are PHP developers (2 others, plus myself, work in C, know C#, perl, java, etc.). Show them the same classical design patterns in Java and Python. Explain how it's much more flexible.

Re: Is there a simple soap library for python?

2009-03-26 Thread Paul McGuire
On Mar 26, 5:17 am, "Diez B. Roggisch" wrote: > > Or maybe Jython + apache axis is a way to go for you, if it's about > quickly writing tests/prototypes against a working service. > The best utility I've found for quickly writing tests against an existing service is soapUI. Very easy to write reg

Python version(s) for new project?

2009-03-26 Thread Philip Semanchuk
Hi all, I'm about to start a new job at which I and others will build a project largely in Python. I'm trying to figure out which Python versions to use and support. I can't use Python 3.x, but I want to prepare for it even if it is a long way off yet. My idea is to use Python 2.6 on my de

Re: Extracted files form zip corrupted

2009-03-26 Thread Astley Le Jasper
Thanks MRAB. What do you mean about backslashes? -- http://mail.python.org/mailman/listinfo/python-list

difflib and intelligent file differences

2009-03-26 Thread hayes . tyler
Hello All: I am starting to work on a file comparison script where I have to compare the contents of two large files. Originally I thought to just sort on a numeric key, and use UNIX's comm to do a line by line comparison. However, this would fail, hence my thinking that I really should've just us

Re: Unable to compile pyprocessing module on SUN solaris

2009-03-26 Thread Deepak Rokade
Hi, I treed to comple the python 2.6 on Solaris 5.8 with gcc version 3.3.2 Initially multiprocessing package was not compile succesfully. below errors: Failed to find the necessary bits to build these modules: _bsddb _hashlib _sqlite3 _ssl _tkinter

Profiler throws NameError on any function

2009-03-26 Thread Philipp Lies
Hi, I'm trying to run the python profiler on some code but I always get NameErrors, even for the simplest case taken from the docs: import profile def foo(): a = 5 def prof(): profile.run('foo()') When I run prof() I get the following output: Traceback (most recent call last): File "",

Re: Introducing Python to others

2009-03-26 Thread python
Paddy, I've tried to categorize some ideas for your presentation. Note that the ideas within each category are ordered by my random "stream of conscience" vs. prioritized in some logical order. Good luck with your presentation! (BTW: It would be great if you could share your final outline with th

Import aliases

2009-03-26 Thread p p
For a while a maintained a Python package 'foo' with a number of modules (including a nested structure of module). Now the package moved into a namespace package'a.b.foo'. What is the way to approach making old code work with the new package in order that imports like import foo.bar.xxx or fro

Re: Python version(s) for new project?

2009-03-26 Thread andrew cooke
Philip Semanchuk wrote: > Hi all, > I'm about to start a new job at which I and others will build a > project largely in Python. I'm trying to figure out which Python > versions to use and support. I can't use Python 3.x, but I want to > prepare for it even if it is a long way off yet. > > My idea

Re: difflib and intelligent file differences

2009-03-26 Thread Marco Mariani
hayes.ty...@gmail.com wrote: My first thought is to do a sweep, where the first sweep takes one line from f1, travels f2, if found, deletes it from a tmp version of f2, and then on to the second line, and so on. If not found, it writes to a file. At the end, if there are also lines still in f1 t

Re: Python version(s) for new project?

2009-03-26 Thread Philip Semanchuk
On Mar 26, 2009, at 10:34 AM, andrew cooke wrote: Philip Semanchuk wrote: Hi all, I'm about to start a new job at which I and others will build a project largely in Python. I'm trying to figure out which Python versions to use and support. I can't use Python 3.x, but I want to prepare for it e

Re: difflib and intelligent file differences

2009-03-26 Thread Marco Mariani
Marco Mariani wrote: while True: a = filea.readline() b = fileb.readline() if not (a or b): break BTW, watch out for this break. It might not be what you want :-/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Ordered Sets

2009-03-26 Thread Scott David Daniels
pataphor wrote: Raymond Hettinger wrote: Right. Here's a link to a weakref version (though I think the previous __del__ version also does the trick): http://code.activestate.com/recipes/576696/ Interesting. But how about this one? Does it also have the reference problem? By the way col

Re: Python version(s) for new project?

2009-03-26 Thread andrew cooke
Philip Semanchuk wrote: > [...]. I just want to > leverage the -3 switch on Python 2.6 to keep an eye on how many 3.x- > incompatible features I'm using. Some will be unavoidable -- print > versus print() comes to mind -- but ideally when the time comes to > support 3.x, we can just run 2to3 and be

Re: difflib and intelligent file differences

2009-03-26 Thread hayes . tyler
On Mar 26, 11:10 am, Marco Mariani wrote: > Marco Mariani wrote: > >>     while True: > >>         a = filea.readline() > >>         b = fileb.readline() > >>         if not (a or b): > >>             break > > BTW, watch out for this break. It might not be what you want :-/ HA! Just found it :P

Re: difflib and intelligent file differences

2009-03-26 Thread Dave Angel
First comment, have you looked at the standard module difflib? There's a sample program diff.py located in tools\scripts that may do what you need already. It finds the differences in context, and displays them in a way that's frequently intuitive, showing you what's been changed, and

Re: Re: difflib and intelligent file differences

2009-03-26 Thread Dave Angel
If the lines are really sorted, all you really need is a merge, where you read one line from each source, and if equal, read another from each. If one source is less, output the lesser line with appropriate tag , and refresh that one from its source. Stop when either source has run out, and t

Re: Introducing Python to others

2009-03-26 Thread Scott David Daniels
Hendrik van Rooyen wrote: "Paddy O'Loughlin" wrote: Any other suggestions for a possible "wow" reaction from an audience like that? two simple demos: The first one is a simple client server thingy on the LAN. I have seen hardened people do a double take when they see how little code it takes t

Odd behavior regarding a list

2009-03-26 Thread Edd Barrett
Hi there, My first post here, so hello :) Just a little background, I am writing my dissertation, which is a JIT compiler based upon LLVM and it's python bindings, along with the aperiot LL(1) parser. I have some code here, which is not behaving as I would expect. Could someone enlighten me as t

imported module scitools not recognized

2009-03-26 Thread mgdevos
Hi all, I have installed the scitools module but modules included in scitools, for example numpyutils, are not recognized. Python is able to import scitools, and scitools is recognized in my editor (Pydev for Eclipse 1.4.4) as autocompletion works well. However, when I try to run a test script:

Re: difflib and intelligent file differences

2009-03-26 Thread Marco Mariani
Dave Angel wrote: If the lines are really sorted, all you really need is a merge, D'oh. Right. The posted code works on unsorted files. The sorted case is even simpler as you pointed out. -- http://mail.python.org/mailman/listinfo/python-list

Re: difflib and intelligent file differences

2009-03-26 Thread Scott David Daniels
hayes.ty...@gmail.com wrote: Any suggestions where to start? Start by reading the docs on the difflib module, perform some of the examples, and attempt to solve it yourself. Once you get in trouble, show a clear example of what you think went wrong. --Scott David Daniels scott.dani...@acm.org

Re: Introducing Python to others

2009-03-26 Thread David C. Ullrich
In article , "Paddy O'Loughlin" wrote: Here's my favorite thing about Python (you'd of course remark that it's just a toy example, doing everything in as dumb but easily understood way as possible): x=[1,2] print x+x class Vector(): def __init__(self, data): self.data = data def __rep

Re: Odd behavior regarding a list

2009-03-26 Thread Albert Hopkins
On Thu, 2009-03-26 at 08:36 -0700, Edd Barrett wrote: > Hi there, > > My first post here, so hello :) > > Just a little background, I am writing my dissertation, which is a JIT > compiler based upon LLVM and it's python bindings, along with the > aperiot LL(1) parser. > > I have some code here,

Re: Extracted files form zip corrupted

2009-03-26 Thread MRAB
Astley Le Jasper wrote: Thanks MRAB. What do you mean about backslashes? Backslashes have a special meaning in string literals: http://pythonconquerstheuniverse.blogspot.com/2008/06/python-gotchas.html -- http://mail.python.org/mailman/listinfo/python-list

Re: difflib and intelligent file differences

2009-03-26 Thread Steven D'Aprano
On Thu, 26 Mar 2009 07:00:52 -0700, hayes.tyler wrote: > Hello All: > > I am starting to work on a file comparison script where I have to > compare the contents of two large files. ... > (and this is why I'm thinking of using > Python's difflib to work on it) ... > Any suggestions where to start

Re: Bash-like brace expansion

2009-03-26 Thread Peter Waller
On Mar 24, 5:39 pm, Peter Waller wrote: > I've since heard that a 'better way' would be to use pyparsing. Also, > I saw that python has dropped the idea of having recursive regular > expressions at the moment. I've written a pyparsing parser which is very much shorter and nicer than the original

Re: Odd behavior regarding a list

2009-03-26 Thread Dave Angel
But you didn't do an assignment, you did an append. Append modifies the object, which is referenced by both parent_struct_sig and this_cdata["struct-sig"] If you're sure you want a *copy* of the list before the modifications, you might do something like parent_struct_sig = \

Re: Odd behavior regarding a list

2009-03-26 Thread Steven D'Aprano
On Thu, 26 Mar 2009 08:36:49 -0700, Edd Barrett wrote: > Hi there, > > My first post here, so hello :) Hello and welcome. Let me comment on a few things out of order. > My question is: why has 'parent_struct_sig' changed? I was under the > impression the assignment operator copies, not referen

Google summer of code project

2009-03-26 Thread slobicus
Hi all, The Ptolemy project (UC Berkeley) is looking for a student to work on a python project and participate in the Google Summer of Code Program 2009. Essentially, during the summer months Google will bring together about 1000 students and as many mentors to contribute to over 150 open source s

Issue Compiling on Aix 5.3

2009-03-26 Thread James R. Emerson
I am trying to compile Python on Aix 5.3. I have used the following options as per the README file: export PATH=/usr/bin:/usr/vacpp/bin ./configure --with-gcc="xlc_r -q64" --with-cxx="xlC_r -q64" \ --disable-ipv6 AR="ar -X64" When I run make I receive the following error: bu

SWIG: Window syntax help

2009-03-26 Thread Muddy Coder
Hi Folks, I am learning SWIG, with a doggy C file test.c. I have made test.i, the interface file, then I ran: C:>swig -python test.i ---> smooth C:>cl -c test.c test_wrap.c -IC:\Python25\include > nice, test.obj, test_wrap.obj, test.py files were created But the final step I got error mes

Re: Introducing Python to others

2009-03-26 Thread J. Cliff Dyer
On Thu, 2009-03-26 at 09:35 +, Paddy O'Loughlin wrote: > Hi, > As our resident python advocate, I've been asked by my team leader to > give a bit of a presentation as an introduction to python to the rest > of our department. > It'll be less than an hour, with time for taking questions at the

Re: Introducing Python to others

2009-03-26 Thread andrew cooke
David C. Ullrich wrote: > In article , > "Paddy O'Loughlin" wrote: > > Here's my favorite thing about Python (you'd of course > remark that it's just a toy example, doing everything > in as dumb but easily understood way as possible): > > x=[1,2] > > print x+x > > class Vector(): > def __init__

Re: difflib and intelligent file differences

2009-03-26 Thread Marco Mariani
Marco Mariani wrote: If the lines are really sorted, all you really need is a merge, For the archives, and for huge files where /usr/bin/diff or difflib are not appropriate, here it is. #!/usr/bin/env python import sys def run(filea, fileb): p = 3 while True: if p&1: a =

Puzzling: local variable in recursive function made global?

2009-03-26 Thread Daniel Oberski
Hello all, I wrote this function to recurse through a tree structure of Nodes connected by Branches. I use a local variable seen_nodes to mark off Nodes already seen by the function (i.e. add them to a list). What is puzzling me is that the local variable seen_nodes seems to be made global

Re: Puzzling: local variable in recursive function made global?

2009-03-26 Thread andrew cooke
it's not global, it's mutable. you are passing THE SAME FRICKING OBJECT to is_terminal and appending values to it. instead, make a new copy: branch.next.is_terminal(list(seen_nodes)) sorry for the shouting, but someone asks this EVERY DAY AND I CAN'T TAKE ANY MORE. andrew Daniel Oberski

Re: Puzzling: local variable in recursive function made global?

2009-03-26 Thread Diez B. Roggisch
Daniel Oberski schrieb: Hello all, I wrote this function to recurse through a tree structure of Nodes connected by Branches. I use a local variable seen_nodes to mark off Nodes already seen by the function (i.e. add them to a list). That's not a local variable, that is a default argument.

Re: Odd behavior regarding a list

2009-03-26 Thread Edd Barrett
Hi there, First of all, thanks to everyone for replying. This has been a great help. On Mar 26, 4:21 pm, Steven D'Aprano wrote: > On Thu, 26 Mar 2009 08:36:49 -0700, Edd Barrett wrote: > > My question is: why has 'parent_struct_sig' changed? I was under the > > impression the assignment operator

Python v3 question related to pickle/marshal

2009-03-26 Thread Detlev Offenbach
Hi, is it possible to marshal or pickle a data structure using Python v3 and unmarshal or unpickle it using Python v2. If it is possible, how do I have to do it. Everything I tried resulted in an EOFError exception upon unmarshalling/unpickling. Regards, Detlev -- Detlev Offenbach det...@die-off

Re: Puzzling: local variable in recursive function made global?

2009-03-26 Thread andrew cooke
Diez B. Roggisch wrote: > That's not a local variable, that is a default argument. Which is in > fact only created once for each function, yes. > > http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm a nice way of handling this was posted here just yesterday, which isn't in t

dblck py file run, setuptools, easy_install don't work

2009-03-26 Thread Kevin Ar18
I just installed Python 3 64bit on Vista 64bit. I am having several issues: 1. I cannot launch python by typing "python" anywhere in the command line. (I added the Python directory to my PATH variable by the way). 2. Double clicking .py files does not run the files like it used to wi

Re: dblck py file run, setuptools, easy_install don't work

2009-03-26 Thread Tim Golden
Kevin Ar18 wrote: I just installed Python 3 64bit on Vista 64bit. I am having several issues: 1. I cannot launch python by typing "python" anywhere in the command line. (I added the Python directory to my PATH variable by the way). 2. Double clicking .py files does not run the files like it u

Re: Python v3 question related to pickle/marshal

2009-03-26 Thread Tino Wildenhain
Detlev Offenbach wrote: Hi, is it possible to marshal or pickle a data structure using Python v3 and unmarshal or unpickle it using Python v2. If it is possible, how do I have to do it. Everything I tried resulted in an EOFError exception upon unmarshalling/unpickling. Could you give the code

type float problem

2009-03-26 Thread rolandschulz
Hi, why does from numpy import * a=array([.2]) print map(type,map(float,a)) print "%f"%map(float,a) give :TypeError: float argument required This is confusing because line 3 returns []. This is on python 2.5.2 and numpy 1.2.1. Roland -- http://mail.python.org/mailman/listinfo/python-list

Memory Leak after Py_Finalize()

2009-03-26 Thread Tom
Hi, I have ported Python, numarray and numpy to the PharLap Embedded Operating System. Python 2.5.2 numpy 1.3.0b1 My problem is the massive memory loss coming back after Py_Finalize() when using numpy. I have seen similar posts but am unclear how to proceed. Here are my symptomns:- Py_Initialize()

Re: Python v3 question related to pickle/marshal

2009-03-26 Thread Peter Otten
Detlev Offenbach wrote: > is it possible to marshal or pickle a data structure using Python v3 and > unmarshal or unpickle it using Python v2. If it is possible, how do I > have to do it. Everything I tried resulted in an EOFError exception upon > unmarshalling/unpickling. It seems to work here,

Re: Introducing Python to others

2009-03-26 Thread Mensanator
On Mar 26, 11:42 am, "andrew cooke" wrote: > David C. Ullrich wrote: > > In article , > >  "Paddy O'Loughlin" wrote: > > > Here's my favorite thing about Python (you'd of course > > remark that it's just a toy example, doing everything > > in as dumb but easily understood way as possible): > > >

Re: Introducing Python to others

2009-03-26 Thread mmanns
On Thu, 26 Mar 2009 12:42:01 -0400 (CLT) "andrew cooke" wrote: > that's cute, but if you show them 2.6 or 3 it's even cuter: > > >>> from operator import add > >>> class Vector(list): > ... def __add__(self, other): > ... return map(add, self, other) > ... > >>> x = Vector([1,2]) > >>> x+x

Import aliases for moving a module?

2009-03-26 Thread zopyxfil...@googlemail.com
For a while a maintained a Python package 'foo' with a number of modules (including a nested structure of module). Now the package moved into a namespace package 'a.b.foo'. What is the way to approach making old code work with the new package in order that imports like import foo.bar.xxx or fr

Re: difflib and intelligent file differences

2009-03-26 Thread hayes . tyler
Thanks for all of your suggestions. Turns out Marco's first version was really the one I needed. Thanks again, t. On Mar 26, 12:37 pm, Marco Mariani wrote: > Marco Mariani wrote: > >> If the lines are really sorted, all you really need is a merge, > > For the archives, and for huge files where

context not cleaned at the end of a loop containing yield?

2009-03-26 Thread TP
Hi everybody, This example gives strange results: def foo( l = [] ): l2 = l print l2 for i in range(10): if i%2 == 0: l2.append( i ) yield i >>> [i for i in ut.foo()] [] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> [i for i in ut.foo()] [0, 2, 4,

Re: context not cleaned at the end of a loop containing yield?

2009-03-26 Thread MRAB
TP wrote: Hi everybody, This example gives strange results: def foo( l = [] ): l2 = l print l2 for i in range(10): if i%2 == 0: l2.append( i ) yield i [i for i in ut.foo()] [] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [i for i in ut.foo()] [0

Re: Puzzling: local variable in recursive function made global?

2009-03-26 Thread Peter Otten
andrew cooke wrote: > Diez B. Roggisch wrote: >> That's not a local variable, that is a default argument. Which is in >> fact only created once for each function, yes. >> >> http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm > > a nice way of handling this was posted here j

Re: type float problem

2009-03-26 Thread Pavol Juhas
This has nothing to do with numpy, the issue is the string "%" operator cannot convert list to a float (Line 3 in your example gives a list). In '"%f" % x' the x has to be a number or tuple. Does not work: print "%f" % [1.0] Works: print "%f" % 1 print "%f" % (1, ) print "%f" % tu

Re: Python v3 question related to pickle/marshal

2009-03-26 Thread Detlev Offenbach
Tino Wildenhain wrote: > Detlev Offenbach wrote: >> Hi, >> >> is it possible to marshal or pickle a data structure using Python v3 >> and unmarshal or unpickle it using Python v2. If it is possible, how >> do I have to do it. Everything I tried resulted in an EOFError >> exception upon unmarshall

Re: Introducing Python to others

2009-03-26 Thread Peter Otten
Mensanator wrote: > On Mar 26, 11:42 am, "andrew cooke" wrote: >> David C. Ullrich wrote: >> > In article , >> > "Paddy O'Loughlin" wrote: >> >> > Here's my favorite thing about Python (you'd of course >> > remark that it's just a toy example, doing everything >> > in as dumb but easily understo

Re: Puzzling: local variable in recursive function made global?

2009-03-26 Thread Daniel Oberski
Hi Andrew, > it's not global, it's mutable. you are passing THE SAME FRICKING OBJECT > to is_terminal and appending values to it. That, I understand. I already saw in the archives this confuses many people, e.g. the thread "Odd behavior regarding a list". I think this is understandable if you

Re: Puzzling: local variable in recursive function made global?

2009-03-26 Thread Daniel Oberski
Hi Diez, Great, this totally clears it up. Thank you! - daniel On Thu, 26 Mar 2009 17:50:20 +0100, Diez B. Roggisch wrote: > > That's not a local variable, that is a default argument. Which is in > fact only created once for each function, yes.> > http://effbot.org/pyfaq/why-are-default-value

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

Re: Puzzling: local variable in recursive function made global?

2009-03-26 Thread Daniel Oberski
Hi Peter, > Plus, it works as expected (read: modifies the argument) if you > explicitly pass an empty list to the function... That is not so. The reason is given by Andrew Cooke in this thread. I would "expect" that when function calls lower in the recursion hierarchy return, the object is not

Re: context not cleaned at the end of a loop containing yield?

2009-03-26 Thread Mensanator
On Mar 26, 1:34 pm, MRAB wrote: > TP wrote: > > Hi everybody, > > > This example gives strange results: > > > > > def foo( l = [] ): > > >     l2 = l > >     print l2 > >     for i in range(10): > >         if i%2 == 0: > >             l2.append( i ) > >         yield i > > > > >

Re: Puzzling: local variable in recursive function made global?

2009-03-26 Thread MRAB
andrew cooke wrote: it's not global, it's mutable. you are passing THE SAME FRICKING OBJECT to is_terminal and appending values to it. instead, make a new copy: branch.next.is_terminal(list(seen_nodes)) sorry for the shouting, but someone asks this EVERY DAY AND I CAN'T TAKE ANY MORE. [s

Re: Introducing Python to others

2009-03-26 Thread Irmen de Jong
Apart from the other suggestions that have been made already, it could be very wow-provoking if you have a nice example using ctypes to interface to existing c libraries. Python shines as a glue language too :-) --irmen -- http://mail.python.org/mailman/listinfo/python-list

Re: imported module scitools not recognized

2009-03-26 Thread Robert Kern
On 2009-03-26 10:42, mgdevos wrote: Hi all, I have installed the scitools module but modules included in scitools, for example numpyutils, are not recognized. Python is able to import scitools, and scitools is recognized in my editor (Pydev for Eclipse 1.4.4) as autocompletion works well. Howev

Re: "Battleship" style game

2009-03-26 Thread Falstaff
On Feb 25, 10:11 pm, Zvezdan Petkovic wrote: > On Feb 25, 2009, at 3:54 PM, Shawn Milochik wrote: > > > It is true that it would be fewer lines of code with the same > > functionality, but it's better practice to have that framework in > > place so that any changes made in the future wouldn't brea

Re: Puzzling: local variable in recursive function made global?

2009-03-26 Thread Peter Otten
Daniel Oberski wrote: > Hi Peter, > >> Plus, it works as expected (read: modifies the argument) if you >> explicitly pass an empty list to the function... > > That is not so. The reason is given by Andrew Cooke in this thread. > > I would "expect" that when function calls lower in the recursion

Find duplicates in a list and count them ...

2009-03-26 Thread Paul . Scipione
Hello, I'm a newbie to Python. I have a list which contains integers (about 80,000). I want to find a quick way to get the numbers that occur in the list more than once, and how many times that number is duplicated in the list. I've done this right now by looping through the list, getting a

Re: Is there a simple soap library for python?

2009-03-26 Thread JBW
On Thu, 26 Mar 2009 11:17:28 +0100, Diez B. Roggisch wrote: > > > There is no such thing as a "simple soap library". Neither for Python, > nor for any other language. Thanks for the link. I had it bookmarked, but last time I tried it, it was dead. To me, it pretty accurately describes the cu

Calendar module: HTMLCalendar overrides style sheet settings

2009-03-26 Thread Sibylle Koczian
Hello, I want to create a calendar with special text and background color for holidays and some other dates. This is for printing, but a HTML file seems a good choice, independent of changing text processing software and easier to code with Python than a script which fills in a Word or OpenOffice

Re: Find duplicates in a list and count them ...

2009-03-26 Thread D'Arcy J.M. Cain
On Thu, 26 Mar 2009 12:22:27 -0700 paul.scipi...@aps.com wrote: > I'm a newbie to Python. I have a list which contains integers (about > 80,000). I want to find a quick way to get the numbers that occur in the > list more than once, and how many times that number is duplicated in the > list.

split string at commas respecting quotes when string not in csv format

2009-03-26 Thread R. David Murray
OK, I've got a little problem that I'd like to ask the assembled minds for help with. I can write code to parse this, but I'm thinking it may be possible to do it with regexes. My regex foo isn't that good, so if anyone is willing to help (or offer an alternate parsing suggestion) I would be grea

  1   2   >