我正在翻译:http://thinkstats.com/survey.py这个脚本。在
下面是我现在正在翻译的内容(Python):
"""This file contains code for use with "Think Stats",
by Allen B. Downey, available from greenteapress.com
Copyright 2010 Allen B. Downey
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
"""
import sys
import gzip
import os
class Record(object):
"""Represents a record."""
class Respondent(Record):
"""Represents a respondent."""
class Pregnancy(Record):
"""Represents a pregnancy."""
斯卡拉:
^{2}$问题:
我做了class Respondent
和class Pregnancy
正确吗?这些类的注释是否正确?逻辑正确吗?我刚刚读过关于类型参数化的文章,所以我对此有点怀疑,想看看我是否走在正确的道路上。在
谢谢你抽出时间。在
我记得,您展示的Python语法是针对类扩展(继承)。相当于Scala
形式为
/** ... */
的Scala注释将在ScalaDoc中显示为文档。在这里不需要类型参数化。它的主要用途是允许类接受或返回任意参数化类型的值。例如,}分别是整数和字符串的列表。在
List[Int]
和{相关问题 更多 >
编程相关推荐