[Tutor] What these Python user-defined functions do?

2016-05-21 Thread Max Jegers
Hi,

I started learning Python (v3.5) and was given some code samples to assist
in my studies. There are some things I could not figure out using Python
documentation or other online sources. I have experience with SQL
programming and some procedural programming, but little in terms of OOP.



I try to slice and dice a Python script that exports a shipment from ERP
system to a text file.

Shipment consists of a Header (H, one record) and Details (D, one or more
records).



Script first imports a library with a number of user-defined functions.
Then the script uses functions defined in library to do exporting to a text
file.

Here is the part of the library:


class View:

def __init__(self):

  self.handle = None

…

def order(self, n):

  return hostviewOrder(handle, self.handle, n)



def put(self, fieldName, value, verify=1):

  if verify == True:

 verify = 1

  elif verify == False:

 verify = 0

  return hostviewPut(handle, self.handle, fieldName, value,
verify)



def read(self):

  return hostviewRead(handle, self.handle)



def browse(self, filter="", ascending=1):

  if ascending == True:

 ascending = 1

  elif ascending == False:

 ascending = 0

  return hostviewBrowse(handle, self.handle, filter, ascending)



def fetch(self):

  return hostviewFetch(handle, self.handle)



Here is a part of the script I am trying to understand:

def ExportShipment():

 f = open("c:\\" + me.get("SHN") + ".txt", "w")

 h = View("Header", *1*)

 d = View("Details", *1*)

 h.*order*(1) # SHN

 h.*put*("SHN", me.get("SHN"), 1)

 h.*read*()

 f.write("H," + h.get("LOCATION") + "," + h.get("ADDR1") + "\n")

 d.*browse*("SHIUNIQ=" + "{:.0f}".format(h.get("SHIUNIQ")), 1)

 while (d.*fetch*() == 0):

 f.write("D," + d.get("ITEM") + "," +
"{:.0f}".format(d.get("QTYSHIPPED")) + "\n")

 f.close()



Export output looks like:

H,4,1234 Any Road

D,A2,1

D,B1,3


I understand what file operations do. However I can’t get what these
functions do:

*order(), put(), read(), browse(), fetch()*.


Function definitions in the library are of little help for now, as all
functions feature handle and self.handle in their returns; however I cannot
find out what handle and self.handle may mean in this context.



Please let me know if I should provide more info for my question to make
sense.



Thanks a lot!

--
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Newcomer with organizational questions

2016-05-26 Thread Max Jegers
Hi,


I am a newcomer who asked a first question here at Tutor. Soon I received a
very good answer from a tutor and put an effort to understand it. After
that I wrote a reply with a thank you and a follow-up question, only to
discover that I don’t see a way to send it.


I need to say I did not write to maillist forums before, only to forums
with Post button right there:).



I reread *tutor-**bounces* auto-response, then did some googling and
realized that I may need to subscribe. So I did on Sunday May 22, and the
webpage said: “*Your subscription request has been received, and will soon
be acted upon. Depending on the configuration of this mailing list, your
subscription request may have to be first confirmed by you via email, or
approved by the list moderator. If confirmation is required, you will soon
get a confirmation email which contains further instructions.*”

Main question: Should I wait more or I am missing something I need to do at
my end?

My purpose is to post a reply in a particular subject I initiated.



Please note that I did not receive anything from a tutor in my email other
than *tutor-bounces* auto-response. I use Gmail.



Other organizational questions:

-   -   May I attach a file to a message? Some Python libraries are
quite big (50 pages in my case), however it may be not difficult for an
expert to answer a question if he/she has a full library. At the same time,
it seems inconsiderate and impractical to paste 50 pages into a message.

-   -   Can I paste not in plain text – using fonts etc?

-   -   May I ask a follow-up question in the same thread, or should I
start a new one?

-   -   Is this ok to post a message that contains thank you only, or
these messages have to be deleted by moderators (like on stackoverflow.com?)

I believe first I was able to see a tutor’s response on external website:
https://code.activestate.com/lists/python-tutor/107992/  - and much later
on mail.python.org. Is this persistent behaviour?

Possibly, all this is answered in a document somewhere?



Thank you for your time.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor