These are chat archives for BernieenJos/weetikveel

3rd
Jul 2015
JosvanderSpek
@JosvanderSpek
Jul 03 2015 16:34
Hey G
Ik denk dat ik iets ben tegengekomen waar ik iets nodig heb wat ik gek genoeg nog steeds nooit gebruikt heb: classes
Kijk
        Surpassing(numberS, WOP, Days_Till_Birthday(122), 122)
        Surpassing(numberS, WOP, Days_Till_Birthday(121), 121)
        Surpassing(numberS, WOP, Days_Till_Birthday(120), 120)
        Surpassing(2, "Sarah Knauss", daysTillSK, 119)
        Surpassing(numberS, WOP, Days_Till_Birthday(119), 119)
        Surpassing(numberS, WOP, Days_Till_Birthday(118), 118)
        Surpassing(3, "Lucy Hannah", daysTillLH, 117)
        Surpassing(4, "Marie-Louise Meilleur", daysTillMLM, 117)
        Surpassing(5, "Misao Okawa", daysTillMO, 117)
        Surpassing(numberS, WOP, Days_Till_Birthday(117), 117)
        Surpassing(6, "Maria Capovilla", daysTillMC, 116)
        Surpassing(7, "Gertrude Weaver", daysTillGW, 116)
        Surpassing(8, "Tane Ikai", daysTillTI, 116)
        Surpassing(9, "Elizabeth Bolden", daysTillEB, 116)
        Surpassing(10, "Besse Cooper", daysTillBC, 116)
        Surpassing(11, "Jiroemon Kimura", daysTillJK, 116)
        Surpassing(12, "Jeralean Talley", daysTillJT, 116)
        Surpassing(numberS, WOP, Days_Till_Birthday(116), 116)
Dit moet natuurlijk ik 1 functie kunenn
iets als:
        dagen_tot = [Days_Till_Birthday(116), daysTillJT, daysTillJK, daysTillBC, daysTillEB, daysTillTI, daysTillGW, daysTillMC, Days_Till_Birthday(117), daysTillMO, daysTillMLM, daysTillLH, Days_Till_Birthday(118), Days_Till_Birthday(119), daysTillSK, Days_Till_Birthday(120), Days_Till_Birthday(121), Days_Till_Birthday(122)] # Dit moet natuurlijk ook beter kunnen.
        for dag in dagen_tot :
            if dag >= 0 :
                Surpassing(number,  person, days_until, age)
(Ze moeten uiteraard gesorteerd worden op het argument 'days_until')
Maar zou het nu niet handig zijn om van alle personen een class te maken, die dan allemaal de attributen, nummer (in de top100), leeftijd en tijd tot passeren krijgen
JosvanderSpek
@JosvanderSpek
Jul 03 2015 16:55
Kijk zo
class Jeralean:
    name = "Jeralean"
    days_until = m.ceil((time.mktime(time.strptime("2015 07 31", "%Y %m %d")) - now)/86400.0)
    number = 12
    age = 116

class Jiroemon:
    name = 'Jiroemon"
    days_until = m.ceil((time.mktime(time.strptime("2015 07 16", "%Y %m %d")) - now)/86400.0 + 44)
    number = 11
    age = 116

class Besse:
    name = "Besse"
    days_until = m.ceil((time.mktime(time.strptime("2015 08 31", "%Y %m %d")) - now)/86400.0 + 44)
    number = 10
    age = 116

class Elizabeth:
    name = "Elizabeth"
    days_until = m.ceil((time.mktime(time.strptime("2015 09 18", "%Y %m %d")) - now)/86400.0 + 44)
    number = 9
    age = 116

class Tane:
    name = "Tane"
    days_until = m.ceil((time.mktime(time.strptime("2015 11 14", "%Y %m %d")) - now)/86400.0 + 44)
    number = 8
    age = 116

class Gertrude:
    name = "Gertrude"
    days_until = m.ceil((time.mktime(time.strptime("2016 02 23", "%Y %m %d")) - now)/86400.0 + 44)
    number = 7
    age = 116

