Re: running shelscript inside python

2009-03-26 Thread harijay
Hello Albert , Thanks for your pointers I did finally get it to work Here is what worked: script = """SYMM %s CELL %s skipline LABOUT H K L FP FOM PHIS X CTYPOUT H H H F W P R FORMAT '(3f4.0,f11.2,f8.2,f8.1,f8.2)' END eof""" %(options.symm,cellparams) import su

C extension using GSL

2009-03-26 Thread jesse
I give up. I cannot find my memory leak! I'm hoping that someone out there has come across something similar. Let me lay out the basic setup: I'm performing multiple simulations on a model. Each iteration involves solving a system of differential equations. For this I use the GNU Scientific Librar

Re: Any way to use a range as a key in a dictionary?

2009-03-26 Thread Paul Rubin
Dennis Lee Bieber writes: > ... v = theDict.get(x, NOT_RELEVANT) > ... if v is not NOT_RELEVANT: > ... print x, v I think you'd normally do this with if x in theDict: print x, v but the OP was asking about a different problem, involving looking up numeric ranges, wh

dict view to list

2009-03-26 Thread Aaron Brady
Hi. Is there a possibility of the dict_values, dict_items, and dict_keys objects growing a 'tolist' method? It's one of those little things that contributes to one's user experience. P.S. Yes, yes, I know, -1. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python AppStore / Marketplace

2009-03-26 Thread David Lyon
I think Marcel has a point... Much can be done and should be done to improve packaging and applications for python. That's why I for one am working on the python package manager project. On sourceforge. It uses the pypi interface to search. Actually we haven't made a release yet. Still many..

Re: Python AppStore / Marketplace

2009-03-26 Thread Joshua Judson Rosen
Marcel Luethi writes: > > Now I'm standing here, having this great idea for a brand new rocking > app... > But where do I start? I want it to be multi-platform (Linux, Mac OS X, > Windows). It should be easy to install and upgrade. It should be self- > contained, independent of an already installe

Re: Is there a simple soap library for python?

2009-03-26 Thread 李田
Thanks. 2009/3/26, 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/listin

Re: not pack methon in tkinter

2009-03-26 Thread alex23
On Mar 27, 1:39 pm, kuangye wrote: > Hi, all.  Why can not i find the pack method in tkinter. > [...] > w.pack() ###I can not find this method in Label and Label's ancesters > ##So  where does pack function come from?? Take a look at the Pack class in Tkinter.py, line 1765. It's a rebinding of th

RE: Style question - defining immutable class data members

2009-03-26 Thread John Posner
[snip] >> > If the object is a class instance and the attribute reference occurs >> > on both sides of the assignment operator; for example:: >> > >> > self.x = self.x + 1 >> > >> > ... in the RHS expression, ``self.x`` is evaluated with >> > ``getattr()``, which ca

not pack methon in tkinter

2009-03-26 Thread kuangye
Hi, all. Why can not i find the pack method in tkinter. code segment: from Tkinter import * root = Tk() w = Label(root, text="Hello, world!") w.pack() ###I can not find this method in Label and Label's ancesters ##So where does pack function come from?? root.mainloop() -- http://mail.python

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

2009-03-26 Thread R. David Murray
Paul McGuire wrote: > On Mar 26, 2:51 pm, "R. David Murray" wrote: > > 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 > >

Re: Any way to use a range as a key in a dictionary?

2009-03-26 Thread Carl Banks
On Mar 26, 2:35 pm, Mudcat wrote: > I would like to use a dictionary to store byte table information to > decode some binary data. The actual number of entries won't be that > large, at most 10. That leaves the other 65525 entries as 'reserved' > or 'other' but still need to be somehow accounted f

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

2009-03-26 Thread R. David Murray
John Machin wrote: > On Mar 27, 6:51 am, "R. David Murray" wrote: > > 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 > >

Re: Any way to use a range as a key in a dictionary?

2009-03-26 Thread Aaron Brady
On Mar 26, 5:10 pm, "andrew cooke" wrote: > Mudcat wrote: > > I would like to use a dictionary to store byte table information to > > decode some binary data. The actual number of entries won't be that > > large, at most 10. That leaves the other 65525 entries as 'reserved' > > or 'other' but stil

Re: Introducing Python to others

2009-03-26 Thread André
On Mar 26, 6: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: how to arrange classes in .py files?

2009-03-26 Thread bearophileHUGS
Kent: > Now I just deal with my little application exactly in Java style: > package: gui, service, dao, entity, util If those things are made of a small enough number of sub things and such sub things are small enough, then you may use a single module for each of those Java packages (or even less)

Programming Python 4th Edition?

2009-03-26 Thread Esmail
Hi, Does anyone know if there is a 4th edition of this book planned and if so, when it might be coming out? It looks like a good and comprehensive book but is getting a bit outdated(?). And I guess since I'm asking this, I might as well be asking what your favorite, comparable Python book might

Re: how to arrange classes in .py files?

2009-03-26 Thread Terry Reedy
Kent wrote: In above packages, each .py file contains one python class. And ClassName = Filename not sure about the right code structure of python oop. Group related objects into one module. People of course differ on lumping versus splitting. Can anyone give some hint on it? would be gr

Re: Any way to use a range as a key in a dictionary?

2009-03-26 Thread bearophileHUGS
An interval map maybe? http://code.activestate.com/recipes/457411/ A programmer has to know the name of many data structures :-) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

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

2009-03-26 Thread Josh Dukes
On Thu, 26 Mar 2009 16:02:20 -0400 "D'Arcy J.M. Cain" wrote: or l = ( randint(0,9) for x in xrange(8) ) > On Thu, 26 Mar 2009 16:00:01 -0400 > Albert Hopkins wrote: > > > l = list() > > > for i in xrange(8): > > > l.append(randint(0,10)) > > ^^^ > > should

Re: Code anntotations (copyright, autor, etc) in your code

2009-03-26 Thread Ben Finney
Tim Daneliuk writes: > mattia wrote: > > Hi all, which are the usual comments that you put at the beginning > > of your code to explain e.g. the author, the usage, the license > > etc? I use a single-line copyright statement for each distinct holder, and a brief grant of license under some free-

how to arrange classes in .py files?

2009-03-26 Thread Kent
Hi all, I work with Java. Recently I read some about python, and it is really impressive. So i decide to learn it in my spare time by a small application. But i got a question about the python classes. Didn't find any help with Google. In java, usually a .java file contains One Class. I read some

Re: type float problem

2009-03-26 Thread Robert Kern
On 2009-03-26 19:27, rolandschulz wrote: On Mar 26, 2:41 pm, Pavol Juhas wrote: 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: pri

Re: file transfer over LAN

2009-03-26 Thread MRAB
prakash jp wrote: Hi all, On generating log file on remote systems(say client), I want to transfer them to the Network Admins(say Server) Computer. In doing so all the contents of the log file r not transfered, only part of the file. I appreciate ur help, here is the pre-existant code: fi

Re: type float problem

2009-03-26 Thread rolandschulz
On Mar 26, 2:41 pm, Pavol Juhas wrote: > 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] Yes that helps.

file transfer over LAN

2009-03-26 Thread prakash jp
Hi all, On generating log file on remote systems(say client), I want to transfer them to the Network Admins(say Server) Computer. In doing so all the contents of the log file r not transfered, only part of the file. I appreciate ur help, here is the pre-existant code: file sender !!!--client:

RE: Introducing Python to others

2009-03-26 Thread Delaney, Timothy (Tim)
Rhodri James wrote: > On Thu, 26 Mar 2009 09:35:55 -, Paddy O'Loughlin > wrote: > >> Because of this, I was thinking of making sure I included exceptions >> and handling, the richness of the python library and a pointing out >> how many modules there were out there to do almost anything one

Re: control device via USB or Parallel

2009-03-26 Thread alejandro
I just cant install it. Here is 1 in the morning. Do I have to do all that it says on the webpage? http://libusb-win32.sourceforge.net/ "miki" wrote in message news:3580d70f-3b11-4a56-abeb-9284b4012...@f1g2000prb.googlegroups.com... On Mar 26, 3:43 pm, "alejandro" wrote: > Some guy will make s

Re: Odd behavior regarding a list

2009-03-26 Thread Rhodri James
On Thu, 26 Mar 2009 17:01:40 -, Edd Barrett wrote: On Mar 26, 4:21 pm, Steven D'Aprano wrote: A few more comments, based on your code. >    def __classdef_integer(self): Double-underscore name mangling is often more trouble than it is worth. Unless you really need it, not just think you

Re: control device via USB or Parallel

2009-03-26 Thread miki
On Mar 26, 3:43 pm, "alejandro" wrote: > Some guy will make switches that can be controlled via USB or parallel, he > told me that I can chose which connection I want. So, are there any modules > for Python that will allow me to control some switches via USB or parallel? For parallel port there i

Re: Introducing Python to others

2009-03-26 Thread Rhodri James
On Thu, 26 Mar 2009 09:35:55 -, Paddy O'Loughlin wrote: Because of this, I was thinking of making sure I included exceptions and handling, the richness of the python library and a pointing out how many modules there were out there to do almost anything one could think of. Once you've sh

Re: Introducing Python to others

2009-03-26 Thread Mensanator
On Mar 26, 4:32 pm, Jervis Whitley wrote: > >> class Vector(list): > > >>> ...   def __add__(self, other): > >>> ...     return map(add, self, other) > >>> ...>>> x = Vector([1,2]) > > I've used the complex type for a similar problem (2D Cartesian points) > in the past, I saw the suggestion >

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

2009-03-26 Thread John Machin
On Mar 27, 8:14 am, paul.scipi...@aps.com wrote: > Hi D'Arcy J.M. Cain, > > Thank you.  I tried this and my list of 76,979 integers got reduced to a > dictionary of 76,963 items, each item listing the integer value from the > list, a comma, and a 1. I doubt this very much. Please show: (a) your

Re: running shelscript inside python

2009-03-26 Thread Albert Hopkins
On Thu, 2009-03-26 at 15:23 -0700, harijay wrote: > Hi > I want to run shell scripts of the following kind from inside python > and for some reason either the os.system or the subprocess.call ways > are not working for me . > > I am calling a fortran command (f2mtz ) with some keyworded input that

New Python Runtime

2009-03-26 Thread Adonis
Came across this article on Ars on a new LLVM (Low Level Virtual Machine) JIT compiler for Python being built by Google: http://arstechnica.com/open-source/news/2009/03/google-launches-project-to-boost-python-performance-by-5x.ars Now the question is will this make Vista run faster? Thought I'

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

2009-03-26 Thread MRAB
Benjamin Kaplan wrote: On Thu, Mar 26, 2009 at 5:14 PM, > wrote: Hi D'Arcy J.M. Cain, Thank you. I tried this and my list of 76,979 integers got reduced to a dictionary of 76,963 items, each item listing the integer value from the list, a comma,

running shelscript inside python

2009-03-26 Thread harijay
Hi I want to run shell scripts of the following kind from inside python and for some reason either the os.system or the subprocess.call ways are not working for me . I am calling a fortran command (f2mtz ) with some keyworded input that is normally piped (<<) in. The section of code that deals wi

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

2009-03-26 Thread John Machin
On Mar 27, 8:43 am, Terry Reedy wrote: > R. David Murray wrote: > > 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 > > any

Re: Any way to use a range as a key in a dictionary?

2009-03-26 Thread Paul Rubin
Mudcat writes: > However I wondered if there was a way to simply use a range as a key > reference somehow. Dictionaries aren't really the right structure for that. You want a tree or binary search structure of some sort. The bisect module might be helpful, but you will have to write some code

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

2009-03-26 Thread Benjamin Kaplan
On Thu, Mar 26, 2009 at 5:14 PM, wrote: > Hi D'Arcy J.M. Cain, > > Thank you. I tried this and my list of 76,979 integers got reduced to a > dictionary of 76,963 items, each item listing the integer value from the > list, a comma, and a 1. I think what this is doing is finding all integers > fr

Re: Any way to use a range as a key in a dictionary?

2009-03-26 Thread andrew cooke
Mudcat wrote: > I would like to use a dictionary to store byte table information to > decode some binary data. The actual number of entries won't be that > large, at most 10. That leaves the other 65525 entries as 'reserved' > or 'other' but still need to be somehow accounted for when > referenced.

Re: Any way to use a range as a key in a dictionary?

2009-03-26 Thread Daniel Fetchinson
> I would like to use a dictionary to store byte table information to > decode some binary data. The actual number of entries won't be that > large, at most 10. That leaves the other 65525 entries as 'reserved' > or 'other' but still need to be somehow accounted for when > referenced. > > So there

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

2009-03-26 Thread Terry Reedy
R. David Murray wrote: 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 su

Re: unicode for beginners

2009-03-26 Thread skip
Wally> I have something of a csv file which has somehow been converted Wally> into something that looks like this... Wally> Is there a simple way to convert this into something a little bit Wally> readable? Look at the unicode_csv_reader function in the csv module doc's examples:

Re: unicode for beginners

2009-03-26 Thread WallyDD
On Mar 26, 5:30 pm, Peter Otten <__pete...@web.de> wrote: > WallyDD wrote: > > I have something of a csv file which has somehow been converted into > > something that looks like this; > > " FOZ DE IGUAZ\u00da" and " R\u00cdO DE JANEIRO" > > > Is there a simple way to convert this into something a l

Any way to use a range as a key in a dictionary?

2009-03-26 Thread Mudcat
I would like to use a dictionary to store byte table information to decode some binary data. The actual number of entries won't be that large, at most 10. That leaves the other 65525 entries as 'reserved' or 'other' but still need to be somehow accounted for when referenced. So there are a couple

Re: unicode for beginners

2009-03-26 Thread Vlastimil Brom
2009/3/26 WallyDD : > I have something of a csv file which has somehow been converted into > something that looks like this; > " FOZ DE IGUAZ\u00da" and " R\u00cdO DE JANEIRO" > Is there a simple way to convert this into something a little bit > readable? > Is there a simple command in python to co

Re: unicode for beginners

2009-03-26 Thread Peter Otten
WallyDD wrote: > I have something of a csv file which has somehow been converted into > something that looks like this; > " FOZ DE IGUAZ\u00da" and " R\u00cdO DE JANEIRO" > > Is there a simple way to convert this into something a little bit > readable? > > Is there a simple command in python to

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

2009-03-26 Thread Tim Chase
R. David Murray wrote: Tim Chase wrote: r = re.compile(r""" (\w+) \s*=\s*( "(?:[^"]*)" | [^,]+ ) """, re.VERBOSE) results = [ (m.group(1), m.group(2).strip('"')) for m in r.finditer(s) ] Thank you thank you. I owe you a dinner if we are

Re: Introducing Python to others

2009-03-26 Thread Jervis Whitley
>> class Vector(list): >>> >>> ...   def __add__(self, other): >>> ...     return map(add, self, other) >>> ...>>> x = Vector([1,2]) I've used the complex type for a similar problem (2D Cartesian points) in the past, I saw the suggestion once on the pygame list. >>> x = complex(1,2) >

Help in reading the pdf file

2009-03-26 Thread M Kumar
Hi, I need to read pdf files and extract data from it, is there any way to do it through python. thanks & reagards Maneesh KB -- http://mail.python.org/mailman/listinfo/python-list

unicode for beginners

2009-03-26 Thread WallyDD
I have something of a csv file which has somehow been converted into something that looks like this; " FOZ DE IGUAZ\u00da" and " R\u00cdO DE JANEIRO" Is there a simple way to convert this into something a little bit readable? Is there a simple command in python to convert this? Thank you. -- htt

Using ctypes with National Instruments nilibddc.dll

2009-03-26 Thread aewindhorn
I would like to use Python ctypes with this "DiaDEM Connectivity Library", but it only has examples for C and Matlab. I have got a couple of things to work by trial and error, but it is slow. Has anyone here used this library with Python? Here's what I have so far: -

Re: Code anntotations (copyright, autor, etc) in your code

2009-03-26 Thread andrew cooke
mattia wrote: > Hi all, which are the usual comments that you put at the beginning of your code to explain e.g. the author, the usage, the license etc? the GPL has guidelines at http://www.fsf.org/licensing/licenses/gpl-howto.html andrew -- http://mail.python.org/mailman/listinfo/pytho

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

2009-03-26 Thread Paul McGuire
On Mar 26, 2:51 pm, "R. David Murray" wrote: > 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

Re: Calendar module: HTMLCalendar overrides style sheet settings

2009-03-26 Thread Terry Reedy
Sibylle Koczian wrote: 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

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

2009-03-26 Thread Grant Edwards
On 2009-03-26, R. David Murray wrote: > Tim Chase wrote: >>r = re.compile(r""" >> (\w+) >> \s*=\s*( >> "(?:[^"]*)" >> | >> [^,]+ >> ) >> """, re.VERBOSE) >>results = [ >> (m.group(1), m.group(2).strip('"')) >> for m in r.finditer(s) >> ] >

Re: Code anntotations (copyright, autor, etc) in your code

2009-03-26 Thread Tim Daneliuk
mattia wrote: > Hi all, which are the usual comments that you put at the beginning of > your code to explain e.g. the author, the usage, the license etc? > > I've found useful someting like: > #- > # Name:About.py

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

2009-03-26 Thread Paul . Scipione
Hi D'Arcy J.M. Cain, Thank you. I tried this and my list of 76,979 integers got reduced to a dictionary of 76,963 items, each item listing the integer value from the list, a comma, and a 1. I think what this is doing is finding all integers from my list that are unique (only one instance of i

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

2009-03-26 Thread R. David Murray
Tim Chase wrote: >r = re.compile(r""" > (\w+) > \s*=\s*( > "(?:[^"]*)" > | > [^,]+ > ) > """, re.VERBOSE) >results = [ > (m.group(1), m.group(2).strip('"')) > for m in r.finditer(s) > ] > > Things like internal quoting ('b="123\"456", c="1

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

2009-03-26 Thread andrew cooke
Peter Otten wrote: > I would be surprised by the behaviour of Andrew's variant: > def append(item, items=None): > ... items = items or [] > ... items.append(item) > ... return items > ... a = [] append("x", a) > ['x'] ah that's a good point. andrew -- http://mail.

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

2009-03-26 Thread Terry Reedy
If the order of node-entry into seen_nodes is never used (if particular, if 'node in seen_nodes' is its only usage), then seen_nodes could be a set and the 'in' operation would be O(1) instead of O(n). -- http://mail.python.org/mailman/listinfo/python-list

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

2009-03-26 Thread John Machin
On Mar 27, 6:51 am, "R. David Murray" wrote: > 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

Code anntotations (copyright, autor, etc) in your code

2009-03-26 Thread mattia
Hi all, which are the usual comments that you put at the beginning of your code to explain e.g. the author, the usage, the license etc? I've found useful someting like: #- # Name:About.py # Purpose: # # Author:

Re: imported module scitools not recognized

2009-03-26 Thread Terry Reedy
Robert Kern wrote: 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 autocompleti

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

2009-03-26 Thread Tim Chase
The challenge is to turn a string like this: a=1,b="0234,)#($)@", k="7" into this: [("a", "1"), ("b", "0234,)#($)#"), ("k", "7")] A couple solutions "work" for various pathological cases of input data: import re s = 'a=1,b="0234,)#($)@", k="7"' r = re.compile(r""" (?P\w+)

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

2009-03-26 Thread Paul Rubin
"D'Arcy J.M. Cain" writes: > icount = {} > for i in list_of_ints: > icount[i] = icount.get(i, 0) + 1 from collections import defaultdict icount = defaultdict(int) for i in list_of_ints: icount[i] += 1 -- http://mail.python.org/mailman/listinfo/python-list

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

2009-03-26 Thread D'Arcy J.M. Cain
On Thu, 26 Mar 2009 16:00:01 -0400 Albert Hopkins wrote: > > l = list() > > for i in xrange(8): > > l.append(randint(0,10)) > ^^^ > should have been: > l.append(randint(0,9)) Or even: l = [randint(0,9) for x in xrange(8)] -- D'Arcy J.M. Cain

Re: Introducing Python to others

2009-03-26 Thread Scott David Daniels
Mensanator wrote: On Mar 26, 11:42 am, "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 [2, 4] What would yo

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

2009-03-26 Thread Albert Hopkins
On Thu, 2009-03-26 at 15:54 -0400, Albert Hopkins wrote: [...] > $ cat test.py > from random import randint > > l = list() > for i in xrange(8): > l.append(randint(0,10)) ^^^ should have been: l.append(randint(0,9)) > > hist = dict() > for i in l: >

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

2009-03-26 Thread Albert Hopkins
On Thu, 2009-03-26 at 12:22 -0700, paul.scipi...@aps.com wrote: > 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 t

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

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.

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

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

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

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

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

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

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

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

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

  1   2   >