Форум сайта python.su
#get blender API for work with Armatures
from Blender import Armature
from Blender.Mathutils import *
ourArm = Armature.Get('Armature.002')
ourArm == Vector(0,0,0)
ourArm.update()
engine = create_engine('mysql://...?charset=utf8')
self.conn = engine.connect()
self.meta = MetaData()
self.meta.bind = engine
table1 = Table('table1', self.meta, autoload=True)
table2 = Table('table2', self.meta, autoload=True)
table3 = Table('table3', self.meta, autoload=True)
s = select([table1.c.some_data,
table2.c.some_data,
table3.c.some_data,
],
and_(
table1.c.id == table2.c.t1_id,
table2.c.t3_id == table3.c.id,
),
)
result = self.conn.execute(s)
return result.fetchall()
select text
====================
00:00:09 00:00:07
00:00:19 00:00:15
00:00:30 00:00:23
00:00:40 00:00:31
00:00:50 00:00:38
py-htfilter-2.dev>htfilter.py
error: uncaptured python exception, closing channel <__main__.ProxyServer connec
ted 127.0.0.1:2152 at 0x18020a8> (<type 'exceptions.ValueError'>:generator alrea
dy executing [Python26\lib\asyncore.py|read|76] [Python2
6\lib\asyncore.py|handle_read_event|416] [Python26\lib\asynchat.py|h
andle_read|158] [py-htfilter-2.dev\htfilter.py|callback|
175])
Traceback (most recent call last):
File "py-htfilter-2.dev\htfilter.py", line 439, in <mo
dule>
asyncore.loop()
File "Python26\lib\asyncore.py", line 202, in loop
poll_fun(timeout, map)
File "Python26\lib\asyncore.py", line 143, in poll
read(obj)
File "Python26\lib\asyncore.py", line 80, in read
obj.handle_error()
File "Python26\lib\asyncore.py", line 470, in handle_error
self.handle_close()
File "py-htfilter-2.dev\htfilter.py", line 260, in han
dle_close
while self.producer_fifo or self.ac_out_buffer:
File "Python26\lib\asyncore.py", line 394, in __getattr__
return getattr(self.socket, attr)
AttributeError: '_socketobject' object has no attribute 'ac_out_buffer'
#!/usr/bin/python
print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<head>'
print '<title>Hello World - First CGI Program</title>'
print '</head>'
print '<body>'
print '<h2>Hello World! This is my first CGI program</h2>'
print '</body>'
print '</html>'
twitter = OAuthApi(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
friends += twitter.GetFriends()
for friend in friends:
print friend.get('screen_name')
options['cursor']:
By default twitter returns a list of 100
followers. If you have more, you will need to
use the cursor value to paginate the results.
A value of -1 means to get the first page of results.
def GetAllFriends(self, options={}, cursor=-1, friends=[]):
callResult = self.GetFriends(cursor, options)
for user in callResult['user_list']['users']:
friends.append(user)
if callResult['user_list']['next_cursor'] != 0:
self.GetAllFriends(options, callResult['user_list']['next_cursor'], friends)
return friends
submit=wx.Button(panel, label="Submit", pos=(245,207), size=(50,30))
self.Bind(wx.EVT_BUTTON, self.get_answer, submit)
self.user_input = wx.TextCtrl(panel, -1, "", pos=(140,207))
def get_answer(self, event):
self.interpreter.AppendText("\nShall we start? yes/no: ")
rep1=self.user_input.GetValue()
if rep1=="yes":
self.interpreter.AppendText("OK, Your guess? ")
for i in range(5):
guess=self.user_input.GetValue()
if guess in a_word:
self.interpreter.AppendText("Yes!")
else:
self.interpreter.AppendText("No!")
if rep1=="no":
self.interpreter.AppendText("OK, may be next time. Buy!")
Shall we start? yes/no: YES(user input)
The word contains 5 letters.
Your guess? No!No!No!No!No!
class Main():
name = CharField()
class MatrixItem(Model):
value = FloatField()
x = ForeignKey(Main)
y = ForeignKey(Main)
class Main():
name = CharField()
class MatrixItem(Model):
value = FloatField()
coor = ManyToManyField(Main, related_name = 'items') #Храниться две ссылки на Main
def get_value(p1, p2):
try:
if p1<>p2:
return p1.items.__and__(p2.items)[0].value #Пользуясь случаем хотелось бы спросить, почему результат p1.items.__and__(p2.items) отличается от p1.items and p2.items ?
else:
return None
except IndexError:
return 0