[OT] fortran lib which provide python like data type
Marko Rauhamaa
marko at pacujo.net
Sun Feb 1 14:12:49 EST 2015
Christian Gollwitzer <auriocus at gmx.de>:
> Am 01.02.15 um 08:58 schrieb Marko Rauhamaa:
>> Qt gave up on C++ when it comes to callbacks ("signals") and went for
>> an apocryphal metacompiler.
>
> Yes, but only because C++ compilers were not good enough when QT came
> out, and later is was too late to change it to a templated system.
> Lookup libsigc++ http://libsigc.sourceforge.net/ which does the same
> using standard C++ and http://qt-project.org/doc/qt-4.8/templates.html
> for a reasoning of QT.
>
> In C++11 (supported by MSVC, g++, clang) there re also lambda expressions
So please implement this small piece of Python code in C++ so we can
compare the idioms:
import sys, time
class MyLogger:
def __init__(self, write):
self.write = sys.stderr.write
def register_writer(self, write):
self.write = write
def log(self, text):
self.write("{} {}\n".format(time.time(), text))
class MyApp:
def __init__(self, logger):
self.logf = open("thelog.log", "a")
logger.register_writer(self.log_write)
def log_write(self, text):
self.logf.write(text)
self.logf.flush()
Marko
More information about the Python-list
mailing list