class Maria:
    name = "Maria"
    days_until = m.ceil((time.mktime(time.strptime("2016 05 04", "%Y %m %d")) - now)/86400.0 + 44)
    number = 6
    age = 116

class Misao:
    name = "Misao"
    days_until = m.ceil((time.mktime(time.strptime("2016 06 19", "%Y %m %d")) - now)/86400.0 + 44)
    number = 5
    age = 117

class Marie_Louise:
    name = "Marie-Louise"
    days_until = m.ceil((time.mktime(time.strptime("2017 01 08", "%Y %m %d")) - now)/86400.0 + 44)
    number = 4
    age = 117

class Lucy:
    name = "Lucy"
    days_until = m.ceil((time.mktime(time.strptime("2017 01 26", "%Y %m %d")) - now)/86400.0 + 44)
    number = 3
    age = 117

class Sarah:
    name = "Sarah"
    days_until = m.ceil((time.mktime(time.strptime("2018 08 28", "%Y %m %d")) - now)/86400.0 + 44)
    number = 2
    age = 119

class Jeanne:
    name = "Jeanne"
    days_until = m.ceil((time.mktime(time.strptime("2021 11 03", "%Y %m %d")) - now)/86400.0 + 44)
    number = 1
    age = 122
JosvanderSpek
@JosvanderSpek
Jul 03 2015 17:02
Het vervelende is trouwens dat ergens tussen deze gebeurtenissen (het passeren van mensen op de top 100 lijst) af en toe een verjaardag tussendoor komt
Kijk maar naar het lijstje wat uiteindelijk geproduceerd moet worden
 And there are only 6 years and 167 days left until she becomes the verified oldest person ever!
 There are 6 years and 4 days left until she celebrates her 122nd birthday!
 There are 5 years and 4 days left until she celebrates her 121st birthday!
 There are 4 years and 3 days left until she celebrates her 120th birthday!
 There are 3 years and 100 days left until she surpasses the #2: Sarah Knauss
 There are 3 years and 3 days left until she celebrates her 119th birthday!
 There are 2 years and 173 days (904 days) left until I win the bet!
 There are 2 years and 3 days left until she celebrates her 118th birthday!
 There are 1 year and 251 days left until she surpasses the #3: Lucy Hannah
 There are 1 year and 233 days left until she surpasses the #4: Marie-Louise Meilleur
 There are 1 year and 30 days left until she surpasses the #5: Misao Okawa
 There are 1 year and 3 days left until she celebrates her 117th birthday!
 There are only 350 days left until she surpasses the #6: Maria Capovilla
 There are only 279 days left until she surpasses the #7: Gertrude Weaver
 There are only 178 days left until she surpasses the #8: Tane Ikai
 There are only 121 days left until she surpasses the #9: Elizabeth Bolden
 There are only 103 days left until she surpasses the #10: Besse Cooper
 There are only 57 days left until she surpasses the #11: Jiroemon Kimura
 There are only 28 days left until she surpasses the #12: Jeralean Talley
 There are only 3 days left until she celebrates her 116th birthday!
Nu heb ik wel al de functies 'Happy_Birthday()' (die het aantal jaren en dagen tot een zekere verjaardag print) en 'Surpassing()' (print het aantal jaren en dagen tot een passering) samengevoegd in 1 functie
(Deze heet Surpassing(), ik heb dus Happy_Birthday in Surpassing() verwerkt)
JosvanderSpek
@JosvanderSpek
Jul 03 2015 18:29
class Susannah():
    name = "Susannah"
    days_until = Days_Till_Birthday(Birthday)
    number = oldest_people.index("Susannah Jones")
    age = 115    

class Jeralean:
    name = "Jeralean"
    days_until = m.ceil((time.mktime(time.strptime("2015 07 31", "%Y %m %d")) - now)/86400.0)
    number = oldest_people.index("Jeralean Talley")
    age = 116
