[Tutor] Question regarding xml.dom.minidom: How do you send an unsignedByte in an wsdl request
Howdy all, Hope this message finds everyone well - roll on the weekend! I'm trying some calls to an wsdl API I've subscribed to. But I'm struggling to know what they want when sending an unsignedByte in a request. I'm using xml.dom.minidom so to start with I have: from xml.dom.minidom import Document, parseString import httplib, urlparse And later on I create a doc with: doc=Document() And I have a using a little helper to add a text element: def add_text_element(doc, parent, name, value): element=doc.createElement(name) element.appendChild(doc.createTextNode(str(value))) parent.appendChild(element) Should I have a separate class for an unsignedByte? i.e. def add_byte_element What should it look like? This is what their API helpdesk have said: "In this instance, the PriceFormat is defined as an unsignedByte. ** * * **" Many thanks! Cheers, Garry ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Question regarding xml.dom.minidom: How do you send an unsignedByte in an wsdl request
You'll likely get more traction on this at http://mail.python.org/mailman/listinfo/xml-sig Emile On 7/22/2011 11:18 AM Garry Bettle said... Howdy all, Hope this message finds everyone well - roll on the weekend! I'm trying some calls to an wsdl API I've subscribed to. But I'm struggling to know what they want when sending an unsignedByte in a request. I'm using xml.dom.minidom so to start with I have: from xml.dom.minidom import Document, parseString import httplib, urlparse And later on I create a doc with: doc=Document() And I have a using a little helper to add a text element: def add_text_element(doc, parent, name, value): element=doc.createElement(name) element.appendChild(doc.createTextNode(str(value))) parent.appendChild(element) Should I have a separate class for an unsignedByte? i.e. def add_byte_element What should it look like? This is what their API helpdesk have said: "In this instance, the PriceFormat is defined as an unsignedByte. // / / //" Many thanks! Cheers, Garry ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Question regarding xml.dom.minidom: How do you send an unsignedByte in an wsdl request
On Fri, Jul 22, 2011 at 2:18 PM, Garry Bettle wrote: > Howdy all, > > Hope this message finds everyone well - roll on the weekend! > > I'm trying some calls to an wsdl API I've subscribed to. > > But I'm struggling to know what they want when sending an unsignedByte in a > request. > > I'm using xml.dom.minidom so to start with I have: > from xml.dom.minidom import Document, parseString > import httplib, urlparse > > And later on I create a doc with: > doc=Document() > > And I have a using a little helper to add a text element: > def add_text_element(doc, parent, name, value): > element=doc.createElement(name) > element.appendChild(doc.createTextNode(str(value))) > parent.appendChild(element) > > Should I have a separate class for an unsignedByte? i.e. def > add_byte_element > > What should it look like? > > This is what their API helpdesk have said: > > "In this instance, the PriceFormat is defined as an unsignedByte. > > > > ** > > * * > > **" > > Many thanks! > > Cheers, > > Garry > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > this, *type=**xs:**unsignedByte*, is an attribute. I'm assuming "doc" above is an instance of class Document, so you can get the element by using doc.getElementsByTagName('complexType') or whatever it is you are talking about for the element. That will return an Element instance, and from there you can go haywire adding attributes. The Element class has a method called "setAttribute('string')". You would do this right here: element=doc.createElement(name) <-- wave <--- element.setAttribute('string') <-- your argument here element.appendChild(doc.createTextNode(str(value))) parent.appendChild(element) The node from your example has two attributes, and not one. I'm not sure how important this is for you. Anyway, that's my answer. I'm a newb though, and even more of a newb with XML. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Question regarding xml.dom.minidom: How do you send an unsignedByte in an wsdl request
Emile van Sebille, 22.07.2011 20:59: You'll likely get more traction on this at http://mail.python.org/mailman/listinfo/xml-sig Unlikely. Stefan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Question regarding xml.dom.minidom: How do you send an unsignedByte in an wsdl request
Garry Bettle, 22.07.2011 20:18: I'm trying some calls to an wsdl API I've subscribed to. You might find this interesting: http://effbot.org/zone/element-soap.htm But I'm struggling to know what they want when sending an unsignedByte in a request. That's just a number, plain old-fashioned decimal digits. ** * * **" In ElementTree, that's just request_element = Element("request_tag_name_here", PriceFormat="123") Stefan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Question regarding xml.dom.minidom: How do you send an unsignedByte in an wsdl request
On 7/22/2011 12:09 PM Stefan Behnel said... Emile van Sebille, 22.07.2011 20:59: You'll likely get more traction on this at http://mail.python.org/mailman/listinfo/xml-sig Unlikely. Wow. Agreed. Five unanswered posts this year. Emile ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] OT: Drag and Drop GUI IDE ideas
Rance Hall wrote: We want the students to develop a small app in the process, It could be a firefox extension, mobile phone app, or any other type simple structure. ou can develop very smpleAndoid apps witout any coding using a Googletoolit. I've only read an aticle aboutit so an't sy how cleveritgets or how easy itreallyis to use. The problermisthat building apps, especially GII apps is not an easy thing to do. The easiest environment is probably, and I hate to say it - Visual Basic! And there is a free version but you'd need to check the usage limits (I'm sure there will be some!) But you could use the Microsoft office VBA environbment instead - and thats a tool they will probably have in the real world... The catch is that the class is for non-programmers to try to get them introduced to the field. We would like to use a gui ide that can essentially hide the code from the programmer and connect widgets with the gui. We want them to be able to look at the code and analyze it. VB would allow that. Another option is The Apple Mac development tool XCode and the Apple GUI builder - free if you have MacOS X. It uses a graphical representation to connect code to widgets but it is less intuitive than the VB approach (but much more powerful!) You can read through the short Cocoa tutorial on the apple developer site to see it in action. Dabo might be an option for a Python solution but I findit a tad too data centric. But for business types that might not be a bad thing! HTH, Alan G ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Don't understand this class/constructor call syntax
Hello, I'm trying to work on GNU Radio and having trouble understanding some of the Python code. I have a C/C++ coding background. I'm looking at the ieee802.15.4 code found on CGRAN. It's about 4 years old and runs but doesn't function anymore so I'm trying to fully understand it to fix it. In one file (a file in src/example called cc2420_txtest.py) I have the following line from a constructor for: class transmit_path(gr.top_block) ... ... ... self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts(self, spb=self._spb, msgq_limit=2) Now in the src/python directory for this project I have ieee802_15_4pkt.py which has the following class: class ieee802_15_4_mod_pkts(gr.hier_block2): """ IEEE 802.15.4 modulator that is a GNU Radio source. Send packets by calling send_pkt """ def __init__(self, pad_for_usrp=True, *args, **kwargs):[/code] What I don't understand is the call to the constructor and the constructor definition. Since it's using a number of advanced features, I'm having trouble looking it all up in documentation. What does it mean to call with spb=self._spb? In the example file, spb is set = to 2 and so is self._spb. Is it a sort of pass by reference like C while also assigning a value? Why the ** on kwargs then? as if it is a matrix (and does anyone have any idea what kwargs are (as opposed to args)?) I'm uncertain about the first argument, but I guess it must be the transmit_path object passed in place of the usually implicit self... I'm just not sure how Python figures out that it's not pad_for_usrp... magic I guess! Thanks for your help, Dave ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Don't understand this class/constructor call syntax
On 07/22/2011 06:40 PM, dave wrote: Hello, I'm trying to work on GNU Radio and having trouble understanding some of the Python code. I have a C/C++ coding background. I'm looking at the ieee802.15.4 code found on CGRAN. It's about 4 years old and runs but doesn't function anymore so I'm trying to fully understand it to fix it. In one file (a file in src/example called cc2420_txtest.py) I have the following line from a constructor for: class transmit_path(gr.top_block) ... ... ... self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts(self, spb=self._spb, msgq_limit=2) Now in the src/python directory for this project I have ieee802_15_4pkt.py which has the following class: class ieee802_15_4_mod_pkts(gr.hier_block2): """ IEEE 802.15.4 modulator that is a GNU Radio source. Send packets by calling send_pkt """ def __init__(self, pad_for_usrp=True, *args, **kwargs):[/code] What I don't understand is the call to the constructor and the constructor definition. Since it's using a number of advanced features, I'm having trouble looking it all up in documentation. What does it mean to call with spb=self._spb? In the example file, spb is set = to 2 and so is self._spb. Is it a sort of pass by reference like C while also assigning a value? Why the ** on kwargs then? as if it is a matrix (and does anyone have any idea what kwargs are (as opposed to args)?) I'm uncertain about the first argument, but I guess it must be the transmit_path object passed in place of the usually implicit self... I'm just not sure how Python figures out that it's not pad_for_usrp... magic I guess! There are many different things in your question, and I don't know if I can hit them all in my reply, but I'll see what I can do. The '=' syntax means an entirely different thing in the call from what it means in the definition of a function. And the * and ** syntax are special, although there at least there's a relationship between what they mean in the two locations. Let's just address these 4 cases outside of a class, and defer your class questions to when you can post enough code to see all the pieces (you don't show method ieee802_15_4_mod_pkts, but it's probably got a @class decorator in front of it, which changes the 'self' convention to a 'cls' one) When a function definition uses an "=" in it, it's setting a default argument. So if I define a function: def test(a, b=24): print a+b it can be called with either one argument or with two, and if one argument, the value b is implicitly passed. This is similar to C++, except that the default value is initialized at the definition site, and at the time the definition is done. So if the value is mutable, the same value may be used for multiple calls to the same function. If a function call is made using a similar syntax, it refers to a keyword argument. By default arguments are positional, meaning that they have to be given in the right order, with no gaps. A keyword argument allows you to specify parameters out of order, and by name. It's most useful when there is a function with lots of arguments, most of which you're happy with the default values. To make a trivial example: def test2(a, b=2, c=3, d=4): print a,b,c,d test2(12, d=99) will print 12 2 3 99 Sometimes you want to pass a lot of arguments without spelling them out in your call. So if the values are in a list, and in the right order, you can do something like: myargs = [3, 99, 12, 44] test2(*args) You can also use a dictionary, like: mykwargs = { "a":3, "d":44, "b":99, "c":12} test2(**args) And there's a lot of symmetry when defining a function with those same similarities: def test3(*args, **kwargs): x here args will be a list() with the positional arguments, while kwargs will be a dict() with the keyword ones. Now these features can be mixed in lots of ways, but that's way too much for a single message. (All code above is untested; please forgive any typos) -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] OT: Drag and Drop GUI IDE ideas
Hi Rance, On 21 July 2011 23:17, Rance Hall wrote: > The MIS department at UNK is looking to create a course in business > app development. > > The course will be about the app life cycle and discuss problem > statement, testing, maintenance and disposal/decommissioning, etc. > > We want the students to develop a small app in the process, It could > be a firefox extension, mobile phone app, or any other type simple > structure. > Does it have to involve mobile platforms etc or can it be a more conventional MIS PC application? And, are you really after some sort of RAD environment where you can build the GUI by dragging and dropping widgets, and have it generate the tie-up of event handlers to your program code? If so, I'd have suggested Embarcadero Delphi (which uses Object Pascal as the language) rather than VB, but that is commercial. As an alternative sticking with the Delphi/Pascalish theme, you might consider is the Lazarus project. It is a Free software implementation that mimics Delphi and uses Free Pascal as the language. It attempts to be as compatible as possible with Delphi but unlike Delphi also has the benefit of being natively cross platform -- applications written in Lazarus will compile unmodified on either Windows or Linux (or any other platform it's available on, e.g. Mac) It does have a GUI designer allowing you drag and drop controls onto the form, attach event handlers and so on, and then view the code behind the form (F12) etc. The IDE has syntax highlighting and the core of the usual things seen in IDE's these days (code completion, context sensitive help etc.) Continuing in this theme, a possible third option to consider would be "Boa Constructor". It is a RAD'ish IDE environment for Python and WxWidgets, styled on the Delphi IDE. It again allows you to design forms visually while the IDE generates the boilerplate application code and wires up widgets to events and so on. I'm however unsure how actively maintained the Boa project is currently -- the last update seems to be circa 2007. Hoping that is useful, Walter ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Don't understand this class/constructor call syntax
dave wrote: class transmit_path(gr.top_block) [...] self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts(self, spb=self._spb, msgq_limit=2) This calls the ieee802_15_4_mod_pkts initializer (not a constructor -- see below) with one positional argument and two keyword arguments. The positional argument is "self", that is, the transmit_path instance. The keyword arguments are called spb and msgq_limit; spb is set to the value of self._spb, and msgq_limit is set to 2. The reason I say this is an initializer and not a constructor is that Python treats the two as different. The constructor that creates the instance is called __new__ not __init__. When __init__ is called, the instance has already been constructed, and is now being initialized. The reason for this is mostly historical, although it is useful. (Disclaimer -- so called "old style" or "classic" classes don't have a __new__ method, and you cannot customize the actual creation of the instance, only the initialization.) Looking at the ieee802_15_4_mod_pkts initializer: class ieee802_15_4_mod_pkts(gr.hier_block2): def __init__(self, pad_for_usrp=True, *args, **kwargs):[/code] As a method, this takes the instance as first argument (called "self"), plus one named argument "pad_for_usrp", an arbitrary number of unnamed positional arguments collected into "args", and an arbitrary number of named keyword arguments collected into "kwargs". (Note that args and kwargs are conventions. You could call them anything you like -- the "magic", so to speak, comes from the leading * and ** and not from the names.) Given the call: ieee802_15_4_mod_pkts(self, spb=self._spb, msgq_limit=2) this corresponds to the initializer receiving arguments: self = the freshly created ieee802_15_4_mod_pkts instance pad_for_usrp = the transmit_path instance doing the calling args = an empty tuple (no positional arguments collect) kwargs = a dictionary of keyword arguments {'spb': value of _spb of the transmit_path instance, 'msgq_limit': 2} What I don't understand is the call to the constructor and the constructor definition. Since it's using a number of advanced features, I'm having trouble looking it all up in documentation. What does it mean to call with spb=self._spb? In the example file, spb is set = to 2 and so is self._spb. Is it a sort of pass by reference like C while also assigning a value? Why the ** on kwargs then? as if it is a matrix No, this is nothing to do with pass by reference, or pass by value either. This often confuses people coming to Python from some other languages, and if it isn't a FAQ it ought to be. You can read one of my posts on this here: http://www.mail-archive.com/tutor%40python.org/msg46612.html and the Wikipedia article: http://en.wikipedia.org/wiki/Evaluation_strategy What it means is that the method being called (in this case, ieee802_15_4_mod_pkts.__init__) sees a keyword argument called "spb". This keyword argument has name "spb", and value whatever self._spb has at the time it is called. When Python allocates arguments to the named parameters in a method or function, its basic process is roughly something like this: (1) for methods, automatically assign the instance being called to the first named parameter (usually called "self" by convention); (2) take each positional argument from the caller and assign it to the remaining positional parameters, from left to right; (3) assign any keyword arguments, raising an error if it duplicates a value already seen; (4) raise an error if any unassigned parameter doesn't have a default value; (5) collect any left over positional arguments into the *args parameter; (6) collect any left over keyword arguments into the **kwargs parameter. (and does anyone have any idea what kwargs are (as opposed to args)?) Positional arguments: function(1, 2) Keyword arguments: function(a=1, b=2) I'm uncertain about the first argument, but I guess it must be the transmit_path object passed in place of the usually implicit self... I'm just not sure how Python figures out that it's not pad_for_usrp... magic I guess! I don't think that it is used as the implicit self. I think it is the pad_for_usrp. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor