his
clears up any confusion my Simple MAPI example may have caused regarding
ctypes pointers.
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
glbs = dict(globals())
>>> for id in cd.co_names:
glbs[id] = 'K' + id
>>> exec cd in glbs
Kx Ky Kz
Special names can be used only as constants. It is better suited
for eval() than exec.
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
Steven Bethard <[EMAIL PROTECTED]> writes:
> Brian Beck wrote:
> > http://exogen.cwru.edu/python2.png
>
> Oooh, I like this one. Very cool!
>
Its visually stunning. But under Windows gears show up in the DLL
and batch file icons.
Lenard Lindstrom
<[EMAIL PROTECTED]&
now I don't care any more whether you use a Python, some other snake,
a foot or 16-ton weight, or a wood rat as a logo for Python!
Of course any official logo would likely require a PEP and the BDFL's
endorcement. But before that it might be an idea to see if it becomes
popular as a de
sistence I can try writing an example that does
it automatically using the atexit module and a history file.
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
Steven Bethard <[EMAIL PROTECTED]> writes:
> Lenard Lindstrom wrote:
> > Steven Bethard <[EMAIL PROTECTED]> writes:
> >
> >>Brian Beck wrote:
> >>
> >>>http://exogen.cwru.edu/python2.png
> >>
> >>Oooh, I like this one. Ve
. I have also not tried using Simple Mapi
under Python, only VC++. But a quick test shows I can access
MAPI32.DLL use the ctypes package:
import ctypes
mapi = ctypes.windll.mapi32
MAPILogon = mapi.MAPILogon
...
It is messy though.
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
byref(msg), 0, 0)
if rc != SUCCESS_SUCCESS:
raise WindowsError, "MAPI error %i" % rc
= Example usage =
import SimpleMAPI
SimpleMAPI.SendMail("[EMAIL PROTECTED]",
"The subject line"
"This is the message content.\n")
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] writes:
> Hi Lenard,
> Absolutely fantastic!!
> That worked like a charm.
> Now onto adapting it to send attachments.
>
Glad to be of help.
Lenard Lindstrom
--
http://mail.python.org/mailman/listinfo/python-list
lpFiles))
Replace "cast(NULL, lpFiles)" with "lpFiles".
>
>
> rc = MAPISendMail(0, 0, byref(msg), 0, 0)
> if rc != SUCCESS_SUCCESS:
> raise WindowsError, "MAPI error %i" % rc
And that is it.
The "cast(NULL, lpFiles)" was a way of assigning a null value to
the lpFiles member of the MapiMessage structure. Using None did
not work. But recasting a c_void_p(None) did.
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
> # No attachments
> lpFiles = cast(NULL, lpMapiFileDesc) # Make NULL
>
> print "nFileCount ",nFileCount
>
>
> recip = MapiRecipDesc(0, MAPI_TO, None, recipient, 0, None)
> #msg = MapiMessage(0, subject, body, None, None, None, 0,
> # cast(NULL, lpMapiRecipDesc), 1, pointer(recip),
> # nFileCount, cast(NULL, lpMapiFileDesc))
> msg = MapiMessage(0, subject, body, None, None, None, 0,
> cast(NULL, lpMapiRecipDesc), 1, pointer(recip),
> nFileCount, lpFiles)
>
>
> rc = MAPISendMail(0, 0, byref(msg), 0, 0)
> if rc != SUCCESS_SUCCESS:
> raise WindowsError, "MAPI error %i" % rc
>
> --
>
> Thanks again for your help so far on this. I really appreciate it!
> Have a safe and very merry Christmas.
>
And the same to you.
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
in zip(fda, attach):
> fd.ulReserved = 0
> fd.flFlags = 0
> fd.nPosition = -1
> fd.lpszPathName = fa
> fd.lpszFileName = None
> fd.lpFileType = None
> lpFiles = fda
> else:
> # No attachments
> lpFiles = cast(NULL, lpMapiFileDesc) # Make NULL
>
> # Get the num
s.update3=module_pyrex.pyrex_update_within_class
#
InstanceMethod is minimal. Additions may be to make the fn attribute
readable and a __call__ method that calls fn directly.
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
methods.
Back to "magic names". Python is a consistent language. What may be
special cased - "magic" - in another language is handled normally with
Python's general purpose dynamic type system. In fact I can think of
only one name I would call "magic": __fut
Steven D'Aprano wrote:
> On Mon, 04 Jun 2007 22:19:35 +, Lenard Lindstrom wrote:
>
>> What is "magic" about __init__ and __repr__? They are identifiers just
>> like "foo" or "JustAnotherClass". They have no special meaning to the
Steven D'Aprano wrote:
> On Tue, 05 Jun 2007 18:08:31 +, Lenard Lindstrom wrote:
>
>> Steven D'Aprano wrote:
>>> On Mon, 04 Jun 2007 22:19:35 +, Lenard Lindstrom wrote:
>>>
>>>> What is "magic" about __init__ and __repr__? T
ot;, os.getlogin(), pointer(c),
> pointer(handle))
>
> if retval != 0:
> print "Couldn't start pam session"
> sys.exit(-1)
>
> retval = pam_authenticate(handle, 0)
> if retval == 21:
> print "Authentication information cannot be recovered"
> sys.exit(-1)
>
> print retval
>
If you are going to do any serious ctypes coding consider joining the
ctypes mailing list at sourceforge.net .
--
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
Chris AtLee wrote:
> On Jun 11, 6:01 pm, Lenard Lindstrom <[EMAIL PROTECTED]> wrote:
> [snip snip snip]
>>> if __name__ == "__main__":
>>> import getpass, os, sys
>>> @conv_func
>>> def my_conv(nMessages, messages, pResp
type instances also vary in
length, but since long has no length property trying to figure out the
size of a particular instance is harder. And types like list, map and
unicode keep pointers to blocks of memory allocated separately.
--
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
appens during attribute lookup is that
an object's class is asserted to be an instance of type. Class test2
immediately passes the test since its type is "type". But test1's type
is meta, so a function is called to check that meta is a subclass of
"type". This may be t
> (http://en.wikipedia.org/wiki/64-bit#64-bit_data_models ).
>
> Try
> python -c "import struct; print struct.calcsize('P')"
> instead. That calculates the size of a pointer.
>
How about:
tuple.__itemsize__
since each tuple item is a pointer.
--
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
ion of source code at
module import time. The bytecodehack.macro module lets one define what
amounts to inlined functions. IMO neither package represents a
productive macro system. And I could find no other attempts to take
Python macros beyond wishful thinking. So until some solid proposal for
Python macros is put on the table any discussion of their merits is
unproductive. I can suggest though that procedural macros are a natural
starting point given the runtime nature of class and function creation.
--
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
ID to 0. Apparently my assumption that it is always 0
was wrong. If that works I have a more flexible version of the module
which actually searches for the speak line fader id. It also has a
GetSpeakerVolume function.
---
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
ions, and there are
> implementations of Common Lisp with stack groups.
>
Those stack groups
http://common-lisp.net/project/bknr/static/lmman/fd-sg.xml
remind me of Python greenlets
http://cheeseshop.python.org/pypi/greenlet .
---
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
htt
ons", which are
> an understood notion in software engineering and by me when I write
> software.
>
So documenting an assumption is more effective than removing the
assumption using a with statement?
--
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
Douglas Alan wrote:
> Lenard Lindstrom <[EMAIL PROTECTED]> writes:
>
>> Douglas Alan wrote:
>
>>> [I]n Python, you can be 100% sure that your files
>>> will be closed in a timely manner without explicitly closing them, as
>>> long as you are safe i
Douglas Alan wrote:
> Lenard Lindstrom <[EMAIL PROTECTED]> writes:
>
>> Explicitly clear the exception? With sys.exc_clear?
>
> Yes. Is there a problem with that?
>
As long as nothing tries to re-raise the exception I doubt it breaks
anything:
>>>
)
l_struct = cast(l_res, POINTER( Struct_Password ) )
POINTER wants a ctypes type as an argument. Struct_Password() is a
Structure instance.
A better way to do it is define the return type for getspnam:
g_lib.getspnam.restype = POINTER( Struct_Password )
Now the function returns a structure pointer so the cast is unnecessary.
---
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
Douglas Alan wrote:
> Lenard Lindstrom <[EMAIL PROTECTED]> writes:
>
>>>> Explicitly clear the exception? With sys.exc_clear?
>
>>> Yes. Is there a problem with that?
>
>> As long as nothing tries to re-raise the exception I doubt it breaks
&
Douglas Alan wrote:
> Lenard Lindstrom <[EMAIL PROTECTED]> writes:
>
>>> You don't necessarily want a function that raises an exception to
>>> deallocate all of its resources before raising the exception, since
>>> you may want access to these r
Douglas Alan wrote:
> Lenard Lindstrom <[EMAIL PROTECTED]> writes:
>
>>> Or are you suggesting that early in __main__.main(), when I wish to
>>> debug something, I do something like:
>>>__builtins__.open = __builtins__.file = MyFile
>>> ?
Douglas Alan wrote:
> Lenard Lindstrom <[EMAIL PROTECTED]> writes:
>
>> But some things will make it into ISO Python.
>
> Is there a movement afoot of which I'm unaware to make an ISO standard
> for Python?
>
Not that I know of. But it would seem any la
gt;
> f = some_file()
> with f:
> f.write("a bunch of stuff")
> #insert code that assumes f is closed, but correctly this time
>
The with statement is designed to be safer. It contains an implicit
try/finally that lets the file close itself in case of an exception.
--
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
line_number += 1
if found:
print "Found at", line_number
else:
print "Not found"
# prints "Found at 2"
---
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
Hendrik van Rooyen wrote:
> "Lenard Lindstrom" <[EMAIL PROTECTED]> wrote:
>
>
>> Pascal has no break, continue or return. Eiffel doesn't even have a
>> goto. In such imperative languages boolean variables are used a lot.
>
> Thanks did no
class. The inspect module defines an isclass function as follows:
def isclass(object):
"""Return true if the object is a class.
Class objects provide these attributes:
__doc__ documentation string
__module__ name of module in which this class
was defined"""
return isinstance(object, types.ClassType) or \
hasattr(object, '__bases__')
---
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
27;m sure I'll eventually figure it out if I stare at the code hard
> enough, but would totally appreciate any help I can get :)
>
Just ask.
--
Lenard Lindstrom
<[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
logs.msdn.com/stephen_griffin/archive/2006/11/03/the-intentional-memory-leak.aspx
Hope this helps,
Lenard Lindstrom
--
http://mail.python.org/mailman/listinfo/python-list
; type and a way to deal with arrays of bytes,
> independent of the string operators.
>
>Efficient handling of lists of bytes would do it.
>
> John Nagle
array.array or ctypes.create_string_buffer.
Lenard Lindstrom
--
http://mail.python.org/mailman/listinfo/python-list
s not replaced with a generic wrapper
that will call the __pow__ method. Instead myint keeps the slot function
inherited from int. So myint may have a __pow__ method that adds, but it
is never called when doing a **.
Curiously C PyPy does what was expected:
>pypy-c.exe
Python 2.4.1 (pypy
8.0, 12.0]
>>> e1.value
0
>>> e2.value
0
I compile the SAMPLE example with mingw g77 3.4.5:
g77 -shared -o sample.dll sample.for
I had to take out the "INTENT(OUT)"s because g77 didn't like them. And
"SAMPLE" became "sample_" in the dll. Also note that argument passing to
Fortran subroutines is strictly pass-by-reference. Thus the ain pointer.
Lenard Lindstrom
--
http://mail.python.org/mailman/listinfo/python-list
Mangabasi wrote:
> A little bit of googling solved the problem. instead of
>
sample = cdll.sample_dll.SAMPLE
>
> I used
>
>
sample = windll.sample_dll.SAMPLE
>
> and now it seems to be working without error messages.
>
> Thanks a lot.
>
>
I remember someone on the ctypes mailing
erikcw wrote:
> Hi,
>
> I'm trying to build a SQL string
>
> sql = """INSERT INTO ag ('cid', 'ag', 'test') VALUES(%i, %s, %d)""",
> (cid, ag, self.data[parent][child]['results']['test'])
>
I am guessing you want the string formatting operator here:
sql = """...""" % (cid, ...)
The comma creat
43 matches
Mail list logo