TypeError: 'kwarg' is an invalid keyword argument for this function

2014-10-12 Thread roro codeath
How to implement it in my class?

class Str(str):
def __init__(self, *args, **kwargs):
pass

Str('smth', kwarg='a')

# How to implement in my class

class C:
   def __init__(self):
   pass

class C2(C):
def __init__(self, *args, **kwargs):
pass
C2(kwarg='a')
-- 
https://mail.python.org/mailman/listinfo/python-list


ruby instance variable in python

2014-10-06 Thread roro codeath
for instance in ruby i can write following code:

module M
def ins_var
@ins_var ||= nil
end

def m
@ins_var = val
end

def m2
ins_var # = val
end

end

in py

# m.py

# how to def a ins_var?

def m:
# how to set a ins_var?

def m2:
# how to get a ins_var?
-- 
https://mail.python.org/mailman/listinfo/python-list


ruby instance variable in python

2014-10-06 Thread roro codeath
in ruby:

module M
def ins_var
@ins_var ||= nil
end

def m
@ins_var = 'val'
end

def m2
m
ins_var # = 'val'
end
end

in py:

# m.py

# how to def ins_var

def m:
# how to set ins_var

def m2:
m()
# how to get ins var
-- 
https://mail.python.org/mailman/listinfo/python-list