× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Wed, Feb 6, 2013 at 1:55 PM, Buck Calabro <kc2hiz@xxxxxxxxx> wrote:
I'm not a Python programmer as much as a Python dabbler.

Nothing wrong with dabbling. Python is one of the easier languages to
be productive with at the dabble level. Dabble long enough and before
you know it, you're an intermediate Python programmer. ;)

I recently discovered named tuples
http://docs.python.org/2/library/collections.html and it seems that this
is the way to emulate the C structs that various IBM APIs return data
with. It doesn't matter to me that they're immutable, as I'm going to
want to read them, not update them.

When you need to work with C structs, what you want in Python is the
struct module:

http://docs.python.org/2/library/struct.html

This module lets you pack Python values into a struct or unpack a
struct into a tuple of Python values. (If you like, you can then use
this tuple to build a named tuple.)

Traversing the list of columns
returned (QUSLFLD) seems harder to me though. I so want to use
pointers! Not looking for code, just musing aloud. No time to try it
now though :-(

For the particular case of QUSLFLD, the main problem is that the
results are not in the parameters but in a user space. (Disclosure:
I have never personally used this API, and am going by the Web docs.)
Unfortunately, iSeries Python doesn't have a convenient way of
accessing user spaces, that I know of. Someone had built one for an
older version of Python, running on V5R2, using various APIs; but
predictably, this can't be used for today's Python on today's i.

Right now, iSeries Python really needs data to be passed around in
parameters, files (database or IFS), or data areas. So your original
thought of an RPG wrapper/helper might not have been too far off the
mark after all.

For the very specific case of getting buffer lengths for fields, well,
that's already built into iSeries Python's File400 class, so no need
for QUSLFLD or DSPFFD or anything else. Example (not that you were
asking):

f = File400('MYFILE', lib='MYLIB')
for field in f.fieldList():
print field, f.fieldSize(field)

That will print out a list of all the fields in MYLIB/MYFILE, along
with their buffer sizes.

John

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.