Clayton Kirkwood | 23 Nov 05:28 2014
Picon

yes, I am being lazy...

I have had my first experience in downloading and trying to lay-in several new modules. I downloaded requests and urllib3, unpacked them (on a windows system) and extracted them from the zip.  I don’t understand how setup.py and .cfg are supposed to implant them into the python hierarchy. The install doesn’t seem to insert them in the python directory. The build puts them under the current directory. Seems odd. I’ve moved the sub-directory into python/lib by hand. Doesn’t seem right. I am tired and frustrated…

 

Not that you care Steven:<)))

 

Clayton

 

You can tell the caliber of a man by his gun--c. kirkwood

 

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
arlus ishmael | 22 Nov 14:47 2014
Picon

Enquiry on technology stack to use

Hello,

I'm a student with intermediate python skill. I intend to build a hospital management system using Python. The intended design is a desktop application with an embedded server that listens for HTTP requests that come from a browser or a desktop client. This should be packaged into a single executable and preferably it should be cross platform. Furthermore, but not a must, bundling with it a message queue could also be great.

I have tried bundling django + cherrypy in Qt4 application but that proved difficult to bundle into an executable. I was looking for some suggestions on what technology stack I could use. Any help will be greatly appreciated.

Regards,
Aurlus I. Wedava


_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Clayton Kirkwood | 21 Nov 22:37 2014
Picon

urllib confusion

Hi all.

 

Got a general problem with url work. I’ve struggled through a lot of code which uses urllib.[parse,request]* and urllib2. First q: I read someplace in urllib documentation which makes it sound like either urllib or urllib2 modules are being deprecated in 3.5. Don’t know if it’s only part or whole.

I’ve read through a lot that says that urllib..urlopen needs urlencode, and/or encode(‘utf-8’) for byte conversion, but I’ve seen plenty of examples where nothing is being encoded either way. I also have a sneeking suspicious that urllib2 code does all of the encoding. I’ve read that if things aren’t encoded that I will get TypeError, yet I’ve seen plenty of examples where there is no error and no encoding.

 

Why do so many examples seem to not encode? And not get TypeError? And yes, for those of you who are about to suggest it, I have tried a lot of things and read for many hours.

 

Thanks,

 

Clayton

 

 

 

You can tell the caliber of a man by his gun--c. kirkwood

 

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
niyanaxx95 | 21 Nov 04:00 2014
Picon

Empty GraphicsWindow

I need help figuring why my GraphicsWindow empty, I cannot figure out why it is empty.
Here is my code :

# Import graphics from module
from graphics import GraphicsWindow

tileSize = 0

def main() :
   
    # Define global variables
    tilesInRow = 0
    tilesInCol = 0
    gapX = 0
    gapY = 0
   
    # Input room width
    roomWidth = getNumber(100, 500, "Enter a room width between 100 and 500: ", "")
    roomLength = getNumber(100, 450, "Enter a room length between 100 and 450: ", "")
    tileSize = getNumber(20, 50, "Enter a tile size between 20 and 50: ", "")
   
    numCols = tilesForSize(roomWidth, tileSize)
    print("The total number of Columns:", numCols)
    numRows = tilesForSize(roomLength, tileSize)
    print("The total number of Rows:", numRows)
   
    # Print the total number of tiles
    print("The total number or Tiles: %d" %(numCols * numRows))
   
    # Calculate the gap
    # the gap = (the total width - the number of tiles * tile width / 2
   
    gapX = calculateGap(roomWidth, numCols)
    gapY = calculateGap(roomLength, numRows)
   
    # Print the gaps
    print("The gap at each end of a row is: %.1f" % (gapX))
    print("The gap at each end of a column is: %.1f" % (gapY))
   
    # Draw graphics window
    win = GraphicsWindow(roomWidth, roomLength)
    canvas = win.canvas()
   
    # Draw the checkered surface
    for row in range(numRows) :
        # If the row is even
        if row % 2 == 0 :
            # If the column is even set color to black, if odd yellow
            drawRow(canvas, row, gapX, numCols, gapY, "black", "yellow")

        # If the row is odd
        else:
            # If the column is even set color to yellow, if odd black
            drawRow(canvas, row, gapX, numCols, gapY, "yellow", "black")     
         
    win.wait()
   
