ANN: Cheesecake Service launched and Cheesecake 0.6.1 released
Thanks to the hard work of Michal Kwiatkowski, I'm proud to announce the launch of the Cheesecake Service (http://pypi.pycheesecake.org/ pypi/) and the release of Cheesecake 0.6.1 (http://python.org/pypi/ Cheesecake/0.6.1). Details here: http://mousebender.wordpress.com/2007/02/09/cheesecake-for-all/ http://agiletesting.blogspot.com/2007/02/cheesecake-service-launched.html Grig -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
FlightFeather Social Networking Platform 0.3.3
FlightFeather's goal is social networking for everyone. This means that *anyone* should have a chance to run a *popular* social networking site -- on minimal hardware, and without wasting bandwidth. Version 0.3.3 is the current development release. It modifies the way the FlightFeather server loads the configuration, protocol, session, and storage modules on startup. The actual loading process now takes place after all options have been parsed. If the -c or --command option is present, the server does not import these modules at all, since they are not required. The new implementation also fixes a bug that caused the test versions of the above modules to always load, in addition to any modules specified on the command line. The current beta release of FlightFeather is 0.2.8. You can download these releases (free/open source under the GPL) from the BoSStats site, which runs on FlightFeather. http://www.bosstats.com/flightfeather.html You are always welcome to participate in the discussion on the BoSStats site; the topic covered (what makes a good boss, office politics, etc.) is valuable in and of itself. Please, however, refrain from posting test comments, as the site is live. A Brief Overview of FlightFeather and BoSStats -- You can see FlightFeather in action on the BoSStats site. BoSStats is dedicated to improving the world of work: you can discuss what makes a good boss, or share your experiences of office politics. You can also comment and vote on the posts made by others. The application does not set cookies, and no registration is required for anything except voting. http://www.bosstats.com/ BoSStats is a good testbed for FlightFeather, and has value of its own, since meaningful advice about work-related problems is very hard to find. A Wisdom of Crowds solution -- particularly with strong privacy protection (see below) -- is a necessary addition to this field. FlightFeather's most important feature is that all write requests generate (or modify) HTML files. In consequence, a pure read (the most common operation) merely serves static pages. The major design focus for FlightFeather are responsiveness and performance; the system should eventually support very high traffic volumes. In addition, FlightFeather allows for a great deal of user privacy -- a critical, rapidly emerging problem in the social networking realm. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
NYC Python User Group Meeting
Greetings! The next New York City Python Users Group meeting is this Tuesday, Feb. 13th, 6:30pm at at the Millennium Partners office at 666 Fifth Avenue (53rd St. and 5th Ave.) on the 8th Floor. We welcome all those in the NYC area who are interested in Python to attend. However, we need a list of first and last names to give to building security to make sure you can gain access to the building. RSVP to [EMAIL PROTECTED] to add your name to the list. More information can be found on the yahoo group page: http://tech.groups.yahoo.com/group/nycpython/ Hope to see you there! -John -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: interacting with shell - another newbie question
James wrote: Hello, I work in this annoying company where I have to autheticate myself to the company firewall every 30-50 minutes in order to access the internet. (I think it's a checkpoint fw). I have to run telnet what.ever.ip.address 259 then it prompts me with userid, then password, then I have to select 1. Then the program closes itself and the internet is enabled. I would like to automate this process with Python and run it every 30 miniutes so I don't have to keep typing in these userid/password everytime. How can this be done? Is there a module I can use to interact with the shell? (I'm running linux) Thank you. James Sounds like the perfect way to get fired. To be sure though, remember to store your password in clear text ;) However bizarre the security measures seem it's obviously in place to make sure it's *you* sitting at the computer. Scripting the authentication process is equal to simply removing it. -- http://mail.python.org/mailman/listinfo/python-list
Re: interacting with shell - another newbie question
Tina I wrote: James wrote: Hello, I work in this annoying company where I have to autheticate myself to the company firewall every 30-50 minutes in order to access the internet. (I think it's a checkpoint fw). I have to run telnet what.ever.ip.address 259 then it prompts me with userid, then password, then I have to select 1. Then the program closes itself and the internet is enabled. I would like to automate this process with Python and run it every 30 miniutes so I don't have to keep typing in these userid/password everytime. How can this be done? Is there a module I can use to interact with the shell? (I'm running linux) Thank you. James Sounds like the perfect way to get fired. To be sure though, remember to store your password in clear text ;) However bizarre the security measures seem it's obviously in place to make sure it's *you* sitting at the computer. Scripting the authentication process is equal to simply removing it. Yes, and finding ways to have employees pointlessly waste time is equal to simply removing them. -- http://mail.python.org/mailman/listinfo/python-list
Re: pycallgraph 0.1.0
Gerald Kaszuba wrote: On 2/10/07, Stef Mientki [EMAIL PROTECTED] wrote: ... but isn't __main__. non-information ? Good point -- I'll consider removing it in the next version. Does the 404 error on http://pycallgraph.slowchop.com/files/examples/mongballs-client.png indicate you are subject to the slashdot effect? regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Blog of Note: http://holdenweb.blogspot.com See you at PyCon? http://us.pycon.org/TX2007 -- http://mail.python.org/mailman/listinfo/python-list
Re: Glob returning an empty list when passed a variable
Steven D'Aprano wrote: On Fri, 09 Feb 2007 14:15:51 +, Steve Holden wrote: area_name_string = '*% s*' % (Area_name) Interesting, I never realised until now that you can have spaces between the percent sign and th format effector. Space is one of the flags. From the docs: The conversion flag characters are: Flag Meaning # The value conversion will use the ``alternate form'' (where defined below). 0 The conversion will be zero padded for numeric values. - The converted value is left adjusted (overrides the 0 conversion if both are given). (a space) A blank should be left before a positive number (or empty string) produced by a signed conversion. + A sign character (+ or -) will precede the conversion (overrides a space flag). http://docs.python.org/lib/typesseq-strings.html % s % 'banana' 'banana' % s % 1 '1' % s % -1 '-1' Since it appears non-operative in the case of strings I'd be tempted to leave it out, though my original post was triggered by my surprise that I'd not seen the feature before. There are no limits to my ignorance :) regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Blog of Note: http://holdenweb.blogspot.com See you at PyCon? http://us.pycon.org/TX2007 -- http://mail.python.org/mailman/listinfo/python-list
Re: interacting with shell - another newbie question
James Stroud wrote: Tina I wrote: James wrote: Hello, I work in this annoying company where I have to autheticate myself to the company firewall every 30-50 minutes in order to access the internet. (I think it's a checkpoint fw). I have to run telnet what.ever.ip.address 259 then it prompts me with userid, then password, then I have to select 1. Then the program closes itself and the internet is enabled. I would like to automate this process with Python and run it every 30 miniutes so I don't have to keep typing in these userid/password everytime. How can this be done? Is there a module I can use to interact with the shell? (I'm running linux) Thank you. James Sounds like the perfect way to get fired. To be sure though, remember to store your password in clear text ;) However bizarre the security measures seem it's obviously in place to make sure it's *you* sitting at the computer. Scripting the authentication process is equal to simply removing it. Yes, and finding ways to have employees pointlessly waste time is equal to simply removing them. The clue, of course, is right there at the start of the original post: I work at this annoying company What the OP really needs is a new employer if it's impossible to do anything about the policy. The company and the employee are clearly incompatible. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Blog of Note: http://holdenweb.blogspot.com See you at PyCon? http://us.pycon.org/TX2007 -- http://mail.python.org/mailman/listinfo/python-list
Re: pygame and python 2.5
Hendrik van Rooyen wrote: [EMAIL PROTECTED] wrote: Ben Sizer [EMAIL PROTECTED] wrote: Ben Python extensions written in C require recompilation for each new Ben version of Python, due to Python limitations. Can you propose a means to eliminate this limitation? Yes. - Instead of calling something, send it a message... I suppose you are proposing to use the ISO 1.333 generic message-passing interface for this? The one that doesn't actually call a function to pass a message? regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Blog of Note: http://holdenweb.blogspot.com See you at PyCon? http://us.pycon.org/TX2007 -- http://mail.python.org/mailman/listinfo/python-list
Re: python linux distro
Szabolcs Nagy wrote: Now what would be interesting (and *really* crazy) would be Linux (or BSD or whatever) distro written almost entirely *in* Python, with the goal of eliminating as much bash/sh as possible. That would be fun. actually there was(is) an os whitch is written almost entirely *in* Python: http://en.wikipedia.org/wiki/Unununium_(operating_system) (their main site http://unununium.org seems to be down) ^was(is)^may one day be, but probably not,^ From the quoted page: The project is in an early development phase and as of January 2007, no significant progress was being made due to lack of developer time.[5] regards Steve [5]: links to a dead server -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Blog of Note: http://holdenweb.blogspot.com See you at PyCon? http://us.pycon.org/TX2007 -- http://mail.python.org/mailman/listinfo/python-list
Need a cross-platform way to execute binary
Hello, everyb. Does anybody know simple cross-platform method of probing if executable binary is available and launching it. Problem no.1: test if executable file is available I'll take windows platform as the most relevant in this case. os.access() doesn't handle env PATHEXT and can't detect if a given path would be executable or not. Here executable means file that could be be launched by system() (if there are any other ways - I'd be happy to know them) Suppose I have ufo2exe executable two directories up. os.access(../../ufo2map.exe, os.X_OK) True However... os.access(../../ufo2map, os.X_OK) False But... os.system(..\..\ufo2map) ufo2map 1.0 0 Problem no.2: launch executable file The same windows platform again. All python commands are using forward slashes for paths, but system doesn't handle this situation (it could at least try to convert immediate forward slashes to backwards) os.access() thinks this file is executable, but os.system() fails ... os.access(../../ufo2map.exe, os.X_OK) True os.system(../../ufo2map.exe) '..' is not recognized as an internal or external command, operable program or batch file. 1 the contrary - access() fails to tell this path can be launched, but file Is executable, ... os.access(..\..\ufo2map, os.X_OK) False os.system(..\..\ufo2map) ufo2map 1.0 0 Is there any workaround in Python or I have to stick with platforms- specific quirks? I'm using Python 2.4.2 Thanks!. -- --t. -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding, import site, PYTHONHOME, and an old, old issue
En Sat, 10 Feb 2007 03:57:05 -0300, Jim Hill [EMAIL PROTECTED] escribió: I want to do a simple embed, so I've followed the example in the Extending and Embedding documentation: In the .c file, #include Python.h int routine() { Py_Initialize(); PyRun_SimpleString(from time import time,ctime\n print 'Today is',ctime(time())\n); Py_Finalize(); return 0; } (Why routine() and not main()? Unfortunately you can't repeteadly initialize/finalize the interpreter, you must do that only once.) The code compiles just fine, but when I execute it the call to Py_Initialize() comes back with: 'import site' failed; use -v for traceback Traceback (most recent call last): File string, line 1, in module ImportError: No module named time Try this: PyRun_SimpleString(import sys; print sys.path); to see where Python expects to find its library (or call the Py_GetPath function). You may need to call Py_SetProgramName (before Py_Initialize) so it can find where the standard library resides. At least for testing purposes, you can copy your executable into the same directory where Python is installed. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Calling J from Python
Alexander Schmolck wrote: how would you code a program that gives the following output ('skewed' sierpinski-triangle) in python? * ** * * * * ** ** * * * * * * ** ** * * * * * * * * ** ** ** ** * * * * * * * * ### def print_sierpinski(order): size = 4 * 2 ** order buffer = [size * [ ] for i in range(size)] put_sierpinski(buffer, size, 0, 0) for line in buffer: print .join(line) def put_sierpinski(buffer, size, x, y): if size == 4: put_triangle(buffer, size, x, y) else: size2 = size / 2 put_sierpinski(buffer, size2, x, y) put_sierpinski(buffer, size2, x, y + size2) put_sierpinski(buffer, size2, x + size2, y + size2) def put_triangle(buffer, size, x, y): for i in range(3): buffer[y + i][x] = buffer[y + i][x + i] = * for i in range(4): buffer[y + 3][x + i] = * print_sierpinski(2) ### By making the recursion explicit, I think this brings out the self-similarity better than any of the other solutions posted, which are very clever but not what I would call lucid. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: pycallgraph 0.1.0
http://pycallgraph.slowchop.com/files/examples/mongballs-client.png indicate you are subject to the slashdot effect? Steve, No /. effect :) I rearranged some files around because of the new version of pycallgraph. The new preview image is: http://pycallgraph.slowchop.com/pycallgraph/wiki/RegExpExample Gerald -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a cross-platform way to execute binary
En Sat, 10 Feb 2007 06:03:40 -0300, techtonik [EMAIL PROTECTED] escribió: Hello, everyb. Does anybody know simple cross-platform method of probing if executable binary is available and launching it. Problem no.1: test if executable file is available I'll take windows platform as the most relevant in this case. os.access() doesn't handle env PATHEXT and can't detect if a given path would be executable or not. Here executable means file that could be be launched by system() (if there are any other ways - I'd be happy to know them) Suppose I have ufo2exe executable two directories up. os.access(../../ufo2map.exe, os.X_OK) True However... os.access(../../ufo2map, os.X_OK) False That's right - such file does not exist. On Windows, in general, X_OK is the same as F_OK: for any existing file, whatever name or extension, returns True. Permissions are managed thru ACL and this simple function does NOT consider them. But... os.system(..\..\ufo2map) ufo2map 1.0 0 (Beware of single \ on normal strings!) Use win32api.FindExecutable; should return the full path to ufo2map.exe. foo.txt would return notepad.exe (or whatever you have associated to text files). That is exactly what would be launched by os.system(foo.txt) Problem no.2: launch executable file The same windows platform again. All python commands are using forward slashes for paths, but system doesn't handle this situation (it could at least try to convert immediate forward slashes to backwards) Use os.path.normpath on the filename. (If you got it from FindExecutable above, that would not be needed) os.access() thinks this file is executable, but os.system() fails ... os.access(../../ufo2map.exe, os.X_OK) True os.system(../../ufo2map.exe) '..' is not recognized as an internal or external command, operable program or batch file. 1 the contrary - access() fails to tell this path can be launched, but file Is executable, ... os.access(..\..\ufo2map, os.X_OK) False Same as above - such file does not exist. os.system(..\..\ufo2map) ufo2map 1.0 0 Is there any workaround in Python or I have to stick with platforms- specific quirks? I'm using Python 2.4.2 I think you will have to treat each platform differently. Just for starting, the concept of executable is not the same across platforms. But you could make some generic functions (with different implementations on different platforms). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Calling J from Python
George Sakkis [EMAIL PROTECTED] wrote: On Feb 9, 9:20 pm, [EMAIL PROTECTED] wrote: This is a bit simpler, but probably there are simpler solutions using modular arithmetic: l = [1] for _ in range(15): print ''.join( *[x] for x in l) l = [1] + [l[i+1]^l[i] for i in range(len(l)-1)] + [1] Bye, bearophile Here's another one, adapted from the example (in Java) in Wikipedia's entry (http://en.wikipedia.org/wiki/Sierpinski_triangle): N=15 for x in xrange(N,0,-1): print ''.join('* '[xy!=0] for y in xrange(N+1-x)) This is my solution after a few minutes thought. It uses a different algorithm for generating the triangle. If python could output binary numbers it would be more elegant... n = 1 for i in range(16): ... print (%X % n).replace('0', ' ').replace('1', '*') ... n = n ^ (n 4) ... * ** * * * * ** ** * * * * * * ** ** * * * * * * * * ** ** ** ** * * * * * * * * -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: python linux distro
^was(is)^may one day be, but probably not,^ From the quoted page: The project is in an early development phase and as of January 2007, no significant progress was being made due to lack of developer time.[5] well actually i managed to boot unununium in qemu so it _is_ an os but obviously there isn't much code and the devs gave up so that's why it _was_ an os project anyway it was not an os about python, but a desktop os with a highly different approach from current os-es they just happen to use a lot of python there were a lot of interesting ideas so the mail archives might be useful for anyone who is interested in os development http://unununium.org/pipermail/uuu-devel/ -- http://mail.python.org/mailman/listinfo/python-list
Wait for keypress
At the moment, I have a command-line application -- http://mail.python.org/mailman/listinfo/python-list
Wait for keypress
At the moment, I have a command-line application which prints out quite a lot of text to the screen. However, when Windows users run it, the prompt disappears before they can read any of it. Is there any simple way to make a script wait for a keypress before completing? Thanks for any help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Wait for keypress
Sorry, accidental key presses before I finished... -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a cross-platform way to execute binary
On Feb 10, 12:03 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: Does anybody know simple cross-platform method of probing if executable binary is available and launching it. Problem no.1: test if executable file is available I'll take windows platform as the most relevant in this case. os.access() doesn't handle env PATHEXT and can't detect if a given path would be executable or not. Here executable means file that could be be launched by system() (if there are any other ways - I'd be happy to know them) Suppose I have ufo2exe executable two directories up. os.access(../../ufo2map.exe, os.X_OK) True However... os.access(../../ufo2map, os.X_OK) False That's right - such file does not exist. On Windows, in general, X_OK is the same as F_OK: for any existing file, whatever name or extension, returns True. Permissions are managed thru ACL and this simple function does NOT consider them. It shouldn't matter if the file exists or not. Quoting http:// docs.python.org/lib/os-file-dir.html: X_OK Value to include in the mode parameter of access() to determine if path can be executed. See - there is no file notation as only path is tested and path is pretty executable. I think this should be clarified in os.access() documentation to make the whole business less confusing if not implemented in interpreter itself. After all the purpose of cross- platform language is to free developer from writing platform-specific code. But... os.system(..\..\ufo2map) ufo2map 1.0 0 (Beware of single \ on normal strings!) Use win32api.FindExecutable; should return the full path to ufo2map.exe. foo.txt would return notepad.exe (or whatever you have associated to text files). That is exactly what would be launched by os.system(foo.txt) Why isn't it possible to integrate the functionality in os.access() - IIUC Python interpreter still uses Windows API itself on this platform. Problem no.2: launch executable file The same windows platform again. All python commands are using forward slashes for paths, but system doesn't handle this situation (it could at least try to convert immediate forward slashes to backwards) Use os.path.normpath on the filename. (If you got it from FindExecutable above, that would not be needed) os.access() thinks this file is executable, but os.system() fails ... os.access(../../ufo2map.exe, os.X_OK) True os.system(../../ufo2map.exe) '..' is not recognized as an internal or external command, operable program or batch file. 1 the contrary - access() fails to tell this path can be launched, but file Is executable, ... os.access(..\..\ufo2map, os.X_OK) False Same as above - such file does not exist. Same as above - access() tests path, not file, so the argument is not valid. os.system(..\..\ufo2map) ufo2map 1.0 0 Is there any workaround in Python or I have to stick with platforms- specific quirks? I'm using Python 2.4.2 I think you will have to treat each platform differently. Just for starting, the concept of executable is not the same across platforms. But you could make some generic functions (with different implementations on different platforms). I would prefer to know as little about underlying platforms as possible. It would only be a big plus for Python. -- --t. -- http://mail.python.org/mailman/listinfo/python-list
Re: Wait for keypress
[EMAIL PROTECTED] wrote: At the moment, I have a command-line application which prints out quite a lot of text to the screen. However, when Windows users run it, the prompt disappears before they can read any of it. Is there any simple way to make a script wait for a keypress before completing? Thanks for any help. At the end of your program just add: raw_input(Press Enter to terminate) regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Blog of Note: http://holdenweb.blogspot.com See you at PyCon? http://us.pycon.org/TX2007 -- http://mail.python.org/mailman/listinfo/python-list
Unicode is confusing me
As per p. 188 of Python for Dummies, I've created a sitecustomize.py in my site-packages directory: # sitecustomize.py (see p.188 of Python for Dummies) import sys sys.setdefaultencoding('utf-8') === With that in place, at the interactive prompt this goes well: === import sys sys.getdefaultencoding() 'utf-8' a = [u'\u91cd', u'\u8981', u'\u6027'] for x in range(3): . . . print a[x], . . . 重 要 性 === The 3 CJK characters are printed very nicely. However, when I put the last 3 lines of that code in a script, a = [u'\u91cd', u'\u8981', u'\u6027'] for x in range(3): print a[x] === and redirect the output to a text file, I get Traceback (most recent call last): File E:\Python25\dev\Untitled1.py, line 3, in ? print a[x] UnicodeEncodeError: 'ascii' codec can't encode character u'\u91cd' in position 0: ordinal not in range(128) I thought maybe it would help if I made the first line, # -*- coding: utf-8 -*- but that made no difference. Got the same error. Can someone help me understand what's going on? Thanks, Dick Moores -- my configuration: Win XP Pro SP2 Python 2.5 wxPython 2.8.1.1 Unicode Python IDE: Ulipad 3.6 -- http://mail.python.org/mailman/listinfo/python-list
Re: pycallgraph 0.2.0
Gerald Kaszuba wrote: Hi I just released a new version of pycallgraph. It has many improvements over 0.1.0. Here is an example of a call graph made in pycallgraph 0.2.0: http://pycallgraph.slowchop.com/pycallgraph/wiki/RegExpExample There are more examples on the web site: http://pycallgraph.slowchop.com/ The changes are: * Windows access denied bug fixed * graph uses different colours depending on the number of calls made to the function * graph settings and look are very customisable * exclude and include filters * stop_trace() is not required anymore, it is called automatically by make_graph() * will throw an exception if there is an error from dot/neato * removed obvious use of __main__ as the module name * added some examples There is no documentation yet but if you browse the source you'll be able to figure out a lot. Enjoy! Gerald looks very good Gerald, thanks ! My first test was terrible: a file of 800kB was created, Trying to view it, resulted in the following: - Paint Shop Pro told me it was not a valid PNG file, - Mozilla crashed after 5 minutes, - GIMP gave me a preview after half an hour ;-) So a few suggestions: - is there a way to limit the number of nodes ? - pycallgraph. nodes are non-information (maybe you can find another way to place your signature ;-) - how do I exclude modules/files/objects (sorry I'm still a newbie in Python) cheers, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Distributing Python Applications
Hello, It has been such a painful thing for me. As I made a program to encrypt files, now I want to distribute that program over other computers. I created .EXE file with py2exe but the dist folder makes around 2 mb and it restricts for the python DLL to be within the same folder. Is there any easy way to get this thing done in just one exe file? I mean if I do interfacing with C/C++ will it work for me and if I do interfacing with C/C++ will it be necessary on the other computer to have python installed on it? Thanks in advance... -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Question
John wrote: Visual Basic is also good. For what -- headache? 8) Regards, Björn -- BOFH excuse #62: need to wrap system in aluminum foil to fix problem -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a cookie with cookielib
I'm going to post this if it kills me (this was my first response in this thread, my normal newsfeed has gone bad so can't post reliably...) Alessandro Fachin [EMAIL PROTECTED] writes: Hi, i am trying to forge a new cookie by own with cookielib. But i don't still have success. This a simply code: import cookielib, urllib, urllib2 login = 'Ia am a cookie!' cookiejar = cookielib.CookieJar() urlOpener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar)) values = {'user':login} data = urllib.urlencode(values) request = urllib2.Request(http://localhost/cookie.php;, data) url = urlOpener.open(request) print url.info() page = url.read(50) print page print cookiejar the output of this is: Date: Sat, 03 Feb 2007 10:20:05 GMT Server: Apache X-Powered-By: PHP/5.1.6 Set-Cookie: user=Alex+Porter; expires=Sat, 03-Feb-2007 11:20:05 GMT Content-Length: 11 Connection: close Content-Type: text/html; charset=UTF-8 Array ( ) cookielib.CookieJar[Cookie user=Alex+Porter for localhost.local/] So the server has sent you a cookie back, and cookielib accepted it. Success! What your PHP program prints out is information about cookies that were received *from* the browser (or from your script, in this case). It does not print information about cookies that it is sending *to* the browser. Your PHP program is not a time machine, so it can't print out information about a cookie that was *not there* in the request you sent. And the cookie was not there in the request you sent because the server hadn't sent the cookie yet! Send a second request (either in the same run of your program, or by saving and loading the cookies), and you should see a cookie sent back to the server (and then printed out by your PHP script in the response you get back). Web sites and web applcations sometimes use a trick like a using a redirect or Refresh to get the browser to send a second request, so that they get the cookie they set sent back to the server again, without the user needing to perform any second action. Also note that saving and loading cookies with cookielib will by default drop session cookies, unless you explicitly ask otherwise. John -- http://mail.python.org/mailman/listinfo/python-list
Re: multithreading concept
Carl J. Van Arsdall wrote: Not necessarily, if he's on a full duplex ethernet connection, then there is some parallelity he can take advantage of. He has upstream and downstream. Partly agreed. There is one bus to the network device, and CPU should be very much faster than the network device itself, so I estimate there'll be no gain. Regards, Björn -- BOFH excuse #353: Second-system effect. -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 hangs forever where there is no network interface
[EMAIL PROTECTED] (John J. Lee) writes: (I'm having news trouble, sorry if anybody sees a similar reply three times...) dumbkiwi [EMAIL PROTECTED] writes: On Feb 2, 5:02 am, [EMAIL PROTECTED] (John J. Lee) wrote: dumbkiwi [EMAIL PROTECTED] writes: [...] If there is no network interface, urllib2 hangs for a very long time before it raises an exception. I have set the socket timeout with socket.setdefaulttimeout(), however, where there is no network interface, this seems to be ignored - presumably, because without a network interface, there is nothing for the socket module to interact with. [...] Presumably Windows? (Unix systems almost always have at least a loopback interface) John Sorry, I should have been more specific. The network interfaces are up - ie lo and eth1, it's where the wireless connection has dropped out. The underlying problem is that Python's socket timeout is implemented using select() or poll(). Those system calls only allow timing out activity on file descriptors (e.g. sockets). The problem you're seeing is caused by getaddrinfo() blocking for a long time, and that function doesn't involve file descriptors. The problem should really be fixed at the C level (in Modules/socketmodule.c), using something like alarm() or a thread to apply a timeout to getaddrinfo() calls. Seems doing this portably with threads is a bit of a nightmare, actually. You'd have to extend every one of CPython's thread implementations (pthreads, Solaris threads, etc. etc. etc.) -- and I don't even know if it's possible on all systems. And since the GIL is released around the getaddrinfo() call in socketmodule.c (and that can't be changed), one can't guarantee that a Python thread won't set a different signal handler, so alarm() is not good. And of course Windows is a separate case. Is the best solution to test for a wireless connection through / proc before trying to download data? That may be a good practical solution. Another workaround that might be useful is to do your DNS lookups only once, then use only IP addresses. The portable way to actually solve what I assume is your underlying problem (latency in a GUI) is to have a Python thread or separate process do your urlopen()s (this can be done at the Python level). John -- http://mail.python.org/mailman/listinfo/python-list
Re: Distributing Python Applications
[EMAIL PROTECTED] wrote: Hello, It has been such a painful thing for me. As I made a program to encrypt files, now I want to distribute that program over other computers. I created .EXE file with py2exe but the dist folder makes around 2 mb and it restricts for the python DLL to be within the same folder. Is there any easy way to get this thing done in just one exe file? I mean if I do interfacing with C/C++ will it work for me and if I do interfacing with C/C++ will it be necessary on the other computer to have python installed on it? Thanks in advance... No need for python to be installed. Don't worry about 2 MB downloads. Probably, if users are savvy enough to need encryption, they have the download speeds and hard drive space to handle 2 MB. Check out pyinstaller also, but what your really need is Innosetup. Its beautiful. James -- http://mail.python.org/mailman/listinfo/python-list
Re: Distributing Python Applications
En Sat, 10 Feb 2007 09:21:29 -0300, [EMAIL PROTECTED] escribió: It has been such a painful thing for me. Ouch... why was that? Programming in Python, or using py2exe? As I made a program to encrypt files, now I want to distribute that program over other computers. I created .EXE file with py2exe but the dist folder makes around 2 mb and it restricts for the python DLL to be within the same folder. Is there any easy way to get this thing done in just one exe file? Perhaps... but what would you gain? Most programs include, apart from the main executable: manual, license, readme file, release notes, installation guide, other resources, etc. You can use an installer like Inno Setup to package nicely all required pieces into a single distributable file. For simple programs, even a self-extracting .zip would suffice. I mean if I do interfacing with C/C++ will it work for me and if I do interfacing with C/C++ will it be necessary on the other computer to have python installed on it? I don't understand what are you asking... You can extend and/or embed Python using C. And you already know py2exe, obviously: the idea is to *not* require a previous Python install in order to run your application. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
[off-topic] Maximum TCP Server Connections
Sorry this question isn't strictly Python-related. Does any one know how many simultaneous TCP connections it's practical to expect a TCP-based server application to support (on the OS of your choice)? I'm looking for the restrictions imposed by the operating environment rather than the application itself. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Blog of Note: http://holdenweb.blogspot.com See you at PyCon? http://us.pycon.org/TX2007 -- http://mail.python.org/mailman/listinfo/python-list
Re: [off-topic] Maximum TCP Server Connections
Steve Holden [EMAIL PROTECTED] writes: Sorry this question isn't strictly Python-related. Does any one know how many simultaneous TCP connections it's practical to expect a TCP-based server application to support (on the OS of your choice)? I'm looking for the restrictions imposed by the operating environment rather than the application itself. http://www.kegel.com/c10k.html -- http://mail.python.org/mailman/listinfo/python-list
Re: pygame and python 2.5
Python used to work that way. You'd then silently get errors if the API changed between version A and version B and you neglected to recompile the extensions you compiled against version A. bearophile Can't the compiled module have one or more test functions bearophile that can be used during linking to see if the compiled bearophile module respects the expected standard? Given the complexity of the formal API how would you test to see if the extension violated a particular aspect of the API? What if one of the API bits used is implemented as a C macro (as parts are) and it was changed simply to fix a bug. Wouldn't you want to know with a high degree of certainty that you should recompile? How would a test function tell you that? A simple API versioning scheme does that. It means you have to recompile when a new version of Python comes out. In fact, you can think of it as the test function you suggest. It's just that it's noted at the time a module is imported, not strictly speaking at link time. It tells you, Hey buddy. You're using an outdated version of the API. What it can't tell you is if the parts of the API your particular module uses are used incorrectly. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: pycallgraph 0.2.0
Gerald I just released a new version of pycallgraph. It has many Gerald improvements over 0.1.0. Looks nice. Before you get too far... Is there any chance that you can support ASCII output mode (obviously not laid out in two dimensions, just using indentation) so the GraphViz requirement can become optional? GraphViz has so many dependencies of its own (and many of them are GTK-related) that the chance of me satisfying them is very small. (I'm on Solaris and Mac, not Linux, so I don't have the benefit of a Linux distro to solve those particular headaches for me.) Thanks, Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Glob returning an empty list when passed a variable
On Feb 10, 3:32 pm, Steve Holden [EMAIL PROTECTED] wrote: % s % 'banana' 'banana' % s % 1 '1' % s % -1 '-1' With some number: In [2]: % 3s % 'a' Out[2]: ' a' Hieu -- http://mail.python.org/mailman/listinfo/python-list
How to find all the same words in a text?
I need to find all the same words in a text . What would be the best idea to do that? I used string.find but it does not work properly for the words. Let suppose I want to find a number 324 in the text '45 324 45324' there is only one occurrence of 324 word but string.find() finds 2 occurrences ( in 45324 too) Must I use regex? Thanks for help L. -- http://mail.python.org/mailman/listinfo/python-list
Re: pygame and python 2.5: switch to linux?
Siggi ... I conclude now that I will be better off to drop Windows and Siggi install Linux on my next PC, to be able to reap the full benefits Siggi of Python. Darn tootin'... (*) Skip (*) http://en.wikipedia.org/wiki/You're_Darn_Tootin' -- http://mail.python.org/mailman/listinfo/python-list
Re: A little more advanced for loop
Larry Bates [EMAIL PROTECTED] wrote: Note: if lists are long take a look at itertools izip. zip creates a list of lists which could take lots of memory/time if they are VERY large. itertools izip iterates over them in place. That's interesting. I was going to quibble with the assertion that zip could take lots of time, since on the face of it a loop using izip packs and unpacks just as many tuples. Fortunately I tried it out before claiming that zip would be just as fast :) It would appear that even for short sequences the izip solution is faster. My guess would be it is because the same tuple objects are being reused in the izip version. C:\Python25\Libtimeit.py -s a, b, c = [range(1000)]*3 -s from itertools import izip for p,q,r in izip(a,b,c): pass 1 loops, best of 3: 131 usec per loop C:\Python25\Libtimeit.py -s a, b, c = [range(1000)]*3 for p,q,r in zip(a,b,c): pass 1000 loops, best of 3: 212 usec per loop C:\Python25\Libtimeit.py -s a, b, c = [range(100)]*3 -s from itertools import izip for p,q,r in izip(a,b,c): pass 10 loops, best of 3: 13.9 usec per loop C:\Python25\Libtimeit.py -s a, b, c = [range(100)]*3 for p,q,r in zip(a,b,c): pass 1 loops, best of 3: 22.6 usec per loop C:\Python25\Libtimeit.py -s a, b, c = [range(10)]*3 -s from itertools import izip for p,q,r in izip(a,b,c): pass 10 loops, best of 3: 2.21 usec per loop C:\Python25\Libtimeit.py -s a, b, c = [range(10)]*3 for p,q,r in zip(a,b,c): pass 10 loops, best of 3: 3.52 usec per loop -- http://mail.python.org/mailman/listinfo/python-list
Re: How to find all the same words in a text?
On Sat, Feb 10, 2007 at 05:29:23AM -0800, Johny wrote: I need to find all the same words in a text . What would be the best idea to do that? I used string.find but it does not work properly for the words. Let suppose I want to find a number 324 in the text '45 324 45324' there is only one occurrence of 324 word but string.find() finds 2 occurrences ( in 45324 too) '45 324 45324'.split().count('324') 1 ciao marco -- reply to `python -c print '[EMAIL PROTECTED]'[::-1]` signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: huge amounts of pure Python code broken by Python 2.5?
Klaas wrote: I have converted our 100 kloc from 2.4 to 2.5. It was relatively painless, and 2.5 has features we couldn't live without. Just out of curiosity, what features in 2.5 can you not live without? I just migrated to 2.5, but haven't had much time to check out the cool new features. thanks, Brian Blais -- - [EMAIL PROTECTED] http://web.bryant.edu/~bblais -- http://mail.python.org/mailman/listinfo/python-list
Re: Glob returning an empty list when passed a variable
In [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: With some number: In [2]: % 3s % 'a' Out[2]: ' a' The space still doesn't have any effect here: In [66]: %3s % 'a' Out[66]: ' a' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: How to find all the same words in a text?
On Feb 10, 2:42 pm, Marco Giusti [EMAIL PROTECTED] wrote: On Sat, Feb 10, 2007 at 05:29:23AM -0800, Johny wrote: I need to find all the same words in a text . What would be the best idea to do that? I used string.find but it does not work properly for the words. Let suppose I want to find a number 324 in the text '45 324 45324' there is only one occurrence of 324 word but string.find() finds 2 occurrences ( in 45324 too) '45 324 45324'.split().count('324') 1 ciao Marco, Thank you for your help. It works perfectly but I forgot to say that I also need to find the possition of each word's occurrence.Is it possible that Thanks. L -- http://mail.python.org/mailman/listinfo/python-list
Re: How to find all the same words in a text?
Johny wrote: Let suppose I want to find a number 324 in the text '45 324 45324' there is only one occurrence of 324 word but string.find() finds 2 occurrences ( in 45324 too) '45 324 45324'.split().count('324') 1 ciao Marco, Thank you for your help. It works perfectly but I forgot to say that I also need to find the possition of each word's occurrence.Is it possible that [i for i, e in enumerate('45 324 45324'.split()) if e=='324'] [1] -- Under construction -- http://mail.python.org/mailman/listinfo/python-list
Re: How to find all the same words in a text?
On Sat, Feb 10, 2007 at 06:00:05AM -0800, Johny wrote: On Feb 10, 2:42 pm, Marco Giusti [EMAIL PROTECTED] wrote: On Sat, Feb 10, 2007 at 05:29:23AM -0800, Johny wrote: I need to find all the same words in a text . What would be the best idea to do that? I used string.find but it does not work properly for the words. Let suppose I want to find a number 324 in the text '45 324 45324' there is only one occurrence of 324 word but string.find() finds 2 occurrences ( in 45324 too) '45 324 45324'.split().count('324') 1 ciao Marco, Thank you for your help. It works perfectly but I forgot to say that I also need to find the possition of each word's occurrence.Is it possible that li = '45 324 45324'.split() li.index('324') 1 play with count and index and take a look at the help of both ciao marco -- reply to `python -c print '[EMAIL PROTECTED]'[::-1]` signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: How to find all the same words in a text?
* Johny (10 Feb 2007 05:29:23 -0800) I need to find all the same words in a text . What would be the best idea to do that? I used string.find but it does not work properly for the words. Let suppose I want to find a number 324 in the text '45 324 45324' there is only one occurrence of 324 word but string.find() finds 2 occurrences ( in 45324 too) Must I use regex? There are two approaches: one is the solve once and forget approach where you code around this particular problem. Mario showed you one solution for this. The other approach would be to realise that your problem is a specific case of two general problems: partitioning a sequence by a separator and partioning a sequence into equivalence classes. The bonus for this approach is that you will have a /lot/ of problems that can be solved with either one of these utils or a combination of them. 1 a = '45 324 45324' 2 quotient_set(part(a, [' ', ' '], 'sep'), ident) 2: {'324': ['324'], '45': ['45'], '45324': ['45324']} The latter approach is much more flexible. Just imagine your problem changes to a string that's separated by newlines (instead of spaces) and you want to find words that start with the same character (instead of being the same as criterion). Thorsten -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't import Stackless in Pythonwin
On Feb 9, 2:06 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Fri, 09 Feb 2007 13:50:56 -0300, [EMAIL PROTECTED] escribió: I am getting started in Python, and I have looked on both the stackless page and python.org and cannot find the answer to what I think is a simple problem. If I start the python command line or idle, i can import stackless If I start pythonwin I get the following error ...No Module named Stackless Any help? Maybe they are different versions, or installed on different places. In those three environments, execute: import sys print sys.version print sys.executable All should report the same version. The executables for both python and IDLE should reside on the same directory; for pythonwin, you should get the *same* directory plus Lib\site-packages\pythonwin\Pythonwin.exe -- Gabriel Genellina Ok, for Idle I get: IDLE 1.2 import sys print sys.version 2.5 Stackless 3.1b3 060516 (python-2.5:53557:53567, Jan 25 2007, 22:01:46) [MSC v.1310 32 bit (Intel)] print sys.executable C:\Python25\pythonw.exe And for the command line i get the same thing except the executable is python.exe But for pythonwin i get import sys print sys.version 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] print sys.executable C:\Python25\Lib\site-packages\pythonwin\Pythonwin.exe So does this mean stackless is not usable with pythonwin? Also, is pythonwin needed for the win32 extensions and mfc? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Hacking in python
i would like to know about hacking in python too whether its illegal or not is not the point and anyway it doesn't mean i'm gong to use it. -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Cheesecake Service launched and Cheesecake 0.6.1 released
On 10/02/2007 10:34 AM, Grig Gheorghiu wrote: Thanks to the hard work of Michal Kwiatkowski, I'm proud to announce the launch of the Cheesecake Service (http://pypi.pycheesecake.org/ pypi/) and the release of Cheesecake 0.6.1 (http://python.org/pypi/Cheesecake/0.6.1). It appears to be missing (1) a Python 2.5 egg (2) a Windows installer Regards, John -- http://mail.python.org/mailman/listinfo/python-list
Re: Hacking in python
http://en.wikipedia.org/wiki/Hacker_%28disambiguation%29 Educate yourself on what hacking actually is. We're all hackers, because it just means we get the most out of code, enjoy pushing our technology to the limit, and generally love programming. The term has been abused by the media and you don't do much more than show your own naiveness by asking such a question. You also do a great job of insulting everyone on this list. On 2/10/07, enes naci [EMAIL PROTECTED] wrote: i would like to know about hacking in python too whether its illegal or not is not the point and anyway it doesn't mean i'm gong to use it. -- http://mail.python.org/mailman/listinfo/python-list -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://ironfroggy-code.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Please recommend library for multithread download
Hello there, I am looking for library (small better) that can fetch URL and download to local file in multi-threads. urllib2 is not thread safe as I tested. What will be? -- http://mail.python.org/mailman/listinfo/python-list
Re: [off-topic] Maximum TCP Server Connections
On 2007-02-10, Steve Holden [EMAIL PROTECTED] wrote: Sorry this question isn't strictly Python-related. Does any one know how many simultaneous TCP connections it's practical to expect a TCP-based server application to support (on the OS of your choice)? I'm looking for the restrictions imposed by the operating environment rather than the application itself. That depends entirely on the operating system environment. For some it's zero. For others it's many thousands. -- Grant Edwards grante Yow! How many retired at bricklayers from FLORIDA visi.comare out purchasing PENCIL SHARPENERS right NOW?? -- http://mail.python.org/mailman/listinfo/python-list
Re: Please recommend library for multithread download
On Feb 10, 4:26 pm, David Xiao [EMAIL PROTECTED] wrote: Hello there, I am looking for library (small better) that can fetch URL and download to local file in multi-threads. urllib2 is not thread safe as I tested. What will be? You may want to look at this recent thread: http://groups.google.com/group/comp.lang.python/browse_frm/thread/77fc9888e43bac46/1df3bcbfb785395c?lnk=gstq=download+simionatornum=1hl=en#1df3bcbfb785395c Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: Hacking in python
enes naci wrote: i would like to know about hacking in python too whether its illegal or not is not the point and anyway it doesn't mean i'm gong to use it. Does your mom know you're using her computer to take down the government? I'm gonna tell on you! -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode is confusing me
I'm the OP, and answering my own question. I received excellent advice from the developer of Ulipad, Limodou. On 2/10/07, Dick Moores [EMAIL PROTECTED] wrote: a = [u'\u91cd', u'\u8981', u'\u6027'] for x in range(3): print a[x] === The script should be === # -*- coding: utf-8 -*- a = [u'\u91cd', u'\u8981', u'\u6027'] for x in range(3): print a[x].encode('utf-8'), When output is redirected to a text file, this give a very pretty 重 要 性 Also, it turns out that I didn't need that sitecustomize.py . -- my configuration: Win XP Pro SP2 Python 2.5 wxPython 2.8.1.1 Unicode Python IDE: Ulipad 3.6 -- http://mail.python.org/mailman/listinfo/python-list
Re: LoadLibrary(pythondll) failed
acncgc schrieb: I get an following error as I turn on my laptop; LoadLibrary(pythondll) failed After this error internet browser ( IE or mozilla) doesn't connect. I can't browse any site. Any idea?? This looks like a message from a broken py2exe'd application. You have to find out where it comes from (AFAIK even viruses or trojaners have been built with Python). Thomas -- http://mail.python.org/mailman/listinfo/python-list
wxPython libraries never detected
Hi, I recently started coding with Python and I've been trying for the past hour or so to determine why, every time I import wx (or compile another piece of code that imports wx), Python can never find the libraries. I'm running Ubuntu Edgy 6.10, and, as per http://www.wxpython.org/download.php#sources, updated sources.list with the sources and installed python-wxgtk2.8, python-wxtools and wx2.8-i18n. I compiled the latest Python (as of writing), 2.5, from source. For example, SPE tells me that I need to install at least wxPython v. 2.5.4.1 to run SPE and any code that relies on import wx reports ImportError: No module named wx. However, whereis wx on the command line reports wx: /usr/lib/wx /usr/local/lib/wx /usr/include/ wx. What could be wrong here? I can't figure out why wx isn't being detected. Many thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Glob returning an empty list when passed a variable
On Feb 10, 8:32 am, Steve Holden [EMAIL PROTECTED] wrote: Steven D'Aprano wrote: On Fri, 09 Feb 2007 14:15:51 +, Steve Holden wrote: area_name_string = '*% s*' % (Area_name) Interesting, I never realised until now that you can have spaces between the percent sign and th format effector. Space is one of the flags. From the docs: The conversion flag characters are: Flag Meaning # The value conversion will use the ``alternate form'' (where defined below). 0 The conversion will be zero padded for numeric values. - The converted value is left adjusted (overrides the 0 conversion if both are given). (a space) A blank should be left before a positive number (or empty string) produced by a signed conversion. + A sign character (+ or -) will precede the conversion (overrides a space flag). http://docs.python.org/lib/typesseq-strings.html % s % 'banana' 'banana' % s % 1 '1' % s % -1 '-1' [snip] I've just tried it and it works for the d format but not the s format: %d % 1 '1' %+d % 1 '+1' % d % 1 ' 1' -- http://mail.python.org/mailman/listinfo/python-list
Re: Hacking in python
enes naci wrote: i would like to know about hacking in python too whether its illegal or not is not the point and anyway it doesn't mean i'm gong to use it. If you mean hacking as modyfying the code of interpreter of libraries - it is perfectly legal, as Python is Open Source. If you mean hacking as cracking into computer systems, then what's the difference if it's with Python or anything else. If you mean hacking as gaining excellency in programming - then why should it be? Greets zefciu -- http://mail.python.org/mailman/listinfo/python-list
pyTTS question ...
hi all: i need to know how other voices besides MSMary, MSSam and MSMike can be installed and used along with pyTTS. i tried downloading voices (PeterUK to be precise) but looks like it has not been registered, since pyTTS doesn't recognize it. Do I have to manually register the voice in Windows? TIA, -Ajay -- http://mail.python.org/mailman/listinfo/python-list
Re: Maximum TCP Server Connections
On Feb 10, 4:52 am, Steve Holden [EMAIL PROTECTED] wrote: Sorry this question isn't strictly Python-related. Does any one know how many simultaneous TCP connections it's practical to expect a TCP-based server application to support (on the OS of your choice)? I'm looking for the restrictions imposed by the operating environment rather than the application itself. Data point: When using winsock2, the number of simultaneous TCP connections is limited by the FD_SETSIZE preprocessor constant, which is often 64. It must be set before including winsock2.h. See Google and http:// www.aminus.org/blogs/index.php/fumanchu/2006/12/23/ cherrypy_3_has_fastest_wsgi_server_yet#c38647 Note also that many TCP servers use one thread per child socket, in which case you can hit a memory limit. IIRC, each Python thread on Windows uses a 1 MB stack: http://mail.python.org/pipermail/python- win32/2005-June/003346.html Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Hacking in python
Calvin Spealman wrote: http://en.wikipedia.org/wiki/Hacker_%28disambiguation%29 Educate yourself on what hacking actually is. We're all hackers, because it just means we get the most out of code, enjoy pushing our technology to the limit, and generally love programming. The term has been abused by the media and you don't do much more than show your own naiveness by asking such a question. You also do a great job of insulting everyone on this list. On 2/10/07, enes naci [EMAIL PROTECTED] wrote: i would like to know about hacking in python too whether its illegal or not is not the point and anyway it doesn't mean i'm gong to use it. -- http://mail.python.org/mailman/listinfo/python-list -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://ironfroggy-code.blogspot.com/ So that was that weird feeling I felt ... insulted hg -- http://mail.python.org/mailman/listinfo/python-list
Re: Hacking in python
On 2/10/07, hg [EMAIL PROTECTED] wrote: Calvin Spealman wrote: http://en.wikipedia.org/wiki/Hacker_%28disambiguation%29 Educate yourself on what hacking actually is. We're all hackers, because it just means we get the most out of code, enjoy pushing our technology to the limit, and generally love programming. The term has been abused by the media and you don't do much more than show your own naiveness by asking such a question. You also do a great job of insulting everyone on this list. On 2/10/07, enes naci [EMAIL PROTECTED] wrote: i would like to know about hacking in python too whether its illegal or not is not the point and anyway it doesn't mean i'm gong to use it. -- http://mail.python.org/mailman/listinfo/python-list -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://ironfroggy-code.blogspot.com/ So that was that weird feeling I felt ... insulted hg -- http://mail.python.org/mailman/listinfo/python-list I'm surprised you all didn't just tell him how to become a hacker. That's what he wants, right? Here's the hacker info. Enjoy! http://www.catb.org/~esr/faqs/hacker-howto.html Shawn -- http://mail.python.org/mailman/listinfo/python-list
What does del actually do?
The Python reference manual says, for del, Rather that spelling it out in full details, here are some hints. That's not too helpful. In particular, when del is applied to a class object, what happens? Are all the instance attributes deleted from the object? Is behavior the same for both old and new classes? I'm trying to break cycles to fix some memory usage problems. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: What does del actually do?
del simply removes the name in the current scope. if that happens to be the last non-cyclic reference to the object it was bound to, then it will remove the objec to, but thats a seperate matter. if you remove the class and there are instances out there, they can only exist if there are some other references to them, so no, they arent deleted. del wont just delete a bunch of objects and leave broken names. i has nothing to do with deleting objects, only names. On 2/10/07, John Nagle [EMAIL PROTECTED] wrote: The Python reference manual says, for del, Rather that spelling it out in full details, here are some hints. That's not too helpful. In particular, when del is applied to a class object, what happens? Are all the instance attributes deleted from the object? Is behavior the same for both old and new classes? I'm trying to break cycles to fix some memory usage problems. John Nagle -- http://mail.python.org/mailman/listinfo/python-list -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://ironfroggy-code.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
How to Speed Up Internet Searches??
How to Speed Up Internet Searches?? When you go to a web site, the first thing that happens is that. and for networking tips see at http://www.studyandjobs.com/network_tip.html or http://www.studyandjobs.com/IT_study.htm thanx -- http://mail.python.org/mailman/listinfo/python-list
Re: Hacking in python
zefciu wrote: enes naci wrote: i would like to know about hacking in python too whether its illegal or not is not the point and anyway it doesn't mean i'm gong to use it. If you mean hacking as modyfying the code of interpreter of libraries - it is perfectly legal, as Python is Open Source. If you mean hacking as cracking into computer systems, then what's the difference if it's with Python or anything else. If you mean hacking as gaining excellency in programming - then why should it be? Greets zefciu It's really sad. I saw this poor schmuck on Want to be a millionaire once. His second question was What is a hacker? I don't remember all of the alternatives but two of them was A computer programmer and Someone illegally using a computer. He answered 'computer programmer'... guess what was the 'correct one'. I guess he was lucky though... it could have been the one million question. -- http://mail.python.org/mailman/listinfo/python-list
Re: Hacking in python
On 2/10/07, Tina I [EMAIL PROTECTED] wrote: zefciu wrote: enes naci wrote: i would like to know about hacking in python too whether its illegal or not is not the point and anyway it doesn't mean i'm gong to use it. If you mean hacking as modyfying the code of interpreter of libraries - it is perfectly legal, as Python is Open Source. If you mean hacking as cracking into computer systems, then what's the difference if it's with Python or anything else. If you mean hacking as gaining excellency in programming - then why should it be? Greets zefciu It's really sad. I saw this poor schmuck on Want to be a millionaire once. His second question was What is a hacker? I don't remember all of the alternatives but two of them was A computer programmer and Someone illegally using a computer. He answered 'computer programmer'... guess what was the 'correct one'. I guess he was lucky though... it could have been the one million question. -- http://mail.python.org/mailman/listinfo/python-list That's truly horrible. I would sue. -- http://mail.python.org/mailman/listinfo/python-list
Re: What does del actually do?
Calvin Spealman wrote [top-posting, which I have corrected]: On 2/10/07, John Nagle [EMAIL PROTECTED] wrote: The Python reference manual says, for del, Rather that spelling it out in full details, here are some hints. That's not too helpful. In particular, when del is applied to a class object, what happens? Are all the instance attributes deleted from the object? Is behavior the same for both old and new classes? I'm trying to break cycles to fix some memory usage problems. del simply removes the name in the current scope. if that happens to be the last non-cyclic reference to the object it was bound to, then it will remove the object to, but thats a separate matter. if you remove the class and there are instances out there, they can only exist if there are some other references to them, so no, they arent deleted. del wont just delete a bunch of objects and leave broken names. i has nothing to do with deleting objects, only names. Except, of course, when you aren't deleting names but elements of some container object. The del statement removes references to objects as well as removing names from namespaces and elements from container objects. Calvin is correct, though. Since each instance of a class contains a reference to the class, the class will live on even after it is deleted by name, being garbage-collected only after all instances have ceased to exist. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Blog of Note: http://holdenweb.blogspot.com See you at PyCon? http://us.pycon.org/TX2007 -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython libraries never detected
[EMAIL PROTECTED] wrote: Hi, I recently started coding with Python and I've been trying for the past hour or so to determine why, every time I import wx (or compile another piece of code that imports wx), Python can never find the libraries. I'm running Ubuntu Edgy 6.10, and, as per http://www.wxpython.org/download.php#sources, updated sources.list with the sources and installed python-wxgtk2.8, python-wxtools and wx2.8-i18n. I compiled the latest Python (as of writing), 2.5, from source. For example, SPE tells me that I need to install at least wxPython v. 2.5.4.1 to run SPE and any code that relies on import wx reports ImportError: No module named wx. However, whereis wx on the command line reports wx: /usr/lib/wx /usr/local/lib/wx /usr/include/ wx. What could be wrong here? I can't figure out why wx isn't being detected. Many thanks. Doing a `whereis wx` won't tell you about the python library installation. I'm using Ubuntu Edgy, with Python 2.4 installed (from apt), and wx-2.6. I can find the libraries in /usr/lib/python2.4/wx-2.6-gtk-unicode/ Check to see if you have wx installed in /usr/lib/python2.5 -- http://mail.python.org/mailman/listinfo/python-list
Re: pycallgraph 0.2.0
On Feb 10, 11:14 pm, Stef Mientki [EMAIL PROTECTED] wrote: My first test was terrible: a file of 800kB was created, Trying to view it, resulted in the following: - Paint Shop Pro told me it was not a valid PNG file, - Mozilla crashed after 5 minutes, - GIMP gave me a preview after half an hour ;-) Impressive! :) So a few suggestions: - is there a way to limit the number of nodes ? Not yet, I will have a maximum stack-depth option in the next version. - pycallgraph. nodes are non-information (maybe you can find another way to place your signature ;-) This should be fixed in the next version. - how do I exclude modules/files/objects (sorry I'm still a newbie in Python) Say you want to only display your own modules called 'foo' and 'bar': import pycallgraph pycallgraph.settings['include_module'] = ['foo', bar] pycallgraph.start_trace() pycallgraph.make_graph('blah.png') From the source there are these options for inclusion and exclusion: 'exclude_module': [], 'exclude_class': [], 'exclude_func': [], 'exclude_specific': ['stop_trace', 'make_graph'], 'include_module': [], 'include_class': [], 'include_func': [], 'include_specific': [], specific means the whole name of a node, e.g. foo.MyBarClass.__init__ Gerald -- http://mail.python.org/mailman/listinfo/python-list
Problems - using widgets.CheckboxTable - I would like examples...
oi I'm trying to use the checkboxtable and I'm having serios problems. I would like some idea or example. Somebory could help me? Any ideas Thanks Bruno Nascimento -- http://mail.python.org/mailman/listinfo/python-list
Re: pycallgraph 0.2.0
On Feb 11, 12:28 am, [EMAIL PROTECTED] wrote: Looks nice. Before you get too far... Is there any chance that you can support ASCII output mode (obviously not laid out in two dimensions, just using indentation) so the GraphViz requirement can become optional? GraphViz has so many dependencies of its own (and many of them are GTK-related) that the chance of me satisfying them is very small. (I'm on Solaris and Mac, not Linux, so I don't have the benefit of a Linux distro to solve those particular headaches for me.) It's easy enough. I'll put it on my todo list. Gerald -- http://mail.python.org/mailman/listinfo/python-list
Python 2.4 pdf Tutorial--Available
I was able to download the 2.5 tutorial, but think I may need the 2.4 tutorial (Guido van Rossum) if it exists. Anyone know where to find it? Wayne T. Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7 N, 121° 2' 32 W, 2700 feet Humans aren't the first species to alter the atmosphere; that distinction belongs to early bacteria, which some two billion years ago, invented photosynthesis. -- Field Notes from a Catastrophe, Kolbert -- Web Page: home.earthlink.net/~mtnviews -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython libraries never detected
[EMAIL PROTECTED] wrote: Hi, I recently started coding with Python and I've been trying for the past hour or so to determine why, every time I import wx (or compile another piece of code that imports wx), Python can never find the libraries. I'm running Ubuntu Edgy 6.10, and, as per http://www.wxpython.org/download.php#sources, updated sources.list with the sources and installed python-wxgtk2.8, python-wxtools and wx2.8-i18n. I compiled the latest Python (as of writing), 2.5, from source. For example, SPE tells me that I need to install at least wxPython v. 2.5.4.1 to run SPE and any code that relies on import wx reports ImportError: No module named wx. However, whereis wx on the command line reports wx: /usr/lib/wx /usr/local/lib/wx /usr/include/ wx. What could be wrong here? I can't figure out why wx isn't being detected. Many thanks. By default, you need to have wx installed in the python site-package path / under Mandriva, I have wx 2.8 installed here: /usr/lib/python2.4/site-packages/wx-2.8-gtk2-ansi/ hg -- http://mail.python.org/mailman/listinfo/python-list
AntiVirus @ AV MAILGATE BTC-NET scan results
Tozi e-mail vi e izpraten ot AV MAILGATE BTC-NET za da vi suobshti che e-mail izpraten ot [EMAIL PROTECTED] do python-list@python.org e zarazen s virus. This e-mail is generated by the AV MAILGATE BTC-NET to warn you that the e-mail sent by [EMAIL PROTECTED] to python-list@python.org is infected with virus. Please contact your system administrator for further information. If you are the sender: --- The scanned e-mail has your address in the From header field. Either your computer is infected or someone's computer having your e-mail address in the address book has been infected. (Please note that some viruses are sending e-mails directly from your computer. Our advise is to check your computer using an up-to-date antivirus product). If you are the receiver: - Please contact the sender: very probably he/she doesn't know he/she has a computer virus. Actions taken for the infected files: - The infected file was saved to quarantine with name 1171119287-RAV10808 text.zip text.bat is infected with virus: W32/[EMAIL PROTECTED] Cannot clean this file.Cannot delete this file (most probably it's in an archive). The mail was not delivered because it contained dangerous code. This is a copy of the e-mail header: - Received: from unknown (HELO mtel.bg) (90.154.148.154) by 0 with SMTP; 10 Feb 2007 14:54:37 - From: [EMAIL PROTECTED] To: python-list@python.org Subject: Returned mail: see transcript for details Date: Sat, 10 Feb 2007 16:49:19 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary==_NextPart_000_0006_C1541CC4.22175B73 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600. X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600. -- http://mail.python.org/mailman/listinfo/python-list
Question about strftime
Hi, I have question about strftime. I am trying to print the current time in this format: date = strftime(%Y%m%d_%H%M%S, gmtime()) print date I run the script at 2:18 pm, but I get this: 20070210_201837 Can you please tell me why I get '20'? instead of '14' (which is 2:00 pm)? Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Something like the getattr() trick.
I'm working with the following class heirarchy (I've snipped out the code from the classes): class Vuln: def __init__(self, url): pass def _parse(self): pass def get_link(self): pass class VulnInfo(Vuln): pass class VulnDiscuss(Vuln): pass def main(url): vuln_class = ['Info', 'Discuss'] vuln = Vuln(url) vuln._parse() for link in vuln.get_link(): i = VulnInfo(link) i._parse() d = VulnDiscuss(link) d._parse() Is there a way to get references to VulnInfo and VulnDiscuss objects using something like the getattr trick? For example, something like: for _class in vuln_class: class_obj = getattr('Vuln%s' % (_class,) ..) a = class_obj(link) a._parse() getattr() takes an object as its first argument. I can't seem to figure out how to make it work here. -- Ayaz Ahmed Khan A witty saying proves nothing, but saying something pointless gets people's attention. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about strftime
[EMAIL PROTECTED] writes: date = strftime(%Y%m%d_%H%M%S, gmtime()) print date I run the script at 2:18 pm, but I get this: 20070210_201837 Can you please tell me why I get '20'? instead of '14' (which is 2:00 pm)? Wrong time zone? Maybe you want localtime() instead of gmtime(). -- http://mail.python.org/mailman/listinfo/python-list
Re: A little more advanced for loop
In article [EMAIL PROTECTED], Larry Bates [EMAIL PROTECTED] wrote: Note: if lists are long take a look at itertools izip. zip creates a list of lists which could take lots of memory/time if they are VERY large. itertools izip iterates over them in place. That's half-true -- while izip is faster, it's not enough faster to make a significant difference unless the lists are huge rather than large. Remember that the data elements themselves are not copied. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ I disrespectfully agree. --SJM -- http://mail.python.org/mailman/listinfo/python-list
Re: Something like the getattr() trick.
On Feb 10, 3:34 pm, Ayaz Ahmed Khan [EMAIL PROTECTED] wrote: I'm working with the following class heirarchy (I've snipped out the code from the classes): class Vuln: def __init__(self, url): pass def _parse(self): pass def get_link(self): pass class VulnInfo(Vuln): pass class VulnDiscuss(Vuln): pass def main(url): vuln_class = ['Info', 'Discuss'] vuln = Vuln(url) vuln._parse() for link in vuln.get_link(): i = VulnInfo(link) i._parse() d = VulnDiscuss(link) d._parse() Is there a way to get references to VulnInfo and VulnDiscuss objects using something like the getattr trick? For example, something like: for _class in vuln_class: class_obj = getattr('Vuln%s' % (_class,) ..) a = class_obj(link) a._parse() getattr() takes an object as its first argument. I can't seem to figure out how to make it work here. -- Ayaz Ahmed Khan A witty saying proves nothing, but saying something pointless gets people's attention. eval('Vuln' + _class) or, Vuln.Discuss = VulnDiscuss getattr(Vuln, _class) -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython libraries never detected
On Feb 10, 1:07 pm, hg [EMAIL PROTECTED] wrote: By default, you need to have wx installed in the python site-package path / under Mandriva, I have wx 2.8 installed here: /usr/lib/python2.4/site-packages/wx-2.8-gtk2-ansi/ hg Ah, now I see. But I have a new problem: ls /usr/lib/python2.4/site-packages | grep wx-2.8 returns wx-2.8- gtk2-unicode I copied wx-2.8-gtk2-unicode to /usr/lib/python2.5/site-packages/, which I assume the programs I am attempting to compile and run are using by default, but they still do not find the libraries. How can I tell where the programs are searching for the libraries? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: pygame and python 2.5
On Feb 10, 6:31 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Feb 9, 11:39?am, Ben Sizer [EMAIL PROTECTED] wrote: Hopefully in the future, some of those convoluted steps will be fixed, but that requires someone putting in the effort to do so. As is often the case with Python, and indeed many open source projects, the people who are knowledgeable enough to do such things usually don't need to do them, as their setup already works just fine. So you're saying the knowledgeable people's attitude is fuck everyone else as lomg as it's not MY problem? And you people complain about Microsoft. Am I one of those people? You don't exactly make it clear. But yes, there is a lot of well, it works for me going around. If you do that long enough, people stop complaining, so people wrongly assume there's no longer a problem. This is partly why Python has various warts on Windows and why the standard libraries are oddly biased, why configuring Linux almost always ends up involving hand- editing a .conf file, why the leading cross-platform multimedia library SDL still doesn't do hardware graphics acceleration a decade after such hardware became mainstream, and so on. However, the difference between the open-source people and Microsoft is the the open-source people aren't being paid by you for the use of their product, so they're not obligated in any way to help you. After all, they have already given freely and generously, and if they choose not to give more on top of that, it's really up to them. Yes, it's occasionally very frustrating to the rest of us, but that's life. The best I feel I can do is raise these things on occasion, on the off- chance that I manage to catch the attention of someone who is altruistic, knowledgeable, and who has some spare time on their hands! -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Hacking in python
Calvin Spealman wrote: http://en.wikipedia.org/wiki/Hacker_%28disambiguation%29 Educate yourself on what hacking actually is. We're all hackers, because it just means we get the most out of code, enjoy pushing our technology to the limit, and generally love programming. The term has been abused by the media and you don't do much more than show your own naiveness by asking such a question. You also do a great job of insulting everyone on this list. On 2/10/07, enes naci [EMAIL PROTECTED] wrote: i would like to know about hacking in python too whether its illegal or not is not the point and anyway it doesn't mean i'm gong to use it. -- http://mail.python.org/mailman/listinfo/python-list Here is my favorite hacker how-to: http://www.datastronghold.com/content/view/555/27/ James -- http://mail.python.org/mailman/listinfo/python-list
Re: Something like the getattr() trick.
This is a really common question. What you really need here is to lookup some value (one of the two classes) by a key (the names of the classes). Does that sound like something familiar? You seem to need a dictionary, where you think you want lookup some global objects by name. Alternatively, if you use new-style classes (by`inheriting the object class in your base class), you could perhaps add a method such as getSubClass() like: class Vuln(object): ... @classmethod def getSubClass(cls, name): for c in cls.__subclasses__(): if c.__name__ == name: return c raise ValueError(No subclass named '%s' found. % name) Of course, this only makes sense if you needs dont extend outside the pattern of looking up subclasses by name. It has the advantage that you can also put the subclasses in other modules and still look them up from one place. On 2/10/07, Ayaz Ahmed Khan [EMAIL PROTECTED] wrote: I'm working with the following class heirarchy (I've snipped out the code from the classes): class Vuln: def __init__(self, url): pass def _parse(self): pass def get_link(self): pass class VulnInfo(Vuln): pass class VulnDiscuss(Vuln): pass def main(url): vuln_class = ['Info', 'Discuss'] vuln = Vuln(url) vuln._parse() for link in vuln.get_link(): i = VulnInfo(link) i._parse() d = VulnDiscuss(link) d._parse() Is there a way to get references to VulnInfo and VulnDiscuss objects using something like the getattr trick? For example, something like: for _class in vuln_class: class_obj = getattr('Vuln%s' % (_class,) ..) a = class_obj(link) a._parse() getattr() takes an object as its first argument. I can't seem to figure out how to make it work here. -- Ayaz Ahmed Khan A witty saying proves nothing, but saying something pointless gets people's attention. -- http://mail.python.org/mailman/listinfo/python-list -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://ironfroggy-code.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: pygame and python 2.5
On Feb 10, 8:42 am, Steve Holden [EMAIL PROTECTED] wrote: Hendrik van Rooyen wrote: [EMAIL PROTECTED] wrote: Ben Sizer [EMAIL PROTECTED] wrote: Ben Python extensions written in C require recompilation for each new Ben version of Python, due to Python limitations. Can you propose a means to eliminate this limitation? Yes. - Instead of calling something, send it a message... I suppose you are proposing to use the ISO 1.333 generic message-passing interface for this? The one that doesn't actually call a function to pass a message? I'm assuming you're being facetious here..? Of course, functions get called at the ends of the message passing process, but those functions can stay the same across versions while the messages themselves change. The important part is reducing the binary interface between the two sides to a level where it's trivial to guarantee that part of the equation is safe. eg. Instead of having PySomeType_FromLong(long value) exposed to the API, you could have a PyAnyObject_FromLong(long value, char* object_type_name). That function can return NULL and set up an exception if it doesn't understand the object you asked for, so Python versions earlier than the one that implement the type you want will just raise an exception gracefully rather than not linking. The other issue comes with interfaces that are fragile by definition - eg. instead of returning a FILE* from Python to the extension, return the file descriptor and create the FILE* on the extension side with fdopen. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython libraries never detected
[EMAIL PROTECTED] wrote: On Feb 10, 1:07 pm, hg [EMAIL PROTECTED] wrote: By default, you need to have wx installed in the python site-package path / under Mandriva, I have wx 2.8 installed here: /usr/lib/python2.4/site-packages/wx-2.8-gtk2-ansi/ hg Ah, now I see. But I have a new problem: ls /usr/lib/python2.4/site-packages | grep wx-2.8 returns wx-2.8- gtk2-unicode I copied wx-2.8-gtk2-unicode to /usr/lib/python2.5/site-packages/, which I assume the programs I am attempting to compile and run are using by default, but they still do not find the libraries. How can I tell where the programs are searching for the libraries? Thanks. If you're going to try the copy technique (never tried it) , you also need to copy wx.pth and wxversion.py. hg -- http://mail.python.org/mailman/listinfo/python-list
Parsing HTML
Alright. I have tried everything I can find, but am not getting anywhere. I have a web page that has data like this: tr td headers=col1_1 style=width:21% span class=hpPageText LETTER/span/td td headers=col2_1 style=width:13%; text-align:right span class=hpPageText 33,699/span/td td headers=col3_1 style=width:13%; text-align:right span class=hpPageText 1.0/span/td td headers=col4_1 style=width:13%; text-align:right /tr What is show is only a small section. I want to extract the 33,699 (which is dynamic) and set the value to a variable so that I can insert it into a database. I have tried parsing the html with pyparsing, and the examples will get it to print all instances with span, of which there are a hundred or so when I use: for srvrtokens in printCount.searchString(printerListHTML): print srvrtokens If I set the last line to srvtokens[3] I get the values, but I don't know grab a single line and then set that as a variable. I have also tried Beautiful Soup, but had trouble understanding the documentation, and HTMLParser doesn't seem to do what I want. Can someone point me to a tutorial or give me some pointers on how to parse html where there are multiple lines with the same tags and then be able to go to a certain line and grab a value and set a variable's value to that? Thanks, Mike -- http://mail.python.org/mailman/listinfo/python-list
HTML Parsing
Alright. I have tried everything I can find, but am not getting anywhere. I have a web page that has data like this: tr td headers=col1_1 style=width:21% span class=hpPageText LETTER/span/td td headers=col2_1 style=width:13%; text-align:right span class=hpPageText 33,699/span/td td headers=col3_1 style=width:13%; text-align:right span class=hpPageText 1.0/span/td td headers=col4_1 style=width:13%; text-align:right /tr What is show is only a small section. I want to extract the 33,699 (which is dynamic) and set the value to a variable so that I can insert it into a database. I have tried parsing the html with pyparsing, and the examples will get it to print all instances with span, of which there are a hundred or so when I use: for srvrtokens in printCount.searchString(printerListHTML): print srvrtokens If I set the last line to srvtokens[3] I get the values, but I don't know grab a single line and then set that as a variable. I have also tried Beautiful Soup, but had trouble understanding the documentation, and HTMLParser doesn't seem to do what I want. Can someone point me to a tutorial or give me some pointers on how to parse html where there are multiple lines with the same tags and then be able to go to a certain line and grab a value and set a variable's value to that? Thanks, Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Best Free and Open Source Python IDE
If you can take some time and master Vim, you'll be set for typing out any programming language for the rest of your life. I hear Emacs is good too, and the GNU project is great, so you could try that as well. It's supposed to be more geared towards programming -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.4 pdf Tutorial--Available
En Sat, 10 Feb 2007 16:45:08 -0300, W. Watson [EMAIL PROTECTED] escribió: I was able to download the 2.5 tutorial, but think I may need the 2.4 tutorial (Guido van Rossum) if it exists. Anyone know where to find it? Go to http://docs.python.org/ and follow the link Locate previous versions -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Regular Expressions
What's the way to go about learning Python's regular expressions? I feel like such an idiot - being so strong in a programming language but knowing nothing about RE. -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular Expressions
Geoff Hill [EMAIL PROTECTED] writes: What's the way to go about learning Python's regular expressions? I feel like such an idiot - being so strong in a programming language but knowing nothing about RE. Read the documentation? -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython libraries never detected
hg wrote: [EMAIL PROTECTED] wrote: On Feb 10, 1:07 pm, hg [EMAIL PROTECTED] wrote: By default, you need to have wx installed in the python site-package path / under Mandriva, I have wx 2.8 installed here: /usr/lib/python2.4/site-packages/wx-2.8-gtk2-ansi/ hg Ah, now I see. But I have a new problem: ls /usr/lib/python2.4/site-packages | grep wx-2.8 returns wx-2.8- gtk2-unicode I copied wx-2.8-gtk2-unicode to /usr/lib/python2.5/site-packages/, which I assume the programs I am attempting to compile and run are using by default, but they still do not find the libraries. How can I tell where the programs are searching for the libraries? Thanks. If you're going to try the copy technique (never tried it) , you also need to copy wx.pth and wxversion.py. hg Oh, and remember that a 2.4.pyc will not run with 2.5 ... so I would also remove all .pyc that I might have copied. hg -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about strftime
En Sat, 10 Feb 2007 17:29:52 -0300, [EMAIL PROTECTED] escribió: I have question about strftime. I am trying to print the current time in this format: date = strftime(%Y%m%d_%H%M%S, gmtime()) print date I run the script at 2:18 pm, but I get this: 20070210_201837 Can you please tell me why I get '20'? instead of '14' (which is 2:00 pm)? gmtime() returns the time in UTC, not local time, and your computer thinks you're in Mexico, central USA or Canada. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Something like the getattr() trick.
On 2/10/07, Ayaz Ahmed Khan [EMAIL PROTECTED] wrote: class Vuln: class VulnInfo(Vuln): class VulnDiscuss(Vuln): def main(url): vuln_class = ['Info', 'Discuss'] vuln = Vuln(url) vuln._parse() for link in vuln.get_link(): i = VulnInfo(link) i._parse() d = VulnDiscuss(link) d._parse() Is there a way to get references to VulnInfo and VulnDiscuss objects In addition to what other people has suggested: - Use some kind of registry: register(Vuln, Vuln, VulnInfo, VulnDiscuss) (a dictionary would do) and then look up by name - If all three classes are contained inside the same module, look up them by name into globals: InfoClass = globals()[%sInfo % self.__class__.__name__] (assuming self is an instance of Vuln, this would give you the VulnInfo class) - Replace your line: vuln_class = ['Info', 'Discuss'] with vuln_class = [VulnInfo, VulnDiscuss] As you see, there are many ways to do that - choose what better fits your needs. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: HTML Parsing
En Sat, 10 Feb 2007 20:07:43 -0300, mtuller [EMAIL PROTECTED] escribió: tr td headers=col1_1 style=width:21% span class=hpPageText LETTER/span/td td headers=col2_1 style=width:13%; text-align:right span class=hpPageText 33,699/span/td td headers=col3_1 style=width:13%; text-align:right span class=hpPageText 1.0/span/td td headers=col4_1 style=width:13%; text-align:right /tr I want to extract the 33,699 (which is dynamic) and set the value to a variable so that I can insert it into a database. I have tried parsing [...] I have also tried Beautiful Soup, but had trouble understanding the documentation, and HTMLParser doesn't seem to do what I want. Can[...] Just try harder with BeautifulSoup, should work OK for your use case. Unfortunately I can't give you an example right now. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a cross-platform way to execute binary
En Sat, 10 Feb 2007 08:48:31 -0300, techtonik [EMAIL PROTECTED] escribió: On Feb 10, 12:03 pm, Gabriel Genellina [EMAIL PROTECTED] Here executable means file that could be be launched by system() (if there are any other ways - I'd be happy to know them) This is a very specific definition of executable. os.access does not use that definition. os.access(../../ufo2map, os.X_OK) False That's right - such file does not exist. On Windows, in general, X_OK is the same as F_OK: for any existing file, whatever name or extension, returns True. Permissions are managed thru ACL and this simple function does NOT consider them. It shouldn't matter if the file exists or not. Quoting http:// docs.python.org/lib/os-file-dir.html: X_OK Value to include in the mode parameter of access() to determine if path can be executed. See - there is no file notation as only path is tested and path is pretty executable. It appears that your argument is: os.system(../../ufo2map) launches a new process, so ../../ufo2map must be executable. But os.system(foo.txt) also works, so foo.txt is also executable? Please define executable first. The definition may be so restrictive as to only include PE files (all others require a wrapping process) or so broad as to include almost anything known to the system. I think this should be clarified in os.access() documentation to make the whole business less confusing if not implemented in interpreter itself. After all the purpose of cross- platform language is to free developer from writing platform-specific code. os.access documentation is rather clear - it's just a wrapper around the access() system call, and I think it should not be changed. It is the underlying OS which gives the answer, not Python. On the other hand, an utility library exposing FindExecutable, ShellExecute, associations and other shell goodies might be useful. Maybe you could do some research, whether such thing exists, and help improve it or design a good interfase? I would prefer to know as little about underlying platforms as possible. It would only be a big plus for Python. Sure, but someone has to write it. I can't think of a good abstraction right now, perhaps you have some ideas? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.4 pdf Tutorial--Available
Gabriel Genellina wrote: En Sat, 10 Feb 2007 16:45:08 -0300, W. Watson [EMAIL PROTECTED] escribió: I was able to download the 2.5 tutorial, but think I may need the 2.4 tutorial (Guido van Rossum) if it exists. Anyone know where to find it? Go to http://docs.python.org/ and follow the link Locate previous versions --Gabriel Genellina Thanks. Found the 2.4 Python Tutorial web page by Guido van Rossum, but would like the pdf. Wayne T. Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7 N, 121° 2' 32 W, 2700 feet Humans aren't the first species to alter the atmosphere; that distinction belongs to early bacteria, which some two billion years ago, invented photosynthesis. -- Field Notes from a Catastrophe, Kolbert -- Web Page: home.earthlink.net/~mtnviews -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular Expressions
Hi, a good start: http://diveintopython.org/regular_expressions/index.html On 10 Feb 2007 15:30:04 -0800, Paul Rubin http://phr.cx@nospam.invalid wrote: Geoff Hill [EMAIL PROTECTED] writes: What's the way to go about learning Python's regular expressions? I feel like such an idiot - being so strong in a programming language but knowing nothing about RE. Read the documentation? -- http://mail.python.org/mailman/listinfo/python-list -- --- You can't have everything. Where would you put it? -- Steven Wright --- please visit www.serpia.org -- http://mail.python.org/mailman/listinfo/python-list