たばさの?

Nov 14, 2007

ruby => python 比較

irb
=>
python 引数なしで


def fun a,b,c
  a
end
 =>
def fun(a,b,c):
   return a

>puts "123".class
String
 =>
>print type("123")
<type 'str'>

/abc/ =~ str
=> 
import re
re.search(abc, str)

a.length
=>
len(a)

end
=>
(なし)

String.methods
=>
dir(str)

Nov 10, 2007

1000res

# check1000res.py
# coding: shift-jis
import re
import sys
import os

def copy(read, write):
    write(read())

filename=sys.argv[1]
# tmp=open("tmp-savedhtmname.txt")
# filename=tmp.readline()
print "!",filename	
file=open(filename)

key="<dt>1000 :<font color=green><b>"

ans=0
while 1:
 line = file.read()
 if len(line)==0:break
 if (re.search(key, line)) :
   ans=1
   break
 else :
   ans=0
   
if ans==1:
  print "1000!",filename
  os.system('notepad')

Oct 26, 2007

trace-characters

http://golf.shinh.org/p.rb?Trace+characters

str reverseってないんだったかな

# trace-char.py
import sys
x=""
for line in sys.stdin:
 x+=line
if x[0]=='L':
 a=x[149:159]
 print x[0:15]+a+(',F'+a)*2 +"."+x[0:15] +a+",Myfairlady."
elif x[0]=='W':
 a="killedCockRobin"
 print"Who"+a+"?I,saidtheSparrow,Withmybowandarrow,I"+a+"."
else:
 b=""
 for a in x[245:293]:
  b=a+b
 a=x[0:7]+x[98:143]+b
 print a+a[5:58]

(あった)http://0xcc.net/blog/archives/000137.html

Oct 24, 2007

オープン

19:02

(rubyはこちら => http://rubyist.g.hatena.ne.jp/hatecha/ )

練習など。

print

# print-.py
def a():
 return "123"
def b():
 return "456"

print a()+b()
print a(),b()
# print a() b() # =>SyntaxError: invalid syntax

>print-.py

123456

123 456

カレンダー
<< 2017/02 >>
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28