def getNumber(minBound, maxBound, msg, err_msg) :
    num = minBound - 1
    while num < minBound or num > maxBound :
        if(msg == "") :
            num = float(input("Enter a number between %f and %f: " % (minBound, maxBound)))
        else :
            num = float(input(msg))
        if num < minBound or num > maxBound :
            if err_msg == "" :
                print("Invalid input.")  
            else:
                print(err_msg)
    return num

def tilesForSize(size, tileSize) :
    pairs = int(size - tileSize) // int(2 * tileSize)
    num = int(1 + (2 * pairs))
    return num

def calculateGap(size, num) :
    return (size - num * tileSize) / 2

def drawRow(canvas, row, gapX, numCols, gapY, color1, color2) :
    for col in range(numCols) :
        if col % 2 == 0 :
            canvas.setColor("black")
        else:
            canvas.setColor("yellow")
        # Draw the actual rectangle
        canvas.drawRect(row * tileSize + gapX, col * tileSize + gapY, tileSize, tileSize)
    
 
main ()






















Sent from Windows Mail

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
James Rieve | 21 Nov 05:10 2014
Picon

break and exit

I accidently used 'exit' in a loop where I meant to use 'break' and, in that
case, the program seemed to work as expected but in some cases 'exit' seems
to behave differently from 'break'. For example, in this code snippet using
'exit' or 'break' produces the same result:

for i in range(10):
    if i > 3:
        exit
    else:
        print(i)
print('out of loop')

But in this case they behave differently:

for i in range(10):
    if i > 3:
        break   # try using exit here.
    else:
        print(i)
else:
    print('for loop else statement')

print('out of loop')

Does anyone have any pointers to descriptions of 'exit', what it is, what it
means, how It's used, etc.?

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Stephanie Morrow | 20 Nov 22:20 2014
Picon

Dividing a float derived from a string

Hi there,

I have been posed with the following challenge:

"Create a script that will ask for a number. Check if their input is a legitimate number. If it is, multiply it by 12 and print out the result."

I was able to do this with the following code:

input = raw_input("Insert a number: ")
if input.isdigit():
    print int(input) * 12
else:
    print False

However, a colleague of mine pointed out that a decimal will return as False.  As such, we have tried numerous methods to allow it to divide by a decimal, all of which have failed.  Do you have any suggestions?  Additionally, we are using 2.7, so that might change your answer.

Thank you in advance for any help you can provide!

-Stephanie
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Danny Yoo | 20 Nov 03:34 2014

Fwd: Fw: Traceback

---------- Forwarded message ----------
From: niyana morgan <niyanaxx95 <at> gmail.com>
Date: Wed, Nov 19, 2014 at 5:43 PM
Subject: Re: [Tutor] Fw: Traceback
To: Danny Yoo <dyoo <at> hashcollision.org>

No I am still stuck on what to do and this is a major project for my class.

On Nov 19, 2014 6:21 PM, "Danny Yoo" <dyoo <at> hashcollision.org> wrote:
>
> >> Exercise 1:
> >> def distance(x1, y1, x2, y2):
> >>     dx = x2 - x1
> >>     dy = y2 - y1
> >>     dsquared = dx**2 + dy**2
> >>     result = math.sqrt(dsquared)
> >>     print(result)
> >>     return result
> >
> >
> > That's not exercise 1.  Try again.
> >
> >
> >    Exercise 1
> >    Write a compare function that returns 1 if x > y, 0 if x == y, and
> > -1 if x < y.
> >
> >
> > I have to get back to work so hopefully others on the mailing list can
> > help you.  Please continue to reply to the list.
>
>
>
> Following up.  I don't think I've heard back about this.  Did you get
> help from someone else?  Has the problem here been resolved?
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

niyanaxx95 | 19 Nov 16:21 2014
Picon

Input Files

