Alright, disregard this message. This appears to be easy enough with
the use structs.
Simply posted this in haste, sorry.
On Sun, Oct 28, 2012 at 10:52 AM, Robert Steckroth
<robertsteckroth(a)gmail.com> wrote:
> Hello Gang, I am asking that one of you can point me into the correct direction.
> I have a python module which has two objects with many methods and
> attributes in each.
> The two hypothetical objects are "house" and "tree".
> E.g. Used like below:
> import my_mod
> h = my_mod.house()
> t = my_mod.tree()
>
> They also contain attributes like:
> h.color
> t.height
>
>
> I would like to pass the t object to a house.attach() method
> e.g. h.attach(t)
> and modify the attributes of t within the house object methods. What
> is the best practice to reference separate objects in a module
> which are passed in at the interpreter? Any thoughts are appreciated
> as keywords and ideas
> are easy to Google.
>
> Thank you, Robert.
>
>
>
>
>
> --
> Bust0ut, Surgemcgee: Systems Engineer ---
> surgemcgee.com
> Django_Teamplate3d
--
Bust0ut, Surgemcgee: Systems Engineer ---
surgemcgee.com
Django_Teamplate3d
Hello Gang, I am asking that one of you can point me into the correct direction.
I have a python module which has two objects with many methods and
attributes in each.
The two hypothetical objects are "house" and "tree".
E.g. Used like below:
import my_mod
h = my_mod.house()
t = my_mod.tree()
They also contain attributes like:
h.color
t.height
I would like to pass the t object to a house.attach() method
e.g. h.attach(t)
and modify the attributes of t within the house object methods. What
is the best practice to reference separate objects in a module
which are passed in at the interpreter? Any thoughts are appreciated
as keywords and ideas
are easy to Google.
Thank you, Robert.
--
Bust0ut, Surgemcgee: Systems Engineer ---
surgemcgee.com
Django_Teamplate3d
Robert Steckroth, 27.10.2012 13:36:
> Hello Gang, I am fresh to this list so, hello gang!
I didn't know I was participating in a Gang. Maybe you meant someone else.
> I have the need for a universal setter function to set objects.
You are not very clear about what you want to achieve. What's "universal"
about that setter function? Could you give an example?
Stefan
Robert Steckroth, 27.10.2012 13:36:
> Hello Gang, I am fresh to this list so, hello gang!
I didn't know I was participating in a Gang. Maybe you meant someone else.
> I have the need for a universal setter function to set objects.
You are not very clear about what you want to achieve. What's "universal"
about that setter function? Could you give an example?
Stefan
Hello Gang, I am fresh to this list so, hello gang!
========================================
I have the need for a universal setter function to set objects.
The documentation suggests that there is a way to use a void pointer
to define object data for comparison. Unfortunately, there does not
seem to be any examples on how to do this.
This snippet only works with the `last` attribute of the object -->
static int
Noddy_setlast(Noddy *self, PyObject *value, void *closure)
{
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the last attribute");
return -1;
}
if (! PyString_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"The last attribute value must be a string");
return -1;
}
Py_DECREF(self->last);
Py_INCREF(value);
self->last = value;
return 0;
}
Is there any examples of a universal setter function for
`PyGetSetDef` that would check a attribute type with the 3 argument in
Noddy_setlast?
Thank you.
*From the docs* [http://docs.python.org/extending/newtypes.html]
> `The getter function is passed a Noddy object and a “closure”, which is void pointer. In this case, the closure is ignored. (The closure supports an advanced usage in which definition data is passed to the getter and setter. This could, for example, be used to allow a single set of getter and setter functions that decide the attribute to get or set based on data in the closure.)`
--
Bust0ut, Surgemcgee: Systems Engineer ---
surgemcgee.com
Django_Teamplate3d
I am trying to work with Apple Mountain Lion's install of Python 2.7. I
have a language interoperability tool, Babel
http://www.llnl.gov/CASC/components/, that used embedded Python when
other languages are calling Python (c.g., C++ calling Python). My
fundamental problem is that sys.path is not being initialized the same
when I dlopen(libpython2.7.dylib) and initialize Python compared with
how the sys.path is set when the Python executable is called directly.
This causes Python to fail to load the numpy module used by Babel.
bash-3.2$ /usr/bin/python2.7 -c "import sys; print sys.path; import
numpy" > /tmp/out1
bash-3.2$ /usr/bin/python -c "import sys; print sys.path; import numpy"
> /tmp/out2
bash-3.2$ cat /tmp/out1
['',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
'/Library/Python/2.7/site-packages']
bash-3.2$ diff /tmp/out1 /tmp/out2
bash-3.2$ ls -al /usr/bin/python2.7
lrwxr-xr-x 1 root wheel 75 Aug 23 11:10 /usr/bin/python2.7 ->
../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Presumably, this C program that uses dlopen(), Py_Initialize, and
Py_SimpleString should have exactly the same output.
/** foo.c */
#include <dlfcn.h>
#include <stdio.h>
int
main(int argc, char **argv)
{
// void *lptr =
dlopen("/System/Library/Frameworks/Python.framework/Python", RTLD_NOW |
RTLD_GLOBAL);
void *lptr =
dlopen("/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib",
RTLD_NOW | RTLD_GLOBAL);
if (lptr) {
void (*pyinit)(void) = dlsym(lptr, "Py_Initialize");
if (pyinit) {
int (*runSimple)(const char *);
(*pyinit)(); /* initialize Python */
runSimple = dlsym(lptr, "PyRun_SimpleString");
if (runSimple) {
(*runSimple)("import sys ; print sys.path; import numpy");
}
}
else {
fprintf(stderr, "Unable to locate Py_Initialize: %s\n", dlerror());
}
}
else {
fprintf(stderr, "Error loading Python shared library: %s\n",
dlerror());
}
}
bash-3.2$ gcc foo.c ; ./a.out
['/usr/lib/python27.zip', '/usr/lib/python2.7',
'/usr/lib/python2.7/plat-darwin', '/usr/lib/python2.7/plat-mac',
'/usr/lib/python2.7/plat-mac/lib-scriptpackages',
'/usr/Extras/lib/python', '/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload']
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named numpy
However as you see, it has a completely different sys.path. I can't seem
to find a way to get it to initialize Python with the same sys.path. It
seems like the libpython2.7.dylib is broken. I am at a loss on how to
fix this or even who to ask for help.
Regards,
Tom Epperly
On 19.10.2012 13:36, endeavor john wrote:
> Hello Team,
> While cross-compiling XBMC Apllication.The code is generated using Java.
> I am getting an error :PyByteArray_FromStringAndSize.is undefined, i
> understand that this api is defined in python2.6.
> But we are supposed to compile this with python-2.4 libraries.
>
> Can you please let us know what is the equivalent API in python 2.4.This is
> the Code which using the "PyByteArray_FromStringAndSize" API.
>
> static PyObject* xbmc_XBMCAddon_xbmc_RenderCapture_getImage(PyObject*
> self, PyObject *args, PyObject *kwds)
> {
> RenderCapture* rc =
> ((RenderCapture*)retrieveApiInstance((PyObject*)self,&PyXBMCAddon_xbmc_RenderCapture_Type,"getImage","XBMCAddon::xbmc::RenderCapture"));
> if (rc->GetUserState() != CAPTURESTATE_DONE)
> {
> PyErr_SetString(PyExc_SystemError, "illegal user state");
> return NULL;
> }
>
> ssize_t size = rc->getWidth() * rc->getHeight() * 4;
> return PyByteArray_FromStringAndSize((const char *)rc->GetPixels(), size);
> }
This depends a bit on what the library expects as input elsewhere and
whether the memory area allocation is being managed elsewhere or not.
You could use a PyBuffer_FromReadWriteMemory() or a PyString_FromStringAndSize()
with Python 2.4.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Oct 19 2012)
>>> Python Projects, Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2012-09-27: Released eGenix PyRun 1.1.0 ... http://egenix.com/go35
2012-09-26: Released mxODBC.Connect 2.0.1 ... http://egenix.com/go34
2012-09-25: Released mxODBC 3.2.1 ... http://egenix.com/go33
2012-10-23: Python Meeting Duesseldorf ... 4 days to go
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
http://www.egenix.com/company/contact/
Hello Team,
While cross-compiling XBMC Apllication.The code is generated using Java.
I am getting an error :PyByteArray_FromStringAndSize.is undefined, i
understand that this api is defined in python2.6.
But we are supposed to compile this with python-2.4 libraries.
Can you please let us know what is the equivalent API in python 2.4.This is
the Code which using the "PyByteArray_FromStringAndSize" API.
static PyObject* xbmc_XBMCAddon_xbmc_RenderCapture_getImage(PyObject*
self, PyObject *args, PyObject *kwds)
{
RenderCapture* rc =
((RenderCapture*)retrieveApiInstance((PyObject*)self,&PyXBMCAddon_xbmc_RenderCapture_Type,"getImage","XBMCAddon::xbmc::RenderCapture"));
if (rc->GetUserState() != CAPTURESTATE_DONE)
{
PyErr_SetString(PyExc_SystemError, "illegal user state");
return NULL;
}
ssize_t size = rc->getWidth() * rc->getHeight() * 4;
return PyByteArray_FromStringAndSize((const char *)rc->GetPixels(), size);
}
Thanks,
John
Hi list.
I have a situation where I make a PyObject_CallObject call on one thread, and then I watch for keyboard input on a separate thread.
When the user hits CTRL-C, this second thread will see it and needs to make it so that the callable being run on the first thread gets "stopped" with a KeyboardInterrupt exception
I tried calling Py_AddPendingCall() on the second thread, and passing it a pointer to a function foo.
My first attempt was to make foo call PyErr_SetInterrupt() and PyErr_CheckSignals().
Since this did not work, I rewrote foo to explicitly set the KeyboardInterrupt exception with PyErr_SetString() and returning -1
This worked in the sense that I saw the KeyboardInterrupt come out on screen as a traceback, but it did not stop the function from running.
Am I doing something wrong? Is there even a way to raise an exception "inside" a PyObject_CallObject without the callee doing anything?
It would be much preferable that the called python object did not have to do anything in order to be interruptible, but I would be willing to compromise on some simple "make me interruptible" pattern, provided it really is simple.
Thanks for any help.
Enrico Granata
✉ egranata@.com
✆ (408) 972-7683
My client top Silicon Valley Client is looking for someone who has
hands-on testing experience with Windows API Frameworks in both 32-bit and
64-bit environment plus scripting in Python.
The ideal candidate will have the following experience:
· Demonstrated experience and understanding of C Language. This
means you have recent experience with C/C++ programming experience
specific to Windows environments. The strength of your programming
knowledge and skills will be thoroughly examined.
· Demonstrated experience with testing Windows API Frameworks in an
enterprise environment.
· Thorough understanding of QA white box Testing methodologies. You
can demonstrate your ability to create unique test plans from scratch and
execute these test plans with minimal supervision and oversight.
· Demonstrated hands-on experience designing and creating automation
scripts for unit testing and above using common scripting languages
(Python, Perl, VB); Python is preferable.
· Demonstrated experience in owning testing in a fluid, fast paced
environment. You have the exceptional communication skills needed to
gather information from multiple stakeholders and suggest reasonable
priorities against constantly moving targets.
If you're interest is piqued, please shoot me an email with your resume
and the best day/time/contact number to reach you & I'll be sure to follow
up!
Thank You in advance for your time!
Juliette McIlroy
Lead Technical Recruiter
Albin Engineering Services Inc.
ph : 408-733-AESI (2374) x18
juliette.mcilroy(a)aesi.com
www.aesi.com