Re: What's the best way to write this regular expression?
On Mar 7, 4:02 pm, Evan Driscoll wrote: > On 01/-10/-28163 01:59 PM, Prasad, Ramit wrote: > > > gz stands for gzip and is a form of compression (like rar/zip ). > > tar stands for a tape archive. It is basically a box that holds the > > files. So you need to "unzip" and then "open the box". > > > Normally programs like WinZip / WinRar / 7-zip will do both in one step > > so you do not need to. Not sure what program you are using... > > I'm not sure what 7-zip you're referring to, because I use 7-zip and > it's always been a two-step process for me... > > (Though I can't say I've looked through the preferences dialog for a > "extract .tar.gz files in one go" setting.) > > Evan Same here, because that's what I used. I looked through the settings but didn't see anything. What seems to happen is that 7-Zip recognizes the .gz extension and opens that automatically. But then that simply opens up another window with the .tar file in it, which you have to then open again. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
On Mar 7, 11:03 pm, Chris Angelico wrote: > On Thu, Mar 8, 2012 at 7:39 AM, John Salerno wrote: > > it only > > seemed to support Python 2.7. I'm using 3.2. Is 2.7 just the minimum > > version it requires? It didn't say something like "2.7+", so I wasn't > > sure, and I don't want to start installing a bunch of stuff that will > > clog up my directories and not even work. > > Just to clarify: Python 2 and Python 3 are quite different. If > something requires Python 2.7, you cannot assume that it will work > with Python 3.2; anything that supports both branches will usually > list the minimum version of each (eg "2.7 or 3.3"). > > ChrisA That's why I asked first, because I got the feeling it did NOT support Python 3 :) -- http://mail.python.org/mailman/listinfo/python-list
Re: what is best method to set sys.stdout to utf-8?
I would. The io module is more recent an partly replaces codecs. The latter remains for back compatibility and whatever it can do that io cannot. I've a naive question : what is wrong with the following system ? class MyStdOut(object): def __init__(self): self.old_stdout=sys.stdout def write(self,x): try: if isinstance(x,unicode): x=x.encode("utf8") except (UnicodeEncodeError,UnicodeDecodeError): sys.stderr.write("This should not happen !") raise self.old_stdout.write(x) sys.stdout=MyStdOut() ... well ... a part of the fact that it is much longer ? Laurent Claessens -- http://mail.python.org/mailman/listinfo/python-list
Re: Biologist new to cgi in python
Shane Neeley wrote: > >Here is the function I am using to insert the variable file text inside the >url. Is it even possible to include the upload command in the url? No. You are trying to simulate a "GET" request, but files can only be uploaded via a "POST" request of type multiport/form-data. There is a module called "poster" that can do the appropriate encoding for you: http://stackoverflow.com/questions/680305/using-multipartposthandler-to-post-form-data-with-python -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Help with MultipartPostHandler
Hi Python Google Group! I hope someone could help me and then one day when I am good I can contribute to the forum as well. Does anyone know what is wrong with my syntax here as I am trying to submit this form using MultipartPostHandler that I installed? import MultipartPostHandler, urllib2 params = { 'Run_Number' : 'NONE', 'MAX_FILE_SIZE' : '200', 'submitForm' : 'Submit' } opener.open("http://consurf.tau.ac.il/index_full_form_PROT.php";, params) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python site-packages permission denied?
In article , Chris Rebert wrote: > You generally shouldn't mess with Mac OS X's system copies of Python. > Typically, one installs a separate copy using MacPorts, Fink, or > whatever, and uses that instead. I don't understand what you mean by "mess with". Certainly one should not attempt alter standard library modules provided with the system Python but adding additional packages is fully supported. Apple conveniently provides a special directory in user-controlled space (/Library/Python) as the default location for Distutils-based installs. They even provide versions of easy_install for the system Pythons. -- Ned Deily, n...@acm.org -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
On Thu, Mar 8, 2012 at 7:39 AM, John Salerno wrote: > it only > seemed to support Python 2.7. I'm using 3.2. Is 2.7 just the minimum > version it requires? It didn't say something like "2.7+", so I wasn't > sure, and I don't want to start installing a bunch of stuff that will > clog up my directories and not even work. Just to clarify: Python 2 and Python 3 are quite different. If something requires Python 2.7, you cannot assume that it will work with Python 3.2; anything that supports both branches will usually list the minimum version of each (eg "2.7 or 3.3"). ChrisA -- http://mail.python.org/mailman/listinfo/python-list
python-list@python.org
On Mar 8, 3:02 am, Christian wrote: > I play around with redis. Isn't it possible to handle BitSet with > Python "as" in Java? > > BitSet users = BitSet.valueOf(redis.get(key.getBytes())); > all.or(users); > System.out.println(all.cardinality()) > > I try something with the struct and bitstring libs , but haven't any > success. Even the follow snippet didn't work, beacause > bitset[0] isn't approriate. > > bitset = r.get('bytestringFromRedis') > x = "{0:b}".format(ord(bitset[0])) > > Thanks in advance > Christian Redis I dont know. As for bitset, sets in python should give you whatever bitset in java does See http://docs.python.org/library/sets.html -- http://mail.python.org/mailman/listinfo/python-list
Re: sys.stdout.detach() results in ValueError
Peter Kleiweg xs4all.nl> writes: > Not yet using fp in any way, this script gives the following error: > > Exception ValueError: 'underlying buffer has been detached' in You're probably using print() or some such which tries to write to sys.stdout. It's safest to just write to sys.stdout.buffer rather than using detach. -- http://mail.python.org/mailman/listinfo/python-list
PPC Form Filling Jobs
http://internetjobs4u.weebly.com -- http://mail.python.org/mailman/listinfo/python-list
Re: "Decoding unicode is not supported" in unusual situation
Steven D'Aprano writes: > On Thu, 08 Mar 2012 08:48:58 +1100, Ben Finney wrote: > > I think that's a Python bug. If the latter succeeds as a no-op, the > > former should also succeed as a no-op. Neither should ever get any > > errors when ‘s’ is a ‘unicode’ object already. > > No. The semantics of the unicode function (technically: a type > constructor) are well-defined, and there are two distinct behaviours: That is documented, right. Thanks for drawing my attention to it. > > Yes, this check should not be necessary; calling the ‘unicode’ > > constructor with an object that's already an instance of ‘unicode’ > > should just return the object as-is, IMO. It shouldn't matter that > > you've specified how decoding errors are to be handled, because in > > that case no decoding happens anyway. > > I don't believe that it is the job of unicode() to Do What I Mean, but > only to Do What I Say. If I *explicitly* tell unicode() to decode the > argument (by specifying either the codec or the error handler or both) That's where I disagree. Specifying what to do in the case of decoding errors is *not* explicitly requesting to decode. The decision of whether to decode is up to the object, not the caller. Specifying an error handler *in case* decoding errors happen is not the same as specifying that decoding must happen. In other words: I think specifying an encoding is saying “decode this”, but I don't think the same is true of specifying an error handler. > End-user applications may, with care, try to be smart and DWIM, but > library functions should be dumb and should do what they are told. Agreed, and I think this is compatible with my position. -- \ “Creativity can be a social contribution, but only in so far as | `\ society is free to use the results.” —Richard M. Stallman | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.2 and MS Outlook
On Thursday, 8 March 2012 1:52:48 AM, Greg Lindstrom wrote: Is there documentation showing how to read from a Microsoft Outlook server using Python 3.2. I've done it with 2.x, but can't find anything to help me with 3.2. What problems are you having in 3.2? It should be exactly the same - except, obviously, for the general differences between 2 and 3 (ie, any differences should not be due to needing to talk to Outlook and would exist regardless of the job at hand) Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: sys.stdout.detach() results in ValueError
On Mar 7, 4:10 pm, Terry Reedy wrote: > On 3/7/2012 5:35 PM, Peter Kleiweg wrote: > > > > > > > > > > > Dave Angel schreef op de 7e dag van de lentemaand van het jaar 2012: > > >> On 03/07/2012 02:41 PM, Peter Kleiweg wrote: > >>> I want to write out some binary data to stdout in Python3. I > >>> thought the way to do this was to call detach on sys.stdout. But > >>> apparently, you can't. Here is a minimal script: > > >>> #!/usr/bin/env python3.1 > >>> import sys > >>> fp = sys.stdout.detach() > > >>> Not yet using fp in any way, this script gives the following error: > > >>> Exception ValueError: 'underlying buffer has been detached' in > > >>> Same in Python 3.1.4 and Python 3.2.2 > > >>> So, what do I do if I want to send binary data to stdout? > > >> sys.stdout.write( some_binary_data ) > > > TypeError: must be str, not bytes > > Right, you can only send binary data to file opened in binary mode. The > default sys.stdout is in text mode. I am pretty sure that remains true > even if stdout is redirected. (You did not mention your OS.) You would > have to open such a file and make sys.stdout point to it. > sys.stdout = my_binary_file. > But why do that? Just open the file and write to it directly without the > above. > > -- > Terry Jan Reedy Write binary data to sys.stdout.buffer. -Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: pickle/unpickle class which has changed
On 03/07/2012 09:04 AM, Peter Otten wrote: > Gelonida N wrote: > If you know in advance that your class will undergo significant changes you > may also consider storing more stable data in a file format that can easily > be modified, e. g. json. > Good point, that's what I'm partially doing. I just wondered whether there were already some kind of pre-existing data migration tools / concepts / helpers like for example south for Django or whether I had to roll my own migration scheme for persistent non DB data. -- http://mail.python.org/mailman/listinfo/python-list
Re: what is best method to set sys.stdout to utf-8?
On 3/7/2012 3:57 PM, Peter Kleiweg wrote: In Python 3, there seem to be two ways to set sys.stdout to utf-8 after the script has started: sys.stdout = codecs.getwriter('utf-8')(sys.stdout.detach()) sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8') I guess the second is better. At start-up, type(sys.stdout) is , and it's also after using the second method. After using the first method, type(sys.stdout) is changed to . Should I always use the second method? I would. The io module is more recent an partly replaces codecs. The latter remains for back compatibility and whatever it can do that io cannot. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: sys.stdout.detach() results in ValueError
On 3/7/2012 5:35 PM, Peter Kleiweg wrote: Dave Angel schreef op de 7e dag van de lentemaand van het jaar 2012: On 03/07/2012 02:41 PM, Peter Kleiweg wrote: I want to write out some binary data to stdout in Python3. I thought the way to do this was to call detach on sys.stdout. But apparently, you can't. Here is a minimal script: #!/usr/bin/env python3.1 import sys fp = sys.stdout.detach() Not yet using fp in any way, this script gives the following error: Exception ValueError: 'underlying buffer has been detached' in Same in Python 3.1.4 and Python 3.2.2 So, what do I do if I want to send binary data to stdout? sys.stdout.write( some_binary_data ) TypeError: must be str, not bytes Right, you can only send binary data to file opened in binary mode. The default sys.stdout is in text mode. I am pretty sure that remains true even if stdout is redirected. (You did not mention your OS.) You would have to open such a file and make sys.stdout point to it. sys.stdout = my_binary_file. But why do that? Just open the file and write to it directly without the above. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: "Decoding unicode is not supported" in unusual situation
On 3/7/2012 6:26 PM, Steven D'Aprano wrote: On Thu, 08 Mar 2012 08:48:58 +1100, Ben Finney wrote: John Nagle writes: The library bug, if any, is that you can't apply unicode(s, errors='replace') to a Unicode string. TypeError("Decoding unicode is not supported") is raised. However unicode(s) will accept Unicode input. I think that's a Python bug. If the latter succeeds as a no-op, the former should also succeed as a no-op. Neither should ever get any errors when ‘s’ is a ‘unicode’ object already. No. The semantics of the unicode function (technically: a type constructor) are well-defined, and there are two distinct behaviours: unicode(obj) is analogous to str(obj), and it attempts to convert obj to a unicode string by calling obj.__unicode__, if it exists, or __str__ if it doesn't. No encoding or decoding is attempted in the event that obj is a unicode instance. unicode(obj, encoding, errors) is explicitly stated in the docs as decoding obj if EITHER of encoding or errors is given, AND that obj must be either an 8-bit string (bytes) or a buffer object. It is true that u''.decode() will succeed, in Python 2, but the fact that unicode objects have a decode method at all is IMO a bug. It has also I believe that is because in Py 2, codecs and .encode/.decode were used for same type recoding like base64, uu coding. That was simplified in Py3 so that 'decoding' is bytes to string and 'encoding' is string to bytes, and base64, etc, are only done in their separate modules and not also duplicated in the codecs machinery. been corrected in Python 3, where (unicode) str objects no longer have a decode method, and bytes objects no longer have an encode method. The Python documentation ("http://docs.python.org/library/functions.html#unicode";) does not mention this. Yes it does. It is is the SECOND sentence, immediately after the summary line: unicode([object[, encoding[, errors]]]) Return the Unicode string version of object using one of the following modes: If encoding and/or errors are given, unicode() will decode the object which can either be an 8-bit string or a character buffer using the codec for encoding. ... Admittedly, it doesn't *explicitly* state that TypeError will be raised, but what other exception kind would you expect when you supply an argument of the wrong type? What you have correctly pointed out is that there is no discrepancy between doc and behavior and hence no bug for the purpose of the tracker. Thanks. It is therefore necessary to check the type before calling "unicode", or catch the undocumented TypeError exception afterward. Yes, this check should not be necessary; calling the ‘unicode’ constructor with an object that's already an instance of ‘unicode’ should just return the object as-is, IMO. It shouldn't matter that you've specified how decoding errors are to be handled, because in that case no decoding happens anyway. I don't believe that it is the job of unicode() to Do What I Mean, but only to Do What I Say. If I *explicitly* tell unicode() to decode the argument (by specifying either the codec or the error handler or both) then it should not double-guess me and ignore the extra parameters. End-user applications may, with care, try to be smart and DWIM, but library functions should be dumb and should do what they are told. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: "Decoding unicode is not supported" in unusual situation
On Thu, 08 Mar 2012 08:48:58 +1100, Ben Finney wrote: > John Nagle writes: > >>The library bug, if any, is that you can't apply >> >> unicode(s, errors='replace') >> >> to a Unicode string. TypeError("Decoding unicode is not supported") is >> raised. However >> >> unicode(s) >> >> will accept Unicode input. > > I think that's a Python bug. If the latter succeeds as a no-op, the > former should also succeed as a no-op. Neither should ever get any > errors when ‘s’ is a ‘unicode’ object already. No. The semantics of the unicode function (technically: a type constructor) are well-defined, and there are two distinct behaviours: unicode(obj) is analogous to str(obj), and it attempts to convert obj to a unicode string by calling obj.__unicode__, if it exists, or __str__ if it doesn't. No encoding or decoding is attempted in the event that obj is a unicode instance. unicode(obj, encoding, errors) is explicitly stated in the docs as decoding obj if EITHER of encoding or errors is given, AND that obj must be either an 8-bit string (bytes) or a buffer object. It is true that u''.decode() will succeed, in Python 2, but the fact that unicode objects have a decode method at all is IMO a bug. It has also been corrected in Python 3, where (unicode) str objects no longer have a decode method, and bytes objects no longer have an encode method. >> The Python documentation >> ("http://docs.python.org/library/functions.html#unicode";) does not >> mention this. Yes it does. It is is the SECOND sentence, immediately after the summary line: unicode([object[, encoding[, errors]]]) Return the Unicode string version of object using one of the following modes: If encoding and/or errors are given, unicode() will decode the object which can either be an 8-bit string or a character buffer using the codec for encoding. ... Admittedly, it doesn't *explicitly* state that TypeError will be raised, but what other exception kind would you expect when you supply an argument of the wrong type? >> It is therefore necessary to check the type before >> calling "unicode", or catch the undocumented TypeError exception >> afterward. > > Yes, this check should not be necessary; calling the ‘unicode’ > constructor with an object that's already an instance of ‘unicode’ > should just return the object as-is, IMO. It shouldn't matter that > you've specified how decoding errors are to be handled, because in that > case no decoding happens anyway. I don't believe that it is the job of unicode() to Do What I Mean, but only to Do What I Say. If I *explicitly* tell unicode() to decode the argument (by specifying either the codec or the error handler or both) then it should not double-guess me and ignore the extra parameters. End-user applications may, with care, try to be smart and DWIM, but library functions should be dumb and should do what they are told. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: sys.stdout.detach() results in ValueError
Dave Angel schreef op de 7e dag van de lentemaand van het jaar 2012: > On 03/07/2012 02:41 PM, Peter Kleiweg wrote: > > I want to write out some binary data to stdout in Python3. I > > thought the way to do this was to call detach on sys.stdout. But > > apparently, you can't. Here is a minimal script: > > > > #!/usr/bin/env python3.1 > > import sys > > fp = sys.stdout.detach() > > > > Not yet using fp in any way, this script gives the following error: > > > > Exception ValueError: 'underlying buffer has been detached' in > > > > Same in Python 3.1.4 and Python 3.2.2 > > > > So, what do I do if I want to send binary data to stdout? > > > > > > > > sys.stdout.write( some_binary_data ) TypeError: must be str, not bytes -- Peter Kleiweg http://pkleiweg.home.xs4all.nl/ -- http://mail.python.org/mailman/listinfo/python-list
Re: sys.stdout.detach() results in ValueError
On 03/07/2012 02:41 PM, Peter Kleiweg wrote: I want to write out some binary data to stdout in Python3. I thought the way to do this was to call detach on sys.stdout. But apparently, you can't. Here is a minimal script: #!/usr/bin/env python3.1 import sys fp = sys.stdout.detach() Not yet using fp in any way, this script gives the following error: Exception ValueError: 'underlying buffer has been detached' in Same in Python 3.1.4 and Python 3.2.2 So, what do I do if I want to send binary data to stdout? sys.stdout.write( some_binary_data ) Why should you need to do some funny manipulation? If you have some other unstated motivation, better ask a clearer question. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: are int, float, long, double, side-effects of computer engineering?
On Mar 6, 7:25 pm, rusi wrote: > On Mar 6, 6:11 am, Xah Lee wrote: > > > some additional info i thought is relevant. > > > are int, float, long, double, side-effects of computer engineering? > > It is a bit naive for computer scientists to club integers and reals > as mathematicians do given that for real numbers, even equality is > undecidable! > Mostly when a system like mathematica talks of real numbers it means > computable real numbers which is a subset of mathematical real numbers > (and of course a superset of floats) > > Seehttp://en.wikipedia.org/wiki/Computable_number#Can_computable_numbers... I might add that Mathematica is designed mainly for symbolic computation, whereas IEEE floating point numbers are intended for numerical computation. Those are two very different endeavors. I played with Mathematica a bit several years ago, and I know it can do numerical computation too. I wonder if it resorts to IEEE floating point numbers when it does. -- http://mail.python.org/mailman/listinfo/python-list
python-list@python.org
I play around with redis. Isn't it possible to handle BitSet with Python "as" in Java? BitSet users = BitSet.valueOf(redis.get(key.getBytes())); all.or(users); System.out.println(all.cardinality()) I try something with the struct and bitstring libs , but haven't any success. Even the follow snippet didn't work, beacause bitset[0] isn't approriate. bitset = r.get('bytestringFromRedis') x = "{0:b}".format(ord(bitset[0])) Thanks in advance Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: RE: What's the best way to write this regular expression?
On 01/-10/-28163 01:59 PM, Prasad, Ramit wrote: gz stands for gzip and is a form of compression (like rar/zip ). tar stands for a tape archive. It is basically a box that holds the files. So you need to "unzip" and then "open the box". Normally programs like WinZip / WinRar / 7-zip will do both in one step so you do not need to. Not sure what program you are using... I'm not sure what 7-zip you're referring to, because I use 7-zip and it's always been a two-step process for me... (Though I can't say I've looked through the preferences dialog for a "extract .tar.gz files in one go" setting.) Evan -- http://mail.python.org/mailman/listinfo/python-list
Re: Project
Dev Dixit writes: > Please, tell me how to develop project on "how people intract with > social networing sites". Step one: collect data. Step two: ??? Step three: project! -- \ “Try to become not a man of success, but try rather to become a | `\ man of value.” —Albert Einstein | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: "Decoding unicode is not supported" in unusual situation
John Nagle writes: >The library bug, if any, is that you can't apply > > unicode(s, errors='replace') > > to a Unicode string. TypeError("Decoding unicode is not supported") is > raised. However > > unicode(s) > > will accept Unicode input. I think that's a Python bug. If the latter succeeds as a no-op, the former should also succeed as a no-op. Neither should ever get any errors when ‘s’ is a ‘unicode’ object already. > The Python documentation > ("http://docs.python.org/library/functions.html#unicode";) does not > mention this. It is therefore necessary to check the type before > calling "unicode", or catch the undocumented TypeError exception > afterward. Yes, this check should not be necessary; calling the ‘unicode’ constructor with an object that's already an instance of ‘unicode’ should just return the object as-is, IMO. It shouldn't matter that you've specified how decoding errors are to be handled, because in that case no decoding happens anyway. Care to report that bug to http://bugs.python.org/>, John? -- \ “Those who write software only for pay should go hurt some | `\ other field.” —Erik Naggum, in _gnu.misc.discuss_ | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
On Wed, Mar 7, 2012 at 3:34 PM, Ian Kelly wrote: > The setup.py file (as well as the other files) would be inside the > .tar file. Unlike a Windows zip file, which does both archival and > compression, Unix files are typically archived and compressed in two > separate steps: "tar" denotes the archival format, and "gz" denotes > the compression format. Some decompression programs are smart enough > to recognize the .tar file and automatically extract it when > decompressing. Others require you to decompress the .gz and extract > the .tar separately -- it sounds like yours is one of the latter. Ah, I see now. After opening the gz file, there was a tar file inside, and then I just opened that file (I use 7zip for these types) and there was a whole host of stuff inside. I didn't realize the tar file itself was an archive, I thought it was the module! ::blush:: Maybe I don't need to mess with the "distribute" utility then, if I can just run the setup file. I'll try that first and see what happens. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
On Wed, Mar 7, 2012 at 2:11 PM, John Salerno wrote: > The only files included in the .tar.gz file is a .tar file of the same > name. So I guess the setup option doesn't exist for these particular > packages. The setup.py file (as well as the other files) would be inside the .tar file. Unlike a Windows zip file, which does both archival and compression, Unix files are typically archived and compressed in two separate steps: "tar" denotes the archival format, and "gz" denotes the compression format. Some decompression programs are smart enough to recognize the .tar file and automatically extract it when decompressing. Others require you to decompress the .gz and extract the .tar separately -- it sounds like yours is one of the latter. -- http://mail.python.org/mailman/listinfo/python-list
RE: Project
> > Pay a smart developer! > > What? For homework? Sure why not? Smart developers could use extra money ;) Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
RE: What's the best way to write this regular expression?
> The only files included in the .tar.gz file is a .tar file of the same > name. gz stands for gzip and is a form of compression (like rar/zip ). tar stands for a tape archive. It is basically a box that holds the files. So you need to "unzip" and then "open the box". Normally programs like WinZip / WinRar / 7-zip will do both in one step so you do not need to. Not sure what program you are using... Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python site-packages permission denied?
On Wed, Mar 7, 2012 at 1:02 PM, Shane Neeley wrote: > What do I need to do to successfully install a package onto python so that I > can use it as a module? > > I have tried in terminal in the correct directory "python2.7 ./setup.py > install" but it says permission denied. > > Shanes-MacBook-Pro:seisen-urllib2_file-cf4c4c8 chimpsarehungry$ python2.7.1 > ./setup.py install > -bash: python2.7.1: command not found > Shanes-MacBook-Pro:seisen-urllib2_file-cf4c4c8 chimpsarehungry$ python > ./setup.py install > running install > running build > running build_py > running install_lib > copying build/lib/urllib2_file.py -> /Library/Python/2.7/site-packages > error: /Library/Python/2.7/site-packages/urllib2_file.py: Permission denied > Shanes-MacBook-Pro:seisen-urllib2_file-cf4c4c8 chimpsarehungry$ You generally shouldn't mess with Mac OS X's system copies of Python. Typically, one installs a separate copy using MacPorts, Fink, or whatever, and uses that instead. In any case, you generally need to `sudo` when installing stuff system-wide. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
On Wed, Mar 7, 2012 at 4:11 PM, John Salerno wrote: > > On Wed, Mar 7, 2012 at 3:01 PM, Ian Kelly wrote: > > > There is a fork of setuptools called "distribute" that supports Python > > 3. > > Thanks, I guess I'll give this a try tonight! > > > setup.py is a file that should be included at the top-level of the > > .tar files you downloaded. Generally, to install something in that > > manner, you would navigate to that top-level folder and run "python > > setup.py install". If you have multiple Python versions installed and > > want to install the package for a specific version, then you would use > > that version of Python to run the setup.py file. > > The only files included in the .tar.gz file is a .tar file of the same > name. So I guess the setup option doesn't exist for these particular > packages. I'll try "distribute" tonight when I have some time to mess > with all of this. > > So much work just to get a 3rd party module installed! > -- It's because your extraction program is weird. Gzip is a compression algorithm that operates on a single file. Tar is an archive format that combines multiple files into a single file. When we say "extract the .tar.gz", what we mean is both uncompress the tar file and then extract everything out of that. A lot of programs will do that in one step. If you look inside the tar file, you should find the setup.py. -- http://mail.python.org/mailman/listinfo/python-list
Re: Project
On Wed, 07 Mar 2012 13:06:38 -0500, Rodrick Brown wrote: > Pay a smart developer! What? For homework? -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
On Wed, Mar 7, 2012 at 3:01 PM, Ian Kelly wrote: > There is a fork of setuptools called "distribute" that supports Python 3. Thanks, I guess I'll give this a try tonight! > setup.py is a file that should be included at the top-level of the > .tar files you downloaded. Generally, to install something in that > manner, you would navigate to that top-level folder and run "python > setup.py install". If you have multiple Python versions installed and > want to install the package for a specific version, then you would use > that version of Python to run the setup.py file. The only files included in the .tar.gz file is a .tar file of the same name. So I guess the setup option doesn't exist for these particular packages. I'll try "distribute" tonight when I have some time to mess with all of this. So much work just to get a 3rd party module installed! -- http://mail.python.org/mailman/listinfo/python-list
Python site-packages permission denied?
What do I need to do to successfully install a package onto python so that I can use it as a module? I have tried in terminal in the correct directory "python2.7 ./setup.py install" but it says permission denied. Shanes-MacBook-Pro:seisen-urllib2_file-cf4c4c8 chimpsarehungry$ python2.7.1 ./setup.py install -bash: python2.7.1: command not found Shanes-MacBook-Pro:seisen-urllib2_file-cf4c4c8 chimpsarehungry$ python ./setup.py install running install running build running build_py running install_lib copying build/lib/urllib2_file.py -> /Library/Python/2.7/site-packages error: /Library/Python/2.7/site-packages/urllib2_file.py: Permission denied Shanes-MacBook-Pro:seisen-urllib2_file-cf4c4c8 chimpsarehungry$ -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
On Wed, Mar 7, 2012 at 1:39 PM, John Salerno wrote: > Ok, first major roadblock. I have no idea how to install Beautiful > Soup or lxml on Windows! All I can find are .tar files. Based on what > I've read, I can use the easy_setup module to install these types of > files, but when I went to download the setuptools package, it only > seemed to support Python 2.7. I'm using 3.2. Is 2.7 just the minimum > version it requires? It didn't say something like "2.7+", so I wasn't > sure, and I don't want to start installing a bunch of stuff that will > clog up my directories and not even work. There is a fork of setuptools called "distribute" that supports Python 3. > What's the best way for me to install these two packages? I've also > seen a reference to using setup.py...is that a separate package too, > or is that something that comes with Python by default? setup.py is a file that should be included at the top-level of the .tar files you downloaded. Generally, to install something in that manner, you would navigate to that top-level folder and run "python setup.py install". If you have multiple Python versions installed and want to install the package for a specific version, then you would use that version of Python to run the setup.py file. -- http://mail.python.org/mailman/listinfo/python-list
what is best method to set sys.stdout to utf-8?
In Python 3, there seem to be two ways to set sys.stdout to utf-8 after the script has started: sys.stdout = codecs.getwriter('utf-8')(sys.stdout.detach()) sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8') I guess the second is better. At start-up, type(sys.stdout) is , and it's also after using the second method. After using the first method, type(sys.stdout) is changed to . Should I always use the second method? -- Peter Kleiweg http://pkleiweg.home.xs4all.nl/ -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
Ok, first major roadblock. I have no idea how to install Beautiful Soup or lxml on Windows! All I can find are .tar files. Based on what I've read, I can use the easy_setup module to install these types of files, but when I went to download the setuptools package, it only seemed to support Python 2.7. I'm using 3.2. Is 2.7 just the minimum version it requires? It didn't say something like "2.7+", so I wasn't sure, and I don't want to start installing a bunch of stuff that will clog up my directories and not even work. What's the best way for me to install these two packages? I've also seen a reference to using setup.py...is that a separate package too, or is that something that comes with Python by default? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python recursive tree, linked list thingy
On Wed, Mar 7, 2012 at 1:03 PM, Ian Kelly wrote: > A set of defective pixels would be the probable choice, since it > offers efficient membership testing. Some actual code, using a recursive generator: def get_cluster(defective, pixel): yield pixel (row, column) = pixel for adjacent in [(row - 1, column), (row, column - 1), (row, column + 1), (row + 1, column)]: if adjacent in defective: defective.remove(adjacent) for cluster_pixel in get_cluster(defective, adjacent): yield cluster_pixel defective = {(327, 415), (180, 97), (326, 415), (42, 15), (180, 98), (325, 414), (325, 415)} clusters = [] while defective: pixel = defective.pop() clusters.append(list(get_cluster(defective, pixel))) from pprint import pprint pprint(clusters) Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: Python recursive tree, linked list thingy
Am 07.03.2012 20:49, schrieb Wanderer: I have a list of defective CCD pixels and I need to find clusters where a cluster is a group of adjacent defective pixels. This seems to me to be a classic linked list tree search.I take a pixel from the defective list and check if an adjacent pixel is in the list. If it is I add the pixel to the cluster and remove it from the defective list. I then check an adjacent pixel of the new pixel and so on down the branch until I don't find a defective pixel. The I move up to the previous pixel and check the next adjacent pixel and so on until I'm back at the head I can't find any more defective adjacent pixels. How do you handle this sort of thing in Python? I'd do something like (code not tested): defective_list = [(x1, y1), (x2, y2), ...] #list of coordinates of #defective pixel #build one cluster: cluster_start = defective_list.pop() #starting point buf = [] #buffer for added pixels buf.push(cluster_start) cluster = [] cluster.push(cluster_start) while len(buf)>0: i = buf.pop() for b, d in itertools.product(xrange(2), [-1,1]): #4 neighbours j = list(i) j[b] += d j = tuple(j) if outside_lcd(j) or j in cluster or j not in defective_list: continue defective_list.remove(j) cluster.push(j) buf.push(j) return cluster and repeat it until defective_list is empty. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python recursive tree, linked list thingy
On 07/03/2012 19:49, Wanderer wrote: I have a list of defective CCD pixels and I need to find clusters where a cluster is a group of adjacent defective pixels. This seems to me to be a classic linked list tree search.I take a pixel from the defective list and check if an adjacent pixel is in the list. If it is I add the pixel to the cluster and remove it from the defective list. I then check an adjacent pixel of the new pixel and so on down the branch until I don't find a defective pixel. The I move up to the previous pixel and check the next adjacent pixel and so on until I'm back at the head I can't find any more defective adjacent pixels. How do you handle this sort of thing in Python? Something like this could work: clusters = [] while defective_set: to_do = {defective_set.pop()} done = set() while to_do: pixel = to_do.pop() neighbours = {n for n in defective_set if are_adjacent(n, pixel)} defective_set -= neighbours to_do |= neighbours done.add(pixel) clusters.append(done) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python recursive tree, linked list thingy
On Wed, Mar 7, 2012 at 12:49 PM, Wanderer wrote: > I have a list of defective CCD pixels and I need to find clusters > where a cluster is a group of adjacent defective pixels. This seems to > me to be a classic linked list tree search.I take a pixel from the > defective list and check if an adjacent pixel is in the list. If it is > I add the pixel to the cluster and remove it from the defective list. > I then check an adjacent pixel of the new pixel and so on down the > branch until I don't find a defective pixel. The I move up to the > previous pixel and check the next adjacent pixel and so on until I'm > back at the head I can't find any more defective adjacent pixels. How > do you handle this sort of thing in Python? A set of defective pixels would be the probable choice, since it offers efficient membership testing. -- http://mail.python.org/mailman/listinfo/python-list
RE: Project
> > Please, tell me how to develop project on "how people intract with > > social networing sites". > > This sounds more like a social sciences study than anything > programming related... > > And since I don't do such sites, it may be intractable... Or he could be wanting to know how to use something like Facebook API, but with such a vague description it is hard to say. Even harder to be interested in helping since that is such a broad scope. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Python recursive tree, linked list thingy
I have a list of defective CCD pixels and I need to find clusters where a cluster is a group of adjacent defective pixels. This seems to me to be a classic linked list tree search.I take a pixel from the defective list and check if an adjacent pixel is in the list. If it is I add the pixel to the cluster and remove it from the defective list. I then check an adjacent pixel of the new pixel and so on down the branch until I don't find a defective pixel. The I move up to the previous pixel and check the next adjacent pixel and so on until I'm back at the head I can't find any more defective adjacent pixels. How do you handle this sort of thing in Python? -- http://mail.python.org/mailman/listinfo/python-list
sys.stdout.detach() results in ValueError
I want to write out some binary data to stdout in Python3. I thought the way to do this was to call detach on sys.stdout. But apparently, you can't. Here is a minimal script: #!/usr/bin/env python3.1 import sys fp = sys.stdout.detach() Not yet using fp in any way, this script gives the following error: Exception ValueError: 'underlying buffer has been detached' in Same in Python 3.1.4 and Python 3.2.2 So, what do I do if I want to send binary data to stdout? -- Peter Kleiweg http://pkleiweg.home.xs4all.nl/ -- http://mail.python.org/mailman/listinfo/python-list
Re: "Decoding unicode is not supported" in unusual situation
On 3/7/2012 3:42 AM, Steven D'Aprano wrote: I *think* he is complaining that some other library -- suds? -- has a broken test for Unicode, by using: if type(s) is unicode: ... instead of if isinstance(s, unicode): ... Consequently, when the library passes a unicode *subclass* to the tounicode function, the "type() is unicode" test fails. That's a bad bug. No, that was my bug. The library bug, if any, is that you can't apply unicode(s, errors='replace') to a Unicode string. TypeError("Decoding unicode is not supported") is raised. However unicode(s) will accept Unicode input. The Python documentation ("http://docs.python.org/library/functions.html#unicode";) does not mention this. It is therefore necessary to check the type before calling "unicode", or catch the undocumented TypeError exception afterward. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-2.6.1 ctypes test cases failing
On 3/7/2012 12:43 PM, Naresh Bhat wrote: Hi All, I have the following setup Kernel version: linux-2.6.32.41 Python Version: Python-2.6.1 Hardware target: MIPS 64bit I am just trying to run python test cases, Observed that on my MIPS 64bit system only _ctypes related test cases are failing. Is there any available patch for this issue ?? There have been patches to ctypes since 2.6.1. At minimum, you should be using the latest version of 2.6. Even better, perhaps, would be the latest version of 2.7, since it contain patches applied after 2.6 went to security fixes only. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
RE: are int, float, long, double, side-effects of computer engineering?
Dennis Lee Bieber wrote: > It wouldn't surprise me to find out that modern CompSci degrees > don't even discuss machine representation of numbers. As a fairly recent graduate, I can assure you that they still do. Well, I should say at least my school did since I cannot speak for every other school. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: Project
Pay a smart developer! Sent from my iPhone On Mar 7, 2012, at 4:46 AM, Dev Dixit wrote: > Please, tell me how to develop project on "how people intract with > social networing sites". > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Python-2.6.1 ctypes test cases failing
Hi All, I have the following setup Kernel version: linux-2.6.32.41 Python Version: Python-2.6.1 Hardware target: MIPS 64bit I am just trying to run python test cases, Observed that on my MIPS 64bit system only _ctypes related test cases are failing. Is there any available patch for this issue ?? Only _ctypes test cases are failing: root@cavium-octeonplus:~# root@cavium-octeonplus:~# python /usr/lib32/python2.6/test/test_ctypes.py . .. test_doubleresult (ctypes.test.test_functions.FunctionTestCase) ... FAIL test_floatresult (ctypes.test.test_functions.FunctionTestCase) ... FAIL test_intresult (ctypes.test.test_functions.FunctionTestCase) ... FAIL test_longdoubleresult (ctypes.test.test_functions.FunctionTestCase) ... FAIL test_longlongresult (ctypes.test.test_functions.FunctionTestCase) ... FAIL test_wchar_parm (ctypes.test.test_functions.FunctionTestCase) ... FAIL test_wchar_result (ctypes.test.test_functions.FunctionTestCase) ... FAIL test_longdouble (ctypes.test.test_callbacks.Callbacks) ... FAIL test_integrate (ctypes.test.test_callbacks.SampleCallbacksTestCase) ... FAIL test_wchar_parm (ctypes.test.test_as_parameter.AsParamPropertyWrapperTestCase) ... FAIL test_wchar_parm (ctypes.test.test_as_parameter.AsParamWrapperTestCase) ... FAIL test_wchar_parm (ctypes.test.test_as_parameter.BasicWrapTestCase) ... FAIL test_qsort (ctypes.test.test_libc.LibTest) ... FAIL test_sqrt (ctypes.test.test_libc.LibTest) ... FAIL test_double (ctypes.test.test_cfuncs.CFunctions) ... FAIL test_double_plus (ctypes.test.test_cfuncs.CFunctions) ... FAIL test_float (ctypes.test.test_cfuncs.CFunctions) ... FAIL test_float_plus (ctypes.test.test_cfuncs.CFunctions) ... FAIL test_longdouble (ctypes.test.test_cfuncs.CFunctions) ... FAIL test_longdouble_plus (ctypes.test.test_cfuncs.CFunctions) ... FAIL --Thanks and Regards "For things to change, we must change" -Naresh Bhat -- http://mail.python.org/mailman/listinfo/python-list
Re: Project
In Dev Dixit writes: > Please, tell me how to develop project on "how people intract with > social networing sites". First you need a more detailed description of exactly what you want. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list
Re: help: confused about python flavors....
On Mar 7, 9:41 am, Dennis Lee Bieber wrote: > On Tue, 6 Mar 2012 20:06:37 -0800 (PST), amar Singh > declaimed the following in > gmane.comp.python.general: > > > Hi, > > > I am confused between plain python, numpy, scipy, pylab, matplotlib. > > > I have high familiarity with matlab, but the computer I use does not > > have it. So moving to python. > > What should I use? and the best way to use it. I will be running > > matlab-like scripts sometimes on the shell prompt and sometimes on the > > command line. > > If Matlab compatibility is a high constraint, I'll speak heresy and > suggest you might look at Octavehttp://en.wikipedia.org/wiki/GNU_Octave > > Python is stand-alone programming/scripting language. Numpy is an > extension package adding array/matrix math operations but the syntax > won't be a direct match to Matlab; Scipy is an extension package that, > well, extends Numpy. Matplotlib is a separate package for graphical > plotting of array data. {simplistic explanation} > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfr...@ix.netcom.com HTTP://wlfraed.home.netcom.com/ Thanks everyone for helping me on this. -- http://mail.python.org/mailman/listinfo/python-list
Project
Please, tell me how to develop project on "how people intract with social networing sites". -- http://mail.python.org/mailman/listinfo/python-list
deal with cookie in python 2.3
Dear All, right now I use python to capture data from a internal website. The website uses cookie to store authorization data. But there is no HttpCookieProcessor in python 2.3? Is there anybody know, how to deal with cookie in python 2.3? and could give me a sample code? thanks a lot Julian-- http://mail.python.org/mailman/listinfo/python-list
Re: Porting the 2-3 heap data-structure library from C to Python
Hrvoje Niksic, 07.03.2012 16:48: > Alec Taylor writes: > >> The source-code used has been made available: >> http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.h >> http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.c >> >> I plan on wrapping it in a class. > > You should get acquainted with the Python/C API If it proves necessary, yes. > which is the standard way of extending Python with high-performance > (and/or system-specific) C code. Well, it's *one* way. Certainly not the easiest way, neither the most portable and you'll have a hard time making it the fastest. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Porting the 2-3 heap data-structure library from C to Python
Alec Taylor writes: > The source-code used has been made available: > http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.h > http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.c > > I plan on wrapping it in a class. You should get acquainted with the Python/C API, which is the standard way of extending Python with high-performance (and/or system-specific) C code. See "Extending and Embedding" and "Python/C API" sections at http://docs.python.org/. There is also a mailing list for help with the C API, see http://mail.python.org/mailman/listinfo/capi-sig for details. -- http://mail.python.org/mailman/listinfo/python-list
Re: RotatingFileHandler Fails
Hi, Actually NonInheritedRotatingFileHandler is rotating the log files but some times it falis and showing I/O errors while the log file limit reaches the given size. Thanks Arun -- View this message in context: http://python.6.n6.nabble.com/RotatingFileHandler-Fails-tp4542769p4554781.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list
Python 3.2 and MS Outlook
Is there documentation showing how to read from a Microsoft Outlook server using Python 3.2. I've done it with 2.x, but can't find anything to help me with 3.2. Thanks, --greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Porting the 2-3 heap data-structure library from C to Python
Alec Taylor, 07.03.2012 15:25: > I am planning to port the 2-3 heap data-structure as described by > Professor Tadao Takaoka in Theory of 2-3 Heaps published in 1999 and > available in PDF: > http://www.cosc.canterbury.ac.nz/tad.takaoka/2-3heaps.pdf > > The source-code used has been made available: > http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.h > http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.c > > I plan on wrapping it in a class. > > This tutorial I used to just test out calling C within Python > (http://richizo.wordpress.com/2009/01/25/calling-c-functions-inside-python/) > and it seems to work, but this might not be the recommended method. > > Any best practices for how best to wrap the 2-3 heap data-structure > from C to Python? For data structures, where performance tends to matter, it's usually best to start with Cython right away, instead of using ctypes. http://cython.org/ Here's a tutorial for wrapping a C library with it: http://docs.cython.org/src/tutorial/clibraries.html Stefan -- http://mail.python.org/mailman/listinfo/python-list
Porting the 2-3 heap data-structure library from C to Python
I am planning to port the 2-3 heap data-structure as described by Professor Tadao Takaoka in Theory of 2-3 Heaps published in 1999 and available in PDF: http://www.cosc.canterbury.ac.nz/tad.takaoka/2-3heaps.pdf The source-code used has been made available: http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.h http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.c I plan on wrapping it in a class. This tutorial I used to just test out calling C within Python (http://richizo.wordpress.com/2009/01/25/calling-c-functions-inside-python/) and it seems to work, but this might not be the recommended method. Any best practices for how best to wrap the 2-3 heap data-structure from C to Python? Thanks for all suggestions, Alec Taylor -- http://mail.python.org/mailman/listinfo/python-list
GUI components in python
Hi I am stuck with the brain workshop software implemented using python. The code involves a lot of GUI elements and i am familar only with the basic python programming. I would like to know whether there are built in classes to support GUI elements or arethey project dependant. -- janaki -- http://mail.python.org/mailman/listinfo/python-list
Re: RotatingFileHandler Fails
Hi nac, NTSafeLogging.py is working fine without any errors, but its not rotating the log files as rotatingfilehandler does. Do you have any working sample with NTSafeLogging which rotates the log file. logging issue with subprocess.Popen can be solved using this code import threading lock = threading.RLock() def acquire_lock(): lock.acquire() def release_lock(): lock.release() call the acquire_lock() at the begining of method and release_lock() at the end -- View this message in context: http://python.6.n6.nabble.com/RotatingFileHandler-Fails-tp4542769p4554381.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list
Re: "Decoding unicode is not supported" in unusual situation
On Wed, 07 Mar 2012 22:18:50 +1100, Ben Finney wrote: > de...@web.de (Diez B. Roggisch) writes: > >> John Nagle writes: >> >> > I think that somewhere in "suds", they subclass the "unicode" type. >> > That's almost too cute. >> > >> > The proper test is >> > >> >isinstance(s,unicode) >> >> Woot, you finally discovered polymorphism - congratulations! > > If by “discovered” you mean “broke”. > > John, polymorphism entails that it *doesn't matter* whether the object > inherits from any particular type; it only matters whether the object > behaves correctly. > > So rather than testing whether the object inherits from ‘unicode’, test > whether it behaves how you expect – preferably by just using it as > though it does behave that way. I must admit that I can't quite understand John Nagle's original post, so I could be wrong, but I *think* that both you and Diez have misunderstood the nature of John's complaint. I *think* he is complaining that some other library -- suds? -- has a broken test for Unicode, by using: if type(s) is unicode: ... instead of if isinstance(s, unicode): ... Consequently, when the library passes a unicode *subclass* to the tounicode function, the "type() is unicode" test fails. That's a bad bug. It's arguable that the library shouldn't even use isinstance, but that's an argument for another day. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: "Decoding unicode is not supported" in unusual situation
de...@web.de (Diez B. Roggisch) writes: > John Nagle writes: > > > I think that somewhere in "suds", they subclass the "unicode" type. > > That's almost too cute. > > > > The proper test is > > > > isinstance(s,unicode) > > Woot, you finally discovered polymorphism - congratulations! If by “discovered” you mean “broke”. John, polymorphism entails that it *doesn't matter* whether the object inherits from any particular type; it only matters whether the object behaves correctly. So rather than testing whether the object inherits from ‘unicode’, test whether it behaves how you expect – preferably by just using it as though it does behave that way. -- \ Lucifer: “Just sign the Contract, sir, and the Piano is yours.” | `\ Ray: “Sheesh! This is long! Mind if I sign it now and read it | _o__)later?” —http://www.achewood.com/ | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Need help in wx.ListBox edit
Hi , I am using wxWidget for GUI programming. I need help in editing text appended in wx.ListBox(). Which wx API's do I need to use ? I would like to edit text on mouse double click event . Thanks in advance. Praveen. The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised. If you are not the intended recipient, please notify Airbus immediately and delete this e-mail. Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately. All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
John Salerno writes: > The Beautiful Soup 4 documentation was very clear, and BS4 itself is > so simple and Pythonic. And best of all, since version 4 no longer > does the parsing itself, you can choose your own parser, and it works > with lxml, so I'll still be using lxml, but with a nice, clean overlay > for navigating the tree structure. I haven't used BS4 but have made good use of earlier versions. Main thing to understand is that an awful lot of HTML in the real world is malformed and will break an XML parser or anything that expects syntactically invalid HTML. People tend to write HTML that works well enough to render decently in browsers, whose parsers therefore have to be tolerant of bad errors. Beautiful Soup also tries to make sense of crappy, malformed, HTML. Partly as a result, it's dog slow compared to any serious XML parser. But it works very well if you don't mind the low speed. -- http://mail.python.org/mailman/listinfo/python-list
Re: Error importing __init__ declared variable from another package
On Wed, Feb 29, 2012 at 1:38 AM, Jason Veldicott wrote: >> > Hi, >> > >> > I have a simple configuration of modules as beneath, but an import error >> > is reported: >> > >> > /engine >> > (__init__ is empty here) >> > engine.py >> > /sim >> > __init__.py >> > >> > >> > The module engine.py imports a variable instantiated in sim.__init__ as >> > follows: >> > >> > from sim import var_name >> > var_name.func() >> > >> > The following error messaged is received on the func() call above >> > (Eclipse >> > PyDev): >> > >> > "undefined variable from import: func" >> Are you rephrasing or is this really the error message? If so run your >> program again on the command-line. Then please cut and paste the error >> message together with the traceback. >> > Any idea why this is causing an error? >> What version of Python are you using? >> What does sim/__init__.py contain? > > > > Thanks Peter. > > I'm using Python 2.6, but it works at the command line. The error only > appears in Eclipse as a red cross in the margin. The exact error msg, as > appears in a floating text caption on mouse over, is as I mentioned > (capitalised). > > Perhaps it is some issue in PyDev, maybe related to the version of Python > I'm using. > > I'm in the process of trying to solve another related import problem, and > wished to resolve this one in the hope that it might shed light on the > other. But as it works beside the error icon appearing, I might just ignore > it and spare the trouble of precise identification of cause. Please report that as a bug in the PyDev sf tracker (please attach a sample project where this problem can be reproduced). Cheers, Fabio -- http://mail.python.org/mailman/listinfo/python-list
Re: "Decoding unicode is not supported" in unusual situation
John Nagle writes: > I think that somewhere in "suds", they subclass the "unicode" type. > That's almost too cute. > > The proper test is > > isinstance(s,unicode) Woot, you finally discovered polymorphism - congratulations! Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: help: confused about python flavors....
On 07/03/2012 06:24, Steven D'Aprano wrote: On Tue, 06 Mar 2012 20:06:37 -0800, amar Singh wrote: Hi, I am confused between plain python, numpy, scipy, pylab, matplotlib. Python is a programming language. It comes standard with many libraries for doing basic mathematics, web access, email, etc. Numpy is a library for doing scientific numerical maths work and fast processing of numeric arrays. Scipy is another library for scientific work. It is separate from, but uses, Numpy. Matplotlib is a project for making graphing and plotting of numeric data easy in Python. Pylab is a project to be Python's version of Matlab: it intends to be an integrated bundle of Python the programming language, Numpy, Scipy, and Matplotlib all in one easy-to-use application. I have high familiarity with matlab, but the computer I use does not have it. So moving to python. What should I use? and the best way to use it. I will be running matlab-like scripts sometimes on the shell prompt and sometimes on the command line. Pylab is intended to be the closest to Matlab, but I don't know how close it is. Also, Pylab is NOT compatible with Matlab: its aim is to be an alternative to Matlab, not to be a clone. So it cannot run Matlab scripts. You might also like to look at Sage: http://www.sagemath.org/ Sage is a Python project aimed to be an alternative to Mathematica. Ultimately, you will have to look at the packages, see their features, perhaps try them for a while (they are all free software, so the only cost is your time), and decide for yourself which one meets your needs. We can't answer that, because we don't know what you need. Matplotlib is excellent, it has an extensive pile of docs and examples, and the mailing list is extremely helpful. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Get tkinter text to the clipboard
bugzilla-mail-...@yandex.ru wrote: > How can I get something from tkinter gui to another program ? > tkinter on python 3.2 on kde4 How about import tkinter root = tkinter.Tk() root.clipboard_clear() root.clipboard_append("whatever") -- http://mail.python.org/mailman/listinfo/python-list
"Decoding unicode is not supported" in unusual situation
I'm getting line 79, in tounicode return(unicode(s, errors='replace')) TypeError: decoding Unicode is not supported from this, under Python 2.7: def tounicode(s) : if type(s) == unicode : return(s) return(unicode(s, errors='replace')) That would seem to be impossible. But it's not. "s" is generated from the "suds" SOAP client. The documentation for "suds" says: "Suds leverages python meta programming to provide an intuative API for consuming web services. Runtime objectification of types defined in the WSDL is provided without class generation." I think that somewhere in "suds", they subclass the "unicode" type. That's almost too cute. The proper test is isinstance(s,unicode) John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Why this recursive import fails?
I found it is a bug http://bugs.python.org/issue13187 -- http://mail.python.org/mailman/listinfo/python-list
Help: how to protect the module 'sys' and 'os'
Hi~ alls, I have to limit somebody modify the attr of 'sys'&'os'? e.g. you can't append sys.path. Someone has a good method? now my way: modified the source code of python ,"_PyObject_GenericSetAttrWithDict", because if you want to reset the value, you need to invoke this function. --- best regards pytom -- http://mail.python.org/mailman/listinfo/python-list
Re: pickle/unpickle class which has changed
Gelonida N wrote: > Is there anyhing like a built in signature which would help to detect, > that one tries to unpickle an object whose byte code has changed? No. The only thing that is stored is the "protocol", the format used to store the data. > The idea is to distinguish old and new pickled data and start some > 'migration code' fi required > The only thing, that I thought about so far was adding an explicit > version number to each class in order to detect such situations. If you know in advance that your class will undergo significant changes you may also consider storing more stable data in a file format that can easily be modified, e. g. json. -- http://mail.python.org/mailman/listinfo/python-list