How do I know write the loop code for the table for both inputfiles, Table1.txt and Table2.txt and make a third table from the elements multiplied in table1.txt and table2.txt. I'm trying to Check the size of the two tables to make sure they both have the same number of rows and columns o If the tables are not the same size print an error message  Once you have read the data from each file create a third table  The elements in the third table are the result of multiplying each element in the first table by the corresponding element in the second table:
thirdTable [i] [j] = firstTable[i] [j] * secondTable[i] [j

Here is my code so far:
   
    def main():
        print("Table One")
        (row1, column1, table1) = readInput("Table 1.txt")
        print("Table Two")
        (row2, column2, table2) = readInput("Table 2.txt")
        return()


    def readInput(filename):
        table = []
        inputFile = open(filename, "r")

         #  Read the first line containing the number of rows and columns
        line = inputFile.readline()
   
        #  split the line into two strings
        (row, column) = line.split()
   
   
        #  convert the strings into integers
        row = int(row)
        column = int(column)
   
   
        #  loop on the file container, reading each line
   
        for line in inputFile :
            line = line.rstrip()  #strip off the newline
            dataList = line.split()  #  split the string into a list
            table.append(dataList)
 
     #  Loop through the table and convert each element to an integer
   
   
        for i in range(row):
            for j in range (column):
                table[i] [j] = int(table[i] [j])  # convert the string to an integer
                print(" %3d" % (table[i] [j]), end = " ")
            print()
   
        inputFile.close()  #  close the file
        return(row, column, table)
  
    #  return the number of rows and columns


    main()   

Sent from Windows Mail

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Mamy Rivo DIANZINGA | 19 Nov 17:41 2014
Picon

Data chart

Good morning Sir. Excuse me to bother you but i was wondering if you can help me, please Sir.
I am looking for a script (in python or fortran...) which can turn the data from Iter.dat, that i joined for you, into a chart like this:

           canofica   lnvd    msd
10_2         ...      ....    ...
 9_1         ...      ....    ...


I hope i do not exagerate, and i will be very grateful to you if you can help me, for any script in python or fortran. Thank in advance.
Best regards.
Attachment (Iter.dat): application/x-ns-proxy-autoconfig, 502 bytes
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Danny Yoo | 19 Nov 02:01 2014

Fwd: Fw: Traceback

---------- Forwarded message ----------
From: niyana morgan <niyanaxx95 <at> gmail.com>
Date: Tue, Nov 18, 2014 at 4:59 PM
Subject: Re: [Tutor] Fw: Traceback
To: Danny Yoo <dyoo <at> hashcollision.org>

Exercise 1:
def distance(x1, y1, x2, y2):
    dx = x2 - x1
    dy = y2 - y1
    dsquared = dx**2 + dy**2
    result = math.sqrt(dsquared)
    print(result)
    return result

On Nov 18, 2014 7:56 PM, "Danny Yoo" <dyoo <at> hashcollision.org> wrote:
>
> On Tue, Nov 18, 2014 at 4:48 PM, niyana morgan <niyanaxx95 <at> gmail.com> wrote:
> > Read the link. So I need to put
> > Return roomWidth and roomLength? ??
>
>
> You may want to practice writing functions that return useful values.
>
> Save the work you've go so far, and then open up a new program.
>
> Go through that link again in:
> http://www.greenteapress.com/thinkpython/html/thinkpython007.html#toc66
>
> but this time, also do Exercise 1 in that chapter.
>
>     Write a compare function that returns 1 if x > y, 0 if x == y, and
> -1 if x < y.
>
> Do this and show us what it looks like.
>
>
> I'm asking you to do this as side work because, at the moment, you've
> just been exposed to a new thing, and you're tempted to just hack it
> into your original program to make it "work".  This is not the best
> approach.  Instead: practice the new technique on small programs.
> Then once you know what you're doing, you can go back to the original
> problem.
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Danny Yoo | 19 Nov 01:56 2014

Fwd: Fw: Traceback

Forwarding to tutor.

---------- Forwarded message ----------
From: Danny Yoo <dyoo <at> hashcollision.org>
Date: Tue, Nov 18, 2014 at 4:56 PM
Subject: Re: [Tutor] Fw: Traceback
To: niyana morgan <niyanaxx95 <at> gmail.com>

On Tue, Nov 18, 2014 at 4:48 PM, niyana morgan <niyanaxx95 <at> gmail.com> wrote:
> Read the link. So I need to put
> Return roomWidth and roomLength? ??

You may want to practice writing functions that return useful values.

Save the work you've go so far, and then open up a new program.

Go through that link again in:
http://www.greenteapress.com/thinkpython/html/thinkpython007.html#toc66

but this time, also do Exercise 1 in that chapter.

    Write a compare function that returns 1 if x > y, 0 if x == y, and
-1 if x < y.

Do this and show us what it looks like.

I'm asking you to do this as side work because, at the moment, you've
just been exposed to a new thing, and you're tempted to just hack it
into your original program to make it "work".  This is not the best
approach.  Instead: practice the new technique on small programs.
Then once you know what you're doing, you can go back to the original
problem.
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Gmane