--- py*****************@python.org写道: Send Python-list mailing list submissions to py*********@python.org
To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-list or, via email, send a message with subject or body 'help' to py*****************@python.org
You can reach the person managing the list at py***************@python.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-list digest..." Today's Topics:
1. Re: appending key-value pairs to a dict (Peter Hansen) 2. Re: Is Python suitable for a huge, enterprise size app? (Paul Rubin) 3. Re: appending key-value pairs to a dict (Brian Beck) 4. Re: Comparing 2 similar strings? (Skip Montanaro) 5. Re: Is Python suitable for a huge, enterprise size app? (Paul Rubin) 6. Re: buffer_info error (as*****@gmail.com) 7. Re: appending key-value pairs to a dict (James Stroud) 8. From the call hook, how do I know more precisely what is called? (Vijay Kumar) 9. Re: PyGame and Rotozoom (Sorry if OT) (Lee Harr) 10. Re: buffer_info error (Jp Calderone) 11. Re: appending key-value pairs to a dict (Roy Smith) 12. Re: Is Python suitable for a huge, enterprise size app? (Dave Brueck) 13. Re: Process monitoring (John Abel) 发件人: Peter Hansen <pe***@engcorp.com> 收件人: py*********@python.org 日期: Fri, 20 May 2005 16:12:17 -0400 主题: Re: appending key-value pairs to a dict
rbt wrote: I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put
the file's name and its sha hash into a dict on each loop.
Whereas with a list you would call "append" in the loop, with a dictionary you simply use an indexed-assignment type of access:
mydict = {} for filename in some_list_of_filenames: hash = sha.sha(open(filename).read()).hexdigest() # or whatever mydict[filename] = hash
-Peter
发件人: Paul Rubin <http://ph****@NOSPAM.invalid> 收件人: py*********@python.org 日期: 20 May 2005 13:12:50 -0700 主题: Re: Is Python suitable for a huge, enterprise size app?
Dave Brueck <da**@pythonapocrypha.com> writes: One thing from your experience that did resonate with me is that, except for ftplib and occasionally urllib (for basic, one-shot GETs), we don't use any of the standard library's "protocol" modules - partly because we had to implement our own HTTP libraries for performance and scalability reasons anyway, and partly because we had trouble figuring out e.g. all the ins and outs of urllib/urllib2/httplib.
What do you use for HTTPS? And did you use the Cookie module in your HTTP servers? You may have had problems without even being aware of them (until recently if you used Cookie with its default settings, any attacker could completely take over your server by sending you carefully concoted cookies). I'm not trying to be contentious here, just mentioning a couple further cases of where problems aren't visible from far away but are there when you look close.
发件人: Brian Beck <ex****@gmail.com> 收件人: py*********@python.org 日期: Fri, 20 May 2005 16:14:17 -0400 主题: Re: appending key-value pairs to a dict
rbt wrote: I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put
the file's name and its sha hash into a dict on each loop.
Like so:
d = {} for filename in files: d[sha_func(filename)] = filename
Or like so:
d = dict([(sha_func(filename), filename) for filename in files])
-- Brian Beck Adventurer of the First Order
发件人: Skip Montanaro <sk**@pobox.com> *送: py*********@python.org 收件人: Steve Holden <st***@holdenweb.com> 日期: Fri, 20 May 2005 15:16:49 -0500 主题: Re: Comparing 2 similar strings?
Steve> (is this the same as 'Conchobar'?)
No, that's a trendy pub in Key West...
<wink>
Skip
发件人: Paul Rubin <http://ph****@NOSPAM.invalid> 收件人: py*********@python.org 日期: 20 May 2005 13:15:48 -0700 主题: Re: Is Python suitable for a huge, enterprise size app?
"Fredrik Lundh" <fr*****@pythonware.com> writes: this has been reported before, and it won't get fixed (unless you're volunteering to add Python-compatible garbage collection to Tk, that is).
Yeah, I think I understand what the issue is. I can think of some kludgy possible fixes but I assume they've been thought about already and rejected. The workaround of making the application save an extra reference isn't too bad, but all relevant docs that say anything about these images should mention the requirement emphatically.
发件人: "as*****@gmail.com" <do*****@gmail.com> 收件人: py*********@python.org 日期: 20 May 2005 13:18:33 -0700 主题: Re: buffer_info error
i am filling in a packet with source and destination address and using the buffer_info call to pass on the address to an underlying low level call.
The src and dest are strings, but buffer_info expects an array. How do i deal with this?
发件人: James Stroud <js*****@mbi.ucla.edu> 收件人: py*********@python.org 日期: Fri, 20 May 2005 13:20:48 -0700 主题: Re: appending key-value pairs to a dict
On Friday 20 May 2005 01:04 pm, rbt wrote: I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put
the file's name and its sha hash into a dict on each loop.
Many thanks,
rbt
Simple assignment.
adict[filename] = an_sha_hash -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095
http://www.jamesstroud.com/
发件人: Vijay Kumar <ge******@gmail.com> *送: vs******@cs.nmsu.edu 收件人: py*********@python.org 日期: Fri, 20 May 2005 14:21:33 -0600 主题: From the call hook, how do I know more precisely what is called?
Hi,
I wrote a trace function using the profiling and tracing hooks provided by the python interpreter.
The Python interpreter reports the calls occuring in the source program to my trace function.
How can I know whether the call happened is a function call or method call and if it is a method call what is its self object and/or class is?.
I receive a frame object from the interpreter for every call.
Thanks, Vijay.
发件人: Lee Harr <le*@example.com> 收件人: py*********@python.org 日期: Fri, 20 May 2005 20:38:45 GMT 主题: Re: PyGame and Rotozoom (Sorry if OT)
On 2005-05-20, J. W. McCall <jm*****@houston.rr.com> wrote: I'm not sure if this is off-topic, since it doesn't deal with Python itself, but here goes:
I'm messing around with writing a simple "game" where the player (a crudely drawn smiley face) moves by rotating and moving back or forward (think Resident Evil, but from an always-above view). After much hacking, I have it working where left and right rotate the player sprite and up always moves the sprite whichever direction it's facing, while down is reverse. I'm using pygame.transform.RotoZoom(). My problem is that it doesn't rotate smoothly.
When it rotates, the corners of the image (just a plain white background) look like they're hitting some barrier and making it move around. Think of an empty box turned diagonally (so that it looks like a diamond, with its open end facing you), and a cube in that box being turned while it's resting in the bottom corner. I want it to rotate smoothly around its center, it's it's not doing that.
I'm guessing that it has something to do with me not setting up a Rect right, but I'm not sure. Maybe this is a limitation of Rotozoom/Rotate? Any advice would be greatly appreciated. And yes,
I'm a rank PyGame newbie. You might want to try pygsear: http://www.nongnu.org/pygsear/
It has a RotatedImage class which takes care of rotating things for you. See the examples roti.py and wings.py for some use of rotated image sprites.
发件人: Jp Calderone <ex*****@divmod.com> 收件人: py*********@python.org 日期: Fri, 20 May 2005 20:45:00 GMT 主题: Re: buffer_info error
On 20 May 2005 13:18:33 -0700, "as*****@gmail.com" <do*****@gmail.com> wrote:i am filling in a packet with source and destination address and usingthe buffer_info call to pass on the address to an underlying low levelcall.
The src and dest are strings, but buffer_info expects an array. How doi deal with this?
What's the low-level call you're invoking?
Jp
发件人: ro*@panix.com (Roy Smith) 收件人: py*********@python.org 日期: 20 May 2005 16:50:39 -0400 主题: Re: appending key-value pairs to a dict
rbt <rb*@athop1.ath.vt.edu> wrote:I know how to setup an empty list and loop thru something... appendingto the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put
the file's name andits sha hash into a dict on each loop.
You just assign values to keys. If the key doesn't exist, it's created automagically. You want something like this:
shaDict = {} for fileName in fileNameList: hash = generateShaHash (fileName) shaDict[hash] = fileName
发件人: Dave Brueck <da**@pythonapocrypha.com> 收件人: py*********@python.org 日期: Fri, 20 May 2005 15:07:05 -0600 主题: Re: Is Python suitable for a huge, enterprise size app?
Paul Rubin wrote: Dave Brueck <da**@pythonapocrypha.com> writes:
One thing from your experience that did resonate with me is that,except for ftplib and occasionally urllib (for basic, one-shot GETs),we don't use any of the standard library's "protocol" modules - partlybecause we had to implement our own HTTP libraries for performance andscalability reasons anyway, and partly because we had trouble figuringout e.g. all the ins and outs of urllib/urllib2/httplib.
What do you use for HTTPS?
Hi Paul,
m2crypto (plus some patches to make asynchronous SSL do what we needed).
And did you use the Cookie module in your HTTP servers? You may have had problems without even being aware of them (until recently if you used Cookie with its default settings, any attacker could completely take over your server by sending you carefully concoted cookies).
Are you referring to the use of pickle for cookie serialization? In any case, we didn't use Cookie.py from the stdlib (on the servers, nearly everything related to URLs & HTTP was custom-built, with the exception of urlparse, for the aforemenioned reasons).
-Dave
发件人: John Abel <jo*******@btinternet.com> *送: py*********@python.org 日期: Fri, 20 May 2005 22:24:14 +0100 主题: Re: Process monitoring
gsteff wrote:
Hey, I'm working on a Python program that will launch some othernon-Python process using os.spawn (in the os.P_NOWAIT mode) and thenbasically wait for it to finish (while doing some other stuff in theinterim). Normally, the new process will signal that it's done bywriting to a file, but I'd like to also find out if the new processdied unexpectedly. Anyone know any preferrable ways to do this? Greg Steffensen
If you're using 2.4, have a look at the subprocess module.
J
-- http://mail.python.org/mailman/listinfo/python-list
I am a beginner,Can you introduce some book about
python? I am a student of china
__________________________________________________ _______
Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂 http://cn.rd.yahoo.com/mail_cn/tag/y...sic.yisou.com/
美女明星应有尽有,搜遍美图、艳图和酷图 http://cn.rd.yahoo.com/mail_cn/tag/y...mage.yisou.com
1G就是1000兆,雅虎电邮自助扩容! http://cn.rd.yahoo.com/mail_cn/tag/1...event/mail_1g/ 3 2679
You m,igth try my page of Python Book reviews at http://www.awaretek.com/book.html
Ron Stephens
fdsl ysnh wrote: --- py*****************@python.org鍐欓亾:
Send Python-list mailing list submissions to py*********@python.org
To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-list or, via email, send a message with subject or body 'help' to py*****************@python.org
You can reach the person managing the list at py***************@python.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-list digest..." Today's Topics: 1. Re: appending key-value pairs to a dict (Peter Hansen) 2. Re: Is Python suitable for a huge, enterprise size app? (Paul Rubin) 3. Re: appending key-value pairs to a dict (Brian Beck) 4. Re: Comparing 2 similar strings? (Skip Montanaro) 5. Re: Is Python suitable for a huge, enterprise size app? (Paul Rubin) 6. Re: buffer_info error (as*****@gmail.com) 7. Re: appending key-value pairs to a dict (James Stroud) 8. From the call hook, how do I know more precisely what is called? (Vijay Kumar) 9. Re: PyGame and Rotozoom (Sorry if OT) (Lee Harr) 10. Re: buffer_info error (Jp Calderone) 11. Re: appending key-value pairs to a dict (Roy Smith) 12. Re: Is Python suitable for a huge, enterprise size app? (Dave Brueck) 13. Re: Process monitoring (John Abel) 鍙戜欢浜: Peter Hansen <pe***@engcorp.com> 鏀朵欢浜: py*********@python.org 鏃ユ湡: Fri, 20 May 2005 16:12:17 -0400 涓婚: Re: appending key-value pairs to a dict
rbt wrote: I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put
the file's name and its sha hash into a dict on each loop.
Whereas with a list you would call "append" in the loop, with a dictionary you simply use an indexed-assignment type of access:
mydict = {} for filename in some_list_of_filenames: hash = sha.sha(open(filename).read()).hexdigest() # or whatever mydict[filename] = hash
-Peter
鍙戜欢浜: Paul Rubin <http://ph****@NOSPAM.invalid> 鏀朵欢浜: py*********@python.org 鏃ユ湡: 20 May 2005 13:12:50 -0700 涓婚: Re: Is Python suitable for a huge, enterprise size app?
Dave Brueck <da**@pythonapocrypha.com> writes: One thing from your experience that did resonate with me is that, except for ftplib and occasionally urllib (for basic, one-shot GETs), we don't use any of the standard library's "protocol" modules - partly because we had to implement our own HTTP libraries for performance and scalability reasons anyway, and partly because we had trouble figuring out e.g. all the ins and outs of urllib/urllib2/httplib.
What do you use for HTTPS? And did you use the Cookie module in your HTTP servers? You may have had problems without even being aware of them (until recently if you used Cookie with its default settings, any attacker could completely take over your server by sending you carefully concoted cookies). I'm not trying to be contentious here, just mentioning a couple further cases of where problems aren't visible from far away but are there when you look close.
鍙戜欢浜: Brian Beck <ex****@gmail.com> 鏀朵欢浜: py*********@python.org 鏃ユ湡: Fri, 20 May 2005 16:14:17 -0400 涓婚: Re: appending key-value pairs to a dict
rbt wrote: I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put
the file's name and its sha hash into a dict on each loop.
Like so:
d = {} for filename in files: d[sha_func(filename)] = filename
Or like so:
d = dict([(sha_func(filename), filename) for filename in files])
-- Brian Beck Adventurer of the First Order
鍙戜欢浜: Skip Montanaro <sk**@pobox.com> 鎶勯: py*********@python.org 鏀朵欢浜: Steve Holden <st***@holdenweb.com> 鏃ユ湡: Fri, 20 May 2005 15:16:49 -0500 涓婚: Re: Comparing 2 similar strings?
Steve> (is this the same as 'Conchobar'?)
No, that's a trendy pub in Key West...
<wink>
Skip
鍙戜欢浜: Paul Rubin <http://ph****@NOSPAM.invalid> 鏀朵欢浜: py*********@python.org 鏃ユ湡: 20 May 2005 13:15:48 -0700 涓婚: Re: Is Python suitable for a huge, enterprise size app?
"Fredrik Lundh" <fr*****@pythonware.com> writes: this has been reported before, and it won't get fixed (unless you're volunteering to add Python-compatible garbage collection to Tk, that is).
Yeah, I think I understand what the issue is. I can think of some kludgy possible fixes but I assume they've been thought about already and rejected. The workaround of making the application save an extra reference isn't too bad, but all relevant docs that say anything about these images should mention the requirement emphatically.
鍙戜欢浜: "as*****@gmail.com" <do*****@gmail.com> 鏀朵欢浜: py*********@python.org 鏃ユ湡: 20 May 2005 13:18:33 -0700 涓婚: Re: buffer_info error
i am filling in a packet with source and destination address and using the buffer_info call to pass on the address to an underlying low level call.
The src and dest are strings, but buffer_info expects an array. How do i deal with this?
鍙戜欢浜: James Stroud <js*****@mbi.ucla.edu> 鏀朵欢浜: py*********@python.org 鏃ユ湡: Fri, 20 May 2005 13:20:48 -0700 涓婚: Re: appending key-value pairs to a dict
On Friday 20 May 2005 01:04 pm, rbt wrote: I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put
the file's name and its sha hash into a dict on each loop.
Many thanks,
rbt
Simple assignment.
adict[filename] = an_sha_hash -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095
http://www.jamesstroud.com/
鍙戜欢浜: Vijay Kumar <ge******@gmail.com> 鎶勯: vs******@cs.nmsu.edu 鏀朵欢浜: py*********@python.org 鏃ユ湡: Fri, 20 May 2005 14:21:33 -0600 涓婚: From the call hook, how do I know more precisely what is called?
Hi,
I wrote a trace function using the profiling and tracing hooks provided by the python interpreter.
The Python interpreter reports the calls occuring in the source program to my trace function.
How can I know whether the call happened is a function call or method call and if it is a method call what is its self object and/or class is?.
I receive a frame object from the interpreter for every call.
Thanks, Vijay.
鍙戜欢浜: Lee Harr <le*@example.com> 鏀朵欢浜: py*********@python.org 鏃ユ湡: Fri, 20 May 2005 20:38:45 GMT 涓婚: Re: PyGame and Rotozoom (Sorry if OT)
On 2005-05-20, J. W. McCall <jm*****@houston.rr.com> wrote: I'm not sure if this is off-topic, since it doesn't deal with Python itself, but here goes:
I'm messing around with writing a simple "game" where the player (a crudely drawn smiley face) moves by rotating and moving back or forward (think Resident Evil, but from an always-above view). After much hacking, I have it working where left and right rotate the player sprite and up always moves the sprite whichever direction it's facing, while down is reverse. I'm using pygame.transform.RotoZoom(). My problem is that it doesn't rotate smoothly.
When it rotates, the corners of the image (just a plain white background) look like they're hitting some barrier and making it move around. Think of an empty box turned diagonally (so that it looks like a diamond, with its open end facing you), and a cube in that box being turned while it's resting in the bottom corner. I want it to rotate smoothly around its center, it's it's not doing that.
I'm guessing that it has something to do with me not setting up a Rect right, but I'm not sure. Maybe this is a limitation of Rotozoom/Rotate? Any advice would be greatly appreciated. And yes,
I'm a rank PyGame newbie. You might want to try pygsear: http://www.nongnu.org/pygsear/
It has a RotatedImage class which takes care of rotating things for you. See the examples roti.py and wings.py for some use of rotated image sprites.
鍙戜欢浜: Jp Calderone <ex*****@divmod.com> 鏀朵欢浜: py*********@python.org 鏃ユ湡: Fri, 20 May 2005 20:45:00 GMT 涓婚: Re: buffer_info error
On 20 May 2005 13:18:33 -0700, "as*****@gmail.com" <do*****@gmail.com> wrote:i am filling in a packet with source and destination address and usingthe buffer_info call to pass on the address to an underlying low levelcall.
The src and dest are strings, but buffer_info expects an array. How doi deal with this?
What's the low-level call you're invoking?
Jp
鍙戜欢浜: ro*@panix.com (Roy Smith) 鏀朵欢浜: py*********@python.org 鏃ユ湡: 20 May 2005 16:50:39 -0400 涓婚: Re: appending key-value pairs to a dict
rbt <rb*@athop1.ath.vt.edu> wrote:I know how to setup an empty list and loop thru something... appendingto the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put
the file's name andits sha hash into a dict on each loop.
You just assign values to keys. If the key doesn't exist, it's created automagically. You want something like this:
shaDict = {} for fileName in fileNameList: hash = generateShaHash (fileName) shaDict[hash] = fileName
鍙戜欢浜: Dave Brueck <da**@pythonapocrypha.com> 鏀朵欢浜: py*********@python.org 鏃ユ湡: Fri, 20 May 2005 15:07:05 -0600 涓婚: Re: Is Python suitable for a huge, enterprise size app?
Paul Rubin wrote: Dave Brueck <da**@pythonapocrypha.com> writes:
>One thing from your experience that did resonate with me is that,>except for ftplib and occasionally urllib (for basic, one-shot GETs),>we don't use any of the standard library's "protocol" modules - partly>because we had to implement our own HTTP libraries for performance and>scalability reasons anyway, and partly because we had trouble figuring>out e.g. all the ins and outs of urllib/urllib2/httplib.
What do you use for HTTPS?
Hi Paul,
m2crypto (plus some patches to make asynchronous SSL do what we needed).
And did you use the Cookie module in your HTTP servers? You may have had problems without even being aware of them (until recently if you used Cookie with its default settings, any attacker could completely take over your server by sending you carefully concoted cookies).
Are you referring to the use of pickle for cookie serialization? In any case, we didn't use Cookie.py from the stdlib (on the servers, nearly everything related to URLs & HTTP was custom-built, with the exception of urlparse, for the aforemenioned reasons).
-Dave
鍙戜欢浜: John Abel <jo*******@btinternet.com> 鎶勯: py*********@python.org 鏃ユ湡: Fri, 20 May 2005 22:24:14 +0100 涓婚: Re: Process monitoring
gsteff wrote:
Hey, I'm working on a Python program that will launch some othernon-Python process using os.spawn (in the os.P_NOWAIT mode) and thenbasically wait for it to finish (while doing some other stuff in theinterim). Normally, the new process will signal that it's done bywriting to a file, but I'd like to also find out if the new processdied unexpectedly. Anyone know any preferrable ways to do this? Greg Steffensen
If you're using 2.4, have a look at the subprocess module.
J
-- http://mail.python.org/mailman/listinfo/python-list I am a beginner,Can you introduce some book about python? I am a student of china
__________________________________________________ _______ Do You Yahoo!? 150涓囨洸MP3鐤媯鎼滐紝甯︽偍闂叆闊充箰娈垮* http://cn.rd.yahoo.com/mail_cn/tag/y...sic.yisou.com/ 缇庡コ鏄庢槦搴旀湁灏芥湁锛屾悳閬嶇編鍥俱佽壋鍥惧 岄叿鍥 http://cn.rd.yahoo.com/mail_cn/tag/y...mage.yisou.com 1G灏辨槸1000鍏嗭紝闆呰檸鐢甸偖鑷姪鎵╁锛 http://cn.rd.yahoo.com/mail_cn/tag/1...event/mail_1g/
Am Samstag, 21. Mai 2005 08:59 schrieb rd*****@mac.com: <snip>
Quoting a senseless quote, bravo!
...
wasting-bandwith-sure-is-fun-over-ISDN-'ly yours,
--
--- Heiko.
see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQBCjvoOf0bpgh6uVAMRAv+MAJsFZIET+fn6+EuJqz+TMn Aq9HD0qQCff46s
w4icSkQnMmtnq9IjMpA0e7A=
=UQEK
-----END PGP SIGNATURE-----
if u r come from china, maybe python.cn is a good start :) This discussion thread is closed Replies have been disabled for this discussion. Similar topics
40 posts
views
Thread by post400 |
last post: by
|
23 posts
views
Thread by Anthony |
last post: by
|
14 posts
views
Thread by Eduardo Patto Kanegae |
last post: by
|
8 posts
views
Thread by Paddy McCarthy |
last post: by
|
5 posts
views
Thread by Madhusudan Singh |
last post: by
|
8 posts
views
Thread by David Rasmussen |
last post: by
|
23 posts
views
Thread by IOANNIS MANOLOUDIS |
last post: by
|
15 posts
views
Thread by dhr |
last post: by
|
6 posts
views
Thread by dogatemycomputer |
last post: by
| | | | | | | | | | |