pos = position.GetPosition()
print "xpos = " + str(pos.x) + " ypos = " + str(pos.y) + " zpos = " + str(pos.z)
Here's what I get in return:
AP Node Locations:
<ns3.Node object at 0xb6c9924c>
True
Traceback (most recent call last):
File "scratch/fifth.py", line 165, in <module>
main(sys.argv)
File "scratch/fifth.py", line 130, in main
PrintLocations(wifiApNodes, "AP Node Locations:")
File "scratch/fifth.py", line 15, in PrintLocations
pos = position.GetPosition()
AttributeError: 'bool' object has no attribute 'GetPosition'
Command ['/usr/bin/python', 'scratch/fifth.py'] exited with code 1
Thanks,
AWH
> 1. How did you know this in the first place? Maybe this sounds dumb,
> but I can't find any kind of API that would specify how my Python
> syntax should be arranged. So far I've just been going on "hunches"
> by looking at equivalent C++ code until it does what I want it to do.
I don't think we have documented anywhere the python API. For the most
part, it's just like the c++ API, except where c++ templates are
present.
>
> 2. I have another C++ to Python question:
>
> Here's my C++ code:
>
> std::ostringstream oss;
> oss <<
> "/NodeList/" << wifiStaNodes.Get (nSta - 1)->GetId() <<
> "/$ns3::MobilityModel/CourseChange";
>
> Config::Connect (oss.str (), MakeCallback (&CourseChange));
>
>
> And this is my attempt at the corresponding Python code which of
> course, doesn't work :-)
>
> context = "/NodeList/" + str(wifiStaNodes.Get(0).GetId()) +
> "/$ns3::MobilityModel/CourseChange"
> model = wifiStaNodes.Get(0).GetObject(ns3.MobilityModel.GetTypeId())
> ns3.Config.Connect(context, ns3.CallbackBase(CourseChange))
>
Another case of c++ templates in the python api. tracing + callbacks
does not work yet in python.
Mathieu
So without tracing and callbacks, is there any way to confirm that a particular Python script is doing the exact same thing as its C++ counterpart? If not, then maybe it's better just to stick with using C++?
Yes, it would be slow but it's a bug that we don't support it, right ?
On Mon, 2009-08-03 at 14:50 +0100, Gustavo Carneiro wrote:
>
>
> 2009/8/3 Andrew Hallagan <andrewh...@gmail.com>
> So without tracing and callbacks, is there any way to confirm
> that a particular Python script is doing the exact same thing
> as its C++ counterpart? If not, then maybe it's better just
> to stick with using C++?
>
> In any case, callback based tracing would be slow in Python. The