Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IIS, Python3.7 and classes
#1
Just beginning to learn about classes (I have been reading automate the boring).
Anyway I am using windows running IIS localhost to try out python in a web environment. I think I have managed to set it up to run python, struggling a bit with getting it to read a database. But before I need the database, I would like to write some classes in files and be able to import them.

However it seems it not as easy as just write the py file and import it... or perhaps it is and I`m doing it wrong.
I have got python 2.7 and 3.7 installed, as I couldnt get the python 3 to use mysql/mssql... So I mapped the scripts py2 for python 2.7 and py3 for python 3.7

File Structure:
py3
---- whattodo.py3
---- classes
-------- Person.py

whattodo.py3
# get a passed command and do something with it...
'''
class Person:
  def __init__(self, name, age):
    self.name = name
    self.age = age
'''
from classes import Person

print('Content-Type: text/html')
print('CharSet: ISO-8859-1')
print('')
print('<meta charset="ISO-8859-1" content="charset=ISO-8859-1">')

print('<html><head><title>.P.</title></head><body>')

p = Person('John',42)
print(p.name+' '+str(p.age))

print('</body')
print('</html>')
and the person.py:
class Person:
  def __init__(self, name, age):
    self.name = name
    self.age = age
So obviously I've done something wrong... is it an easy fix?
Reply


Messages In This Thread
IIS, Python3.7 and classes - by Ecniv - Mar-13-2019, 02:50 PM
RE: IIS, Python3.7 and classes - by snippsat - Mar-13-2019, 04:45 PM
RE: IIS, Python3.7 and classes - by Ecniv - Mar-13-2019, 07:06 PM
RE: IIS, Python3.7 and classes - by Ecniv - Mar-14-2019, 09:10 AM
RE: IIS, Python3.7 and classes - by Ecniv - Mar-14-2019, 11:20 AM
RE: IIS, Python3.7 and classes - by snippsat - Mar-14-2019, 03:02 PM
RE: IIS, Python3.7 and classes - by Ecniv - Mar-15-2019, 07:38 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020