extending python with array functions
I want to make numerical functions that can be called from python. I am programming in pascal the last few decades so I had a look at "python for delphi" (P4D). The demo09 gives as example add(a,b) using integers and pyarg_parsetuple. That works! However, I cannot figure out what to do when a, b and the result are arrays (or matrices) of float (for i:=0 to high(a) do c[i]:=a[i]+b[i]; and then return c to python). Although from the ALGOL60 school and always tried to keep far from pointers, I might also understand advise in C. Please get me started e.g. by giving a simple example. Many thanks, Janwillem -- http://mail.python.org/mailman/listinfo/python-list
Re: extending python with array functions
Gabriel Genellina wrote: > En Tue, 05 Feb 2008 05:28:33 -0200, Marc 'BlackJack' Rintsch > <[EMAIL PROTECTED]> escribi�: > >> On Mon, 04 Feb 2008 20:56:02 -0200, Gabriel Genellina wrote: >> >>> - the array module http://docs.python.org/lib/module-array.html provides >>> homogeneuos arrays that may be more efficient for your application. >>> arrays >>> don't have a special API, you have to import the module and use its >>> functions the same as one would do in pure Python. >> >> There's one special thing about it: the `buffer_info()` method returns a >> tuple with the memory address and length (in items) of the current >> underlying buffer. Pretty useless information in Python but handy in >> extensions that can directly access the "raw" memory. > > Good to know! I didn't notice it the (only) time I had to use arrays > from C code. > Thanks for the advice. I think I will read the cstype stuff because it might mean that my calculation intensive functions (non-linear systems and Monte Carlo stuff) can be kept unchanged ans stay compatible with e.g. the Excel interfaces I have for them. My first attempt with sum(i,j) was successful but sum(x,y) (FORTRAN typecast thinking) needs apparently understanding ctypes. Janwillem -- http://mail.python.org/mailman/listinfo/python-list
wxpython file dialog
Is there a way to force the wx.FileDialog to show as default the thumbnails vie in stead of list view? thanks, janwillem -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython file dialog
Guilherme Polo wrote: > 2008/2/9, Janwillem <[EMAIL PROTECTED]>: >> Is there a way to force the wx.FileDialog to show as default the >> thumbnails vie in stead of list view? >> thanks, janwillem >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > You should be using wx.lib.imagebrowser.ImageDialog instead of > wx.FileDialog for that purpose. > > Thanks for the hint, very neat widget. However, it seems not to support multiple selection. My application selects from a series of low light photographs of the same subject the sharpest one (like BSS on Nikon Coolpix). So I need multiple selection and thumbnails. It works with wx.FileDialog style=FD_MULTIPLE but I have to select thumbnail view every time. Janwillem -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython file dialog
Guilherme Polo wrote: > 2008/2/10, Janwillem <[EMAIL PROTECTED]>: >> Guilherme Polo wrote: >> > 2008/2/9, Janwillem <[EMAIL PROTECTED]>: >> >>>> Is there a way to force the wx.FileDialog to show as default the >> >> thumbnails vie in stead of list view? >> >> thanks, janwillem >> >> >> >> -- >> >> http://mail.python.org/mailman/listinfo/python-list >> >> >> > >> >>> You should be using wx.lib.imagebrowser.ImageDialog instead of >> > wx.FileDialog for that purpose. >> > >> > >> >> Thanks for the hint, very neat widget. However, it seems not to support >> multiple selection. My application selects from a series of low light >> photographs of the same subject the sharpest one (like BSS on Nikon >> Coolpix). So I need multiple selection and thumbnails. It works with >> wx.FileDialog style=FD_MULTIPLE but I have to select thumbnail view >> every time. >> >> Janwillem >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > Unfortunately that is not possible with imagebrowser because it sets > the listbox for single selection in the code. A patch will fix this. > Now continuing on FileDialog.. I don't have the option to change to > thumbnail view here, I guess you are using Windows, so it is not > cross-platform. imagebrowser is cross-platform because it is all done > by wxPython. > The application is meant to become x-platform; prefarably linux osX and win. I use: dialog=wx.FileDialog(None,'Choose picture file',defDir,\ style=wx.OPEN | wx.FD_MULTIPLE,wildcard=wcard) and supposed that the wx dialog would work on linux. I did not yet test this because the app depends on a lib (dll) which I have not yet made to work in Linux (it's pascal and freepascal has a problem I have to dive into). -- http://mail.python.org/mailman/listinfo/python-list
mailbox multipart
I am trying to analyze mailboxes using an iterator: for key, message in mbox.iteritems(): When message is a simple mail message['date'] results the date. When, however, it is a multipart message this results in None. How can you full proof get the "date", "from" and "to" of of a multipart mail using python? Thanks janwillem -- http://mail.python.org/mailman/listinfo/python-list
Re: mailbox multipart
On Apr 14, 8:26 am, Tim Roberts wrote: > janwillem wrote: > > >I am trying to analyze mailboxes using an iterator: > > for key, message in mbox.iteritems(): > > >When message is a simple mail message['date'] results the date. > >When, however, it is a multipart message this results in None. How can > >you full proof get the "date", "from" and "to" of of a multipart mail > >using python? > > Perhaps you should post your code. There's no particular reason why you > should see this. The mailbox iterator should return the outer multipart > container, which has the headers. > -- > Tim Roberts, [email protected] > Providenza & Boekelheide, Inc. Thanks Tim, There you have a point, after I find it is a multipart message I dive into it recursively and so loose the outer header info. That was all. -- http://mail.python.org/mailman/listinfo/python-list
email and unicode
I have a script that extracts attachments from all emails in a mbox (largely based on http://code.activestate.com/recipes/302086-strip-attachments-from-an-email-message/; thanks ActiveState). It works fine until it encounters an attachment with a unicode file name (Ukrainian in my case). I cannot get working the line msg.set_payload(replace) which is line 39 in the activestate snippet. How can you get the unicode file name into the replace string of line 35 of the snippet: replace = ReplaceString % dict(content_type=ct, filename=fn, params=params) without getting this nasty error message about ascii encoding? -- http://mail.python.org/mailman/listinfo/python-list
