Я знаю функцию stdin.read_line(), но мне хотелось сделать мой код менее подробным с помощью использования или чего-то большего в строке raw_input() в python.Как назвать GNU ReadLine в Genie
Итак, я узнал о GNU ReadLine в this обсуждениях vala, однако я не могу воспроизвести его в Genie.
код питона, который я хочу, чтобы имитировать это:
loop = 1
while loop == 1:
response = raw_input("Enter something or 'quit' to end => ")
if response == 'quit':
print 'quitting'
loop = 0
else:
print 'You typed %s' % response
Дальняя я мог бы получить было:
[indent=4]
init
var loop = 1
while loop == 1
// print "Enter something or 'quit' to end => "
var response = ReadLine.read_line("Enter something or 'quit' to end => ")
if response == "quit"
print "quitting"
loop = 0
else
print "You typed %s", response
И пытался компилировать с:
valac --pkg readline -X -lreadline loopwenquiry.gs
Но я я получаю ошибку:
loopwenquiry.gs:7.24-7.31: error: The name `ReadLine' does not exist in the context of `main'
var response = ReadLine.read_line("Enter something or 'quit' to end => ")
^^^^^^^^
loopwenquiry.gs:7.22-7.81: error: var declaration not allowed with non-typed initializer
var response = ReadLine.read_line("Enter something or 'quit' to end => ")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
loopwenquiry.gs:8.12-8.19: error: The name `response' does not exist in the context of `main'
if response == "quit"
^^^^^^^^
loopwenquiry.gs:12.35-12.42: error: The name `response' does not exist in the context of `main'
print "You typed %s", response
^^^^^^^^
Compilation failed: 4 error(s), 0 warning(s)
Что я делаю неправильно?
Спасибо.
Это 'Readline' не' ReadLine' (обратите внимание на разницу в случае). –
BTW: Почему бы вам просто не написать свою собственную функцию 'raw_input'? –