JosvanderSpek
@JosvanderSpek
Jul 03 2015 18:41
Oh ja oldest_people is gewoon deze lijst
oldest_people   = ["Jeanne Calment", "Sarah Knauss", "Lucy Hannah", "Marie-Louise Meilleur", "Misao Okawa", "Maria Capovilla", "Gertrude Weaver", "Tane Ikai", "Elizabeth Bolden", "Besse Cooper", "Jiroemon Kimura", "Jeralean Talley", "Susannah Jones"]
iambernie
@iambernie
Jul 03 2015 18:44
class Person:
class Person:
    def __init__(self, name, age):
        self.name = name
        self.age =  age

    def foobar(self):
        return self.age+10
Person("Bernie", 30)
p = Person("Bernie", 30)
p.name  
p.age
p.foobar()
p.foobar()
JosvanderSpek
@JosvanderSpek
Jul 03 2015 19:17
class Jeralean:
    name = "Jeralean"
    days_until = m.ceil((time.mktime(time.strptime("2015 07 31", "%Y %m %d")) - now)/86400.0)
    number = oldest_people.index("Jeralean Talley") + 1
    age = 116

class Susannah():
    name = "Susannah"
    number = oldest_people.index("Susannah Jones") + 1
    age = 115    
    def days_until(Birthday):
        daysTillBirthday = m.ceil((time.mktime(time.strptime("%i 07 06"%(nextBirthday + Birthday - 116),"%Y %m %d")) - now)/86400.0)
        return daysTillBirthday
        dagen_tot = [Susannah(116), Jeralean, Jiroemon, Besse, Elizabeth, Tane, Gertrude, Maria, Susannah(117), Misao, Marie_Louise, Lucy, Susannah(118), Susannah(119), Sarah, Susannah(120), Susannah(121), Susannah(122), Jeanne]
        for i in range(len(dagen_tot)) :
            if dagen_tot[i] >= 0 :
                Surpassing(dagen_tot[i].number, dagen_tot[i].name, dagen_tot[i].days_until, dagen_tot[i].age)
Ter vergelijking:
        Surpassing(1, "Jeanne Calment", daysTillJC, 122)                                                                            
        Surpassing(numberS, WOP, Days_Till_Birthday(122), 122)
        Surpassing(numberS, WOP, Days_Till_Birthday(121), 121)
        Surpassing(numberS, WOP, Days_Till_Birthday(120), 120)
        Surpassing(2, "Sarah Knauss", daysTillSK, 119)
        Surpassing(numberS, WOP, Days_Till_Birthday(119), 119)
        Surpassing(numberS, WOP, Days_Till_Birthday(118), 118)
        Surpassing(3, "Lucy Hannah", daysTillLH, 117)
        Surpassing(4, "Marie-Louise Meilleur", daysTillMLM, 117)
        Surpassing(5, "Misao Okawa", daysTillMO, 117)
        Surpassing(numberS, WOP, Days_Till_Birthday(117), 117)
        Surpassing(6, "Maria Capovilla", daysTillMC, 116)
        Surpassing(7, "Gertrude Weaver", daysTillGW, 116)
        Surpassing(8, "Tane Ikai", daysTillTI, 116)
        Surpassing(9, "Elizabeth Bolden", daysTillEB, 116)
        Surpassing(10, "Besse Cooper", daysTillBC, 116)
        Surpassing(11, "Jiroemon Kimura", daysTillJK, 116)
        Surpassing(Jeralean.number, Jeralean.name, Jeralean.days_until, Jeralean.age)
        Surpassing(12, "Jeralean Talley", daysTillJT, 116)
        Surpassing(numberS, WOP, Days_Till_Birthday(116), 116)
JosvanderSpek
@JosvanderSpek
Jul 03 2015 19:29
dagen_tot = [Susannah(116), Jeralean, Jiroemon, Besse, Elizabeth, Tane, Gertrude, Maria, Susannah(117), Misao, Marie_Louise, Lucy, Susannah(118), Susannah(119), Sarah, Susannah(120), Susannah(121), Susannah(122), Jeanne]
for i in range(len(dagen_tot)) :
if dagen_tot[i].days_until >= 0 :
    Surpassing(dagen_tot[i].number, dagen_tot[i].name, dagen_tot[i].days_until, dagen_tot[i].age)
JosvanderSpek
@JosvanderSpek
Jul 03 2015 19:40
dagen_tot = [Susannah(116), Jeralean, Jiroemon, Besse, Elizabeth, Tane, Gertrude, Maria, Susannah(117), Misao, Marie_Louise, Lucy, Susannah(118), Susannah(119), Sarah, Susannah(120), Susannah(121), Susannah(122), Jeanne]
for i in range(len(dagen_tot)) :
    if dagen_tot[i].days_until >= 0 :
        Surpassing(dagen_tot[i].number, dagen_tot[i].name, dagen_tot[i].days_until, dagen_tot[i].age)
iambernie
@iambernie
Jul 03 2015 19:46
Susanna.birthday(116)
Susannah(116)
class Jerelean:
    def __init__(self):
        self.name = ...
       self.age = ...
       self.days_until =...

j = Jerelean()
j.name
j.age.
j.days_until
iambernie
@iambernie
Jul 03 2015 19:55
class Person(object):
    def __init__(self, fullname, sex, date_birth, date_death=None,\
                 residence=None):
        self.fullname = fullname
        self.sex = sex
        self.date_birth = date_birth
        self.date_death = date_death
        self.residence = residence

    def is_alive(self):
        if self.date_death is None:
            return True
        else:
            return False

    def age(self):
        if self.is_alive():
            return datetime.date.today() - self.date_birth
        else:
            return self.age_at_death()

    def age_at_death(self):
        if not self.is_alive():
            return self.date_death - self.date_birth
        else:
            return None
            #raise Exception("Still breathing!")

    def age_at(self, date):
        pass

    def age_in_yearsdays(self):
        dt = self.age()
        years, days = divmod(dt.days, 365.24)
        return "%s years %s days"%(int(years), int(days))
bernie = Person("bernie la" , "m",   *datetimeobject*, datetimeobject*)
iambernie
@iambernie
Jul 03 2015 20:01
class Person(object):
    def __init__(self, age, firstname=None, lastname=None):
        self.age = age
        self.firstname = firstname
        self.lastname = lastname

    def __repr__(self):
        if self.firstname and self.lastname:
            return self.firstname+" "+self.lastname
        else:
            return "No name"

    def is_allowed_to_drink(self):
        if self.age > 16:
           return True
        else:
           return False

    def invert_age(self):
        return 1.0/self.age
b = Person(30, "berni", "aaul")
b.is_allowed_to_drink()
iambernie
@iambernie
Jul 03 2015 20:16
class Foo():
    pass
susasnna = Foo()
susasnna.number =  12
iambernie
@iambernie
Jul 03 2015 20:22

Dit moest trouwens zijn:

class Foo:
    pass

of voor python2 backwards compatibility

class Foo(object):
    pass
JosvanderSpek
@JosvanderSpek
Jul 03 2015 21:05
now         = time.time()
currentYear = time.localtime(now)[0]
nextBirthday= currentYear
if now > time.mktime(time.strptime("%i 07 06 12"%(currentYear), "%Y %m %d %H")) : 
    nextBirthday += 1

oldest_people   = ["Jeanne Calment", "Sarah Knauss", "Lucy Hannah", "Marie-Louise Meilleur", "Misao Okawa", "Maria Capovilla", "Gertrude Weaver", "Tane Ikai", "Elizabeth Bolden", "Besse Cooper", "Jiroemon Kimura", "Jeralean Talley", "Susannah Jones"]

class Susannah():
    name = "Susannah"
    number = oldest_people.index("Susannah Jones") + 1
    age = 115    
    def __init__(self, Birthday):
        def days_until(self, Birthday):
            daysTillBirthday = m.ceil((time.mktime(time.strptime("%i 07 06"%(nextBirthday + Birthday - 116),"%Y %m %d")) - now)/86400.0)
            return daysTillBirthday
        self.days_until = days_until(self, Birthday)

dagen_tot = [Jeanne, Susannah(122), Susannah(121), Susannah(120), Sarah, Susannah(119), Susannah(118), Lucy, Marie_Louise, Misao, Susannah(117), Maria, Gertrude, Tane, Elizabeth, Besse, Jiroemon, Jeralean, Susannah(116)]
for dag in dagen_tot :
    if dag.days_until >= 0 :
        Surpassing(dag.number, dag.name, dag.days_until, dag.age)
JosvanderSpek
@JosvanderSpek
Jul 03 2015 21:20
Ik heb het!
now         = time.time()
currentYear = time.localtime(now)[0]
nextBirthday= currentYear
if now > time.mktime(time.strptime("%i 07 06 12"%(currentYear), "%Y %m %d %H")) : 
    nextBirthday += 1

oldest_people   = ["Jeanne Calment", "Sarah Knauss", "Lucy Hannah", "Marie-Louise Meilleur", "Misao Okawa", "Maria Capovilla", "Gertrude Weaver", "Tane Ikai", "Elizabeth Bolden", "Besse Cooper", "Jiroemon Kimura", "Jeralean Talley", "Susannah Jones"]

class Susannah():
    name = "Susannah"
    number = oldest_people.index("Susannah Jones") + 1
    def __init__(self, Birthday):
        age = 115    
        def days_until(self, Birthday):
            daysTillBirthday = m.ceil((time.mktime(time.strptime("%i 07 06"%(nextBirthday + Birthday - 116),"%Y %m %d")) - now)/86400.0)
            return daysTillBirthday
        self.days_until = days_until(self, Birthday)
        self.age = Birthday

dagen_tot = [Jeanne, Susannah(122), Susannah(121), Susannah(120), Sarah, Susannah(119), Susannah(118), Lucy, Marie_Louise, Misao, Susannah(117), Maria, Gertrude, Tane, Elizabeth, Besse, Jiroemon, Jeralean, Susannah(116)]
for dag in dagen_tot :
    if dag.days_until >= 0 :
        Surpassing(dag.number, dag.name, dag.days_until, dag.age)
JosvanderSpek
@JosvanderSpek
Jul 03 2015 21:33
Nou eigenlijk zelfs dit
```
now         = time.time()
currentYear = time.localtime(now)[0]
nextBirthday= currentYear
if now > time.mktime(time.strptime("%i 07 06 12"%(currentYear), "%Y %m %d %H")) : 
    nextBirthday += 1

oldest_people   = ["Jeanne Calment", "Sarah Knauss", "Lucy Hannah", "Marie-Louise Meilleur", "Misao Okawa", "Maria Capovilla", "Gertrude Weaver", "Tane Ikai", "Elizabeth Bolden", "Besse Cooper", "Jiroemon Kimura", "Jeralean Talley", "Susannah Jones"]

class Susannah():
    name = oldest_people[12]
    number = oldest_people.index("Susannah Jones") + 1
    def __init__(self, Birthday):
        age = 115    
        def days_until(self, Birthday):
            daysTillBirthday = m.ceil((time.mktime(time.strptime("%i 07 06"%(nextBirthday + Birthday - 116),"%Y %m %d")) - now)/86400.0)
            return daysTillBirthday
        self.days_until = days_until(self, Birthday)
        self.age = Birthday

dagen_tot = [Jeanne, Susannah(122), Susannah(121), Susannah(120), Sarah, Susannah(119), Susannah(118), Lucy, Marie_Louise, Misao, Susannah(117), Maria, Gertrude, Tane, Elizabeth, Besse, Jiroemon, Jeralean, Susannah(116)]
for dag in dagen_tot :
    if dag.days_until >= 0 :
        Surpassing(dag.number, dag.name, dag.days_until, dag.age)
```
(Enige verschil is name = oldest_people[12])