dict to boolean expression, how to?

2014-08-01 Thread Alex van der Spek
With a dict like so: cond = {'a': 1, 'b': 1, 'c': 1, 'A': 0, 'B', 0, 'C':0} how would you make a boolean expression like this: bool = (('a' == 1) ('A' == 0) | ('b' == 1) ('B' == 0) | ('c' == 1) ('C' == 0)) The fact that lowercase and uppercase keys are stringed

Re: dict to boolean expression, how to?

2014-08-01 Thread Alex van der Spek
On Fri, 01 Aug 2014 12:45:12 +, Alex van der Spek wrote: With a dict like so: cond = {'a': 1, 'b': 1, 'c': 1, 'A': 0, 'B', 0, 'C':0} how would you make a boolean expression like this: bool = (('a' == 1) ('A' == 0) | ('b' == 1) ('B' == 0) | ('c' == 1

ctypes: returning an array from a subroutine

2014-04-20 Thread Alex van der Spek
but leaves the outdat array unchanged. Obviously I haven't understood ctypes well enough. Returning arrays from FORTRAN I routinely do through a string_buffer. That works very well but did not work here at all. Any and all help welcome. Alex van der Spek -- https://mail.python.org/mailman

Re: ctypes: returning an array from a subroutine

2014-04-20 Thread Alex van der Spek
Many hours later I found a working solutions in ctypes: The below makes sense to me but I am still at a loss why the first solution did not work. Anybody willing to explain for my better understanding? Regards, Alex van der Spek _snns

Deep vs. shallow copy?

2014-03-12 Thread Alex van der Spek
works: with open(os.path.join('path', 'foo.txt', 'rb') as txt: reader = csv.reader(txt) data = [row + [year] for row in reader] However in this context I am baffled. If someone can explain what is going on here, I would be most grateful. Alex van der Spek -- https://mail.python.org

Re: Deep vs. shallow copy?

2014-03-12 Thread Alex van der Spek
On Wed, 12 Mar 2014 10:00:09 -0500, Zachary Ware wrote: On Wed, Mar 12, 2014 at 9:25 AM, Alex van der Spek zd...@xs4all.nl wrote: I think I understand the difference between deep vs. shallow copies but I was bitten by this: with open(os.path.join('path', 'foo.txt', 'rb') as txt

Re: Using SciPy in application

2013-04-24 Thread Alex van der Spek
have done that for a number of the dierckx routines. No problems at all. Hope this helps, Alex van der Spek On Wednesday, April 24, 2013 11:13:45 AM UTC+2, Roozbeh wrote: Hi all, I want to use spline interpolation function from SciPy in an application and at the same time, I don't want the end

logging time format millisecond precision decimalsign

2012-07-20 Thread Alex van der Spek
. Can I change the comma (,) into a period (.) and if so how? Thanks in advance, Alex van der Spek -- http://mail.python.org/mailman/listinfo/python-list

shutil ignore fails on passing a tuple?

2012-07-19 Thread Alex van der Spek
']) Why does it fail on passing in a tuple of ignore strings? I thought the , (comma) is pretty much the tuple constructor (if that is the right word). How can I solve this? Is there a way to convert a tuple of strings in a form that will be accepted? Thank you in advance, Alex van der

logging time format millisecond precision

2012-07-19 Thread Alex van der Spek
is a comma. Can I change the comma (,) into a period (.) and if so how? Thanks in advance, Alex van der Spek -- http://mail.python.org/mailman/listinfo/python-list

Re: Plot a function with matplotlib?

2012-05-19 Thread Alex van der Spek
On Sat, 19 May 2012 01:59:59 +, Steven D'Aprano wrote: I have matplotlib and iPython, and want to plot a function over an equally-spaced range of points. That is to say, I want to say something like this: plot(func, start, end) rather than generating the X and Y values by hand, and

Difference between tempfile and spooled tempfile?

2012-04-05 Thread Alex van der Spek
I do not understand why the spooled write gives an error. See below. The normal tempfile works just fine. They are supposed to behave equal? All insight you can provide is welcome. Alex van der Spek + Python 2.7.1 (r271:86832, Nov 27 2010, 18:30

WAVE file writing, confused about setsampwidth(n)

2011-11-24 Thread Alex van der Spek
I am confused about the Wave_write object setsampwidth(n). Is the sample width n the total sample width, i.e. for a stereo sample consisting of short (2 byte) integers; n=4 or is the sample width the number of bytes in either the left or the right channel? Regards, Alex van der Spek

xml tree writing with ElementTree; prepends elements with ns0

2011-10-11 Thread Alex van der Spek
When reading a tree and writing it back to a new file all the elements are prepended with the string ns0: Why is it prepended and how can I suppress this? Thanks, Alex van der Spek -- http://mail.python.org/mailman/listinfo/python-list

Numpy.array with dtype works on list of tuples not on list of lists?

2011-09-18 Thread Alex van der Spek
=[(1,2,3),(4,5,6)] arr=numpy.array(dat,dtype=col) arr array([(1.0, 2.0, 3.0), (4.0, 5.0, 6.0)], dtype=[('a', 'f4'), ('b', 'f4'), ('c', 'f4')]) The only difference that the object is a list of tuples now? Thanks for clarification, Alex van der Spek -- http://mail.python.org/mailman/listinfo

HDF5 tree walker

2011-09-06 Thread Alex van der Spek
Is there an equivalent to os.path.walk() for HDF5 file trees accessed through h5py? Thanks! Alex van der Spek -- http://mail.python.org/mailman/listinfo/python-list

Text file with mixed end-of-line terminations

2011-08-31 Thread Alex van der Spek
. I use the standard binaries as distributed. Thanks in advance, Alex van der Spek -- http://mail.python.org/mailman/listinfo/python-list

Multiple file select with tkFileDialog passes back 'decorated' strings (sometimes)

2011-05-23 Thread Alex van der Spek
across platforms (I use Python 2.7 on Win Vista)? See code below. Thanks for the insight! Alex van der Spek +++ from Tkinter import * import tkFileDialog as tkf tkroot=Tk() tkroot.withdraw() initdir=os.environ['HOME'] filetype=[('Binary Timeseries','*.bin'),('All files

Tkinter FileDialog

2011-05-22 Thread Alex van der Spek
not appear to be a way to multiselect files? I am probably missing a whole lot. Please point me to a simple example of GUI file manipulations. I can save myself with os.path.walk and os.listdir but the users I try to serve cannot. Regards, Alex van der Spek -- http://mail.python.org/mailman

Appending to dictionary of lists

2011-05-03 Thread Alex van der Spek
(): refd[k].append(v) I do not understand why this appends v to every key k each time. Thanks in advance for any tips you can pass on. Alex van der Spek -- http://mail.python.org/mailman/listinfo/python-list

Re: Appending to dictionary of lists

2011-05-03 Thread Alex van der Spek
Thank you! Would never have found that by myself. Paul Rubin no.email@nospam.invalid wrote in message news:7x7ha75zib@ruckus.brouhaha.com... Alex van der Spek zd...@xs4all.nl writes: refd=dict.fromkeys(csvr.fieldnames,[]) ... I do not understand why this appends v to every key k each

Sending keystrokes to Windows exe programs

2011-04-02 Thread Alex van der Spek
. dva.terminate() however does work fine and kills the program as it should. Is there a way or do I have to go back to Visual Basic? Regards, Alex van der Spek -- http://mail.python.org/mailman/listinfo/python-list

Calling FORTAN dll functions from Python

2010-12-07 Thread Alex van der Spek
in Python. The fact that I still use and can use FORTRAN gives away my age. Mixed language programming is not an issue for me (C/VB, VB/FORTRAN, C/FORTRAN) but Python is new. Just pointing me to relevant documentation would be helpful in its own right. Thank you in advance, Alex van der Spek

Re: EOFError with fileinput

2010-08-17 Thread Alex van der Spek
Thanks all! I understand better now. I had no idea that EOFError was an exception. I was looking for a function to tell me when the end of a sequential file is reached as in all of the 4 programming languages that I do know this is a requirement. Will modify my program accordingly. Alex van

Re: Opposite of split

2010-08-16 Thread Alex van der Spek
. If there is, I won't meet it for a while. Alex van der Spek D'Arcy J.M. Cain da...@druid.net wrote in message news:mailman.2159.1281917130.1673.python-l...@python.org... On 15 Aug 2010 23:33:10 GMT Steven D'Aprano st...@remove-this-cybersource.com.au wrote: Under what possible circumstances would you

EOFError with fileinput

2010-08-16 Thread Alex van der Spek
van der Spek -- http://mail.python.org/mailman/listinfo/python-list

Re: Opposite of split

2010-08-16 Thread Alex van der Spek
? Regards, Alex van der Spek D'Arcy J.M. Cain da...@druid.net wrote in message news:mailman.2159.1281917130.1673.python-l...@python.org... On 15 Aug 2010 23:33:10 GMT Steven D'Aprano st...@remove-this-cybersource.com.au wrote: Under what possible circumstances would you prefer this code

Re: EOFError with fileinput

2010-08-16 Thread Alex van der Spek
fileinput.nextfile() fn+=1 print fileinput.filename().rsplit('\\',1)[1] fileinput.close() +++ Regards, Alex van der Spek Alex van der Spek zd...@xs4all.nl wrote in message news:4c696751$0$22940

Opposite of split

2010-08-15 Thread Alex van der Spek
Looking for a method that does the opposite of 'split', i.e. elements in a list are automatically concatenated with a user selectable spacer in between e.g. '\t'. This is to prepare lines to be written to a sequential file by 'write'. All hints welcome. Regards, Alex van der Spek -- http

IDLE/Python on Asus EEE PC

2009-01-25 Thread Alex van der Spek
repositories. Thanks in advance, Alex van der Spek -- http://mail.python.org/mailman/listinfo/python-list

eval('07') works, eval('08') fails, why?

2009-01-08 Thread Alex van der Spek
. Please keep it simple Thanks in advance, Alex van der Spek -- http://mail.python.org/mailman/listinfo/python-list

Reading C# serialized objects into Python?

2009-01-08 Thread Alex van der Spek
Is there a way to read C# serialized objects into Python? I know the definition and structure of the C# objects. The Python docs say that pickle is specific to Python, which does not give me much hope. There may be a library however that I haven't come across yet. Thanks much, Alex van der

Re: eval('07') works, eval('08') fails, why?

2009-01-08 Thread Alex van der Spek
Thanks much, that makes sense! Alex van der Spek -- http://mail.python.org/mailman/listinfo/python-list