RE: Short-circuit Logic
From: steve+comp.lang.pyt...@pearwood.info Subject: Re: Short-circuit Logic Date: Fri, 31 May 2013 05:13:51 + To: python-list@python.org On Fri, 31 May 2013 00:03:13 +0300, Carlos Nepomuceno wrote: From: steve+comp.lang.pyt...@pearwood.info Subject: Re: Short-circuit Logic Date: Thu, 30 May 2013 05:42:17 + To: python-list@python.org [...] Here's another way, mathematically equivalent (although not necessarily equivalent using floating point computations!) which avoids the divide-by- zero problem: abs(a - b) epsilon*a That's wrong! If abs(a) abs(a-b)/epsilon you will break the commutative law. For example: What makes you think that the commutative law is relevant here? How can't you see? I'll requote a previous message: }On Thu, 30 May 2013 13:45:13 +1000, Chris Angelico wrote: } } Let's suppose someone is told to compare floating point numbers by } seeing if the absolute value of the difference is less than some } epsilon. } }Which is usually the wrong way to do it! Normally one would prefer }*relative* error, not absolute: Since we are considering Chris's supposition (to compare floating point numbers) it's totally relevant to understand how that operation can be correctly implemented. Many things break the commutative law, starting with division and subtraction: 20 - 10 != 10 - 20 1/2 != 2/1 Most comparison operators other than equality and inequality: (23 42) != (42 23) String concatenation: Hello + World != World + Hello Many operations in the real world: put on socks, then shoes != put on shoes, then socks. That's is totally irrelevant in this case. The commutative law is essential to the equality operation. But you are correct that approximately-equal using *relative* error is not commutative. (Absolute error, on the other hand, is commutative.) As I said, any form of approximate equality has gotchas. But this gotcha is simple to overcome: abs(a -b) eps*max(abs(a), abs(b)) (Knuth's approximately equal to which you give.) This discussion reminded me of TAOCP and I paid a visit and bring the following functions: TAOCP? The Art of Computer Programming[1]! An old book full of excellent stuff! A MUST READ ;) http://www-cs-faculty.stanford.edu/~uno/taocp.html [1] Knuth, Donald (1981). The Art of Computer Programming. 2nd ed. Vol. 2. p. 218. Addison-Wesley. ISBN 0-201-03822-6. -- Steven -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Short-circuit Logic
On Fri, May 31, 2013 at 3:13 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: What makes you think that the commutative law is relevant here? Equality should be commutative. If a == b, then b == a. Also, it's generally understood that if a == c and b == c, then a == b, though there are more exceptions to that (especially in loosely-typed languages). ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Can anyone please help me in understanding the following python code
On Fri, May 31, 2013 at 3:43 PM, Cameron Simpson c...@zip.com.au wrote: On 30May2013 21:54, bhk...@gmail.com bhk...@gmail.com wrote: | One final question, Is there a way to edit the message once it has been posted? Essentially, no. If there's some error in a post, reply to it yourself with a correction. Transparency is a good thing. Revisionist history pretty much is not. Once your email or newsgroup post is sent, assume that it's also been received; at very least, you won't be far wrong. You'll sometimes see a response within minutes from someone who saw your post within seconds. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: python b'...' notation
On 31 mai, 00:19, alcyon st...@terrafirma.us wrote: On Wednesday, May 29, 2013 3:19:42 PM UTC-7, Cameron Simpson wrote: On 29May2013 13:14, Ian Kelly ian.g.ke...@gmail.com wrote: | On Wed, May 29, 2013 at 12:33 PM, alcyon st...@terrafirma.us wrote: | This notation displays hex values except when they are 'printable', in which case it displays that printable character. How do I get it to force hex for all bytes? Thanks, Steve | | Is this what you want? | | ''.join('%02x' % x for x in b'hello world') | '68656c6c6f20776f726c64' Not to forget binascii.hexlify. -- Cameron Simpson c...@zip.com.au Every particle continues in its state of rest or uniform motion in a straight line except insofar as it doesn't. - Sir Arther Eddington Thanks for the binascii.hexlify tip. I was able to make it work but I did have to write a function to get it exactly the string I wanted. I wanted, for example, b'\n\x00' to display as 0x0A 0x00 or b'!\xff(\xc0' to display as 0x21 0xFF 0x28 0xC0. a = b'!\xff(\xc0\n\x00' z = ['0x{:02X}'.format(c) for c in b] z ['0x21', '0xFF', '0x28', '0xC0', '0x0A', '0x00'] s = ' '.join(z) s '0x21 0xFF 0x28 0xC0 0x0A 0x00' jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: Short-circuit Logic
On Fri, 31 May 2013 09:42:38 +0300, Carlos Nepomuceno wrote: From: steve+comp.lang.pyt...@pearwood.info Subject: Re: Short-circuit Logic Date: Fri, 31 May 2013 05:13:51 + To: python-list@python.org On Fri, 31 May 2013 00:03:13 +0300, Carlos Nepomuceno wrote: From: steve+comp.lang.pyt...@pearwood.info Subject: Re: Short-circuit Logic Date: Thu, 30 May 2013 05:42:17 + To: python-list@python.org [...] Here's another way, mathematically equivalent (although not necessarily equivalent using floating point computations!) which avoids the divide-by- zero problem: abs(a - b) epsilon*a That's wrong! If abs(a) abs(a-b)/epsilon you will break the commutative law. For example: What makes you think that the commutative law is relevant here? How can't you see? I can ask the same thing about you. How can you see that it is not relevant? I'll requote a previous message: Thanks, but that's entirely irrelevant. It says nothing about the commutative law. [...] Since we are considering Chris's supposition (to compare floating point numbers) it's totally relevant to understand how that operation can be correctly implemented. Of course! But what does that have to do with the commutative law? Many things break the commutative law, starting with division and subtraction: 20 - 10 != 10 - 20 1/2 != 2/1 Most comparison operators other than equality and inequality: (23 42) != (42 23) [...] That's is totally irrelevant in this case. The commutative law is essential to the equality operation. That's fine, but we're not talking about equality, we're talking about *approximately equality* or *almost equal*. Given the simple definition of relative error under discussion, the commutative law does not hold. The mere fact that it does not hold is no big deal. It doesn't hold for many comparison operators. Nor does the transitive law hold, even using absolute epsilon: eps = 0.5 a = 1.1 b = 1.5 c = 1.9 then a ≈ b, and b ≈ c, but a ≉ c. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Short-circuit Logic
On Fri, 31 May 2013 17:09:01 +1000, Chris Angelico wrote: On Fri, May 31, 2013 at 3:13 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: What makes you think that the commutative law is relevant here? Equality should be commutative. If a == b, then b == a. Also, it's generally understood that if a == c and b == c, then a == b, though there are more exceptions to that (especially in loosely-typed languages). Who is talking about equality? Did I just pass through the Looking Glass into Wonderland again? *wink* We're talking about *approximate equality*, which is not the same thing, despite the presence of the word equality in it. It is non-commutative, just like other comparisons like less than and greater than or equal to. Nobody gets their knickers in a twist because the = operator is non- commutative. Approximate equality is not just non-commutative, it's also intransitive. I'm reminded of a story about Ken Iverson, the creator of APL. Iverson was a strong proponent of what he called tolerant equality, and APL defined the = operator as a relative approximate equal, rather than the more familiar exactly-equal operator most programming languages use. In an early talk Ken was explaining the advantages of tolerant comparison. A member of the audience asked incredulously, “Surely you don’t mean that when A=B and B=C, A may not equal C?” Without skipping a beat, Ken replied, “Any carpenter knows that!” and went on to the next question. — Paul Berry The intransitivity of [tolerant] equality is well known in practical situations and can be easily demonstrated by sawing several pieces of wood of equal length. In one case, use the first piece to measure subsequent lengths; in the second case, use the last piece cut to measure the next. Compare the lengths of the two final pieces. — Richard Lathwell, APL Comparison Tolerance, APL76, 1976 See also here: http://www.jsoftware.com/papers/APLEvol.htm (search for fuzz or tolerance. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: How clean/elegant is Python's syntax?
On Thu, 30 May 2013 20:38:40 +0100, MRAB wrote: On 30/05/2013 19:44, Chris Angelico wrote: On Fri, May 31, 2013 at 4:36 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Wed, May 29, 2013 at 8:49 PM, rusi rustompm...@gmail.com wrote: On May 30, 6:14 am, Ma Xiaojun damage3...@gmail.com wrote: What interest me is a one liner: print '\n'.join(['\t'.join(['%d*%d=%d' % (j,i,i*j) for i in range(1,10)]) for j in range(1,10)]) Ha,Ha! The join method is one of the (for me) ugly features of python. You can sweep it under the carpet with a one-line join function and then write clean and pretty code: #joinwith def joinw(l,sep): return sep.join(l) I don't object to changing the join method (one of the more shoe-horned string methods) back into a function, but to my eyes you've got the arguments backward. It should be: def join(sep, iterable): return sep.join(iterable) Trouble is, it makes some sense either way. I often put the larger argument first - for instance, I would write 123412341324*5 rather than the other way around - and in this instance, it hardly seems as clear-cut as you imply. But the function can't be written to take them in either order, because strings are iterable too. (And functions that take args either way around aren't better than those that make a decision.) And additional argument (pun not intended) for putting sep second is that you can give it a default value: def join(iterable, sep=): return sep.join(iterable) I think that is the winning argument. Next question is what should be the default (, or',')? -- Nasrudin walked into a teahouse and declaimed, The moon is more useful than the sun. Why?, he was asked. Because at night we need the light more. -- http://mail.python.org/mailman/listinfo/python-list
Create a file in /etc/ as a non-root user
I am a python novice;request all to kindly bear with me. fd = open('/etc/file','w') fd.write('jpdas') fd.close() The above snippet fails with: Jagannath-MacBook-Pro:~ jpdas$ python testUmask.py Traceback (most recent call last): File testUmask.py, line 3, in module fd = open('/etc/file','w') IOError: [Errno 13] Permission denied: '/etc/file' Any Idea how to create a file in /etc as non-root user?Can i use umask or chmod...confused -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a file in /etc/ as a non-root user
fd = open('/etc/file','w') fd.write('jpdas') fd.close() Hi Bibhu, that is not a Python problem, but a permission one. You should configure the permissions so that you have write access to the folder. However unless you know what you are doing it is discouraged to save your file in the /etc/ folder. I don't know if on Mac the commands are the same, but in Unix systems (that I guess Mac is) you can manage permissions with chmod. -- http://mail.python.org/mailman/listinfo/python-list
Re: Piping processes works with 'shell = True' but not otherwise.
That's because stdin/stdout/stderr take file descriptors or file objects, not path strings. Thanks Chris, how do I set the file descriptor to /dev/null then? -- http://mail.python.org/mailman/listinfo/python-list
Re: Surprising difference between StringIO.StringIO and io.StringIO
30.05.13 23:46, Skip Montanaro написав(ла): Am I missing something about how io.StringIO works? I thought it was a more-or-less drop-in replacement for StringIO.StringIO. io.StringIO was backported from Python 3. It is a text (unicode) stream. cStringIO.StringIO is a binary stream and StringIO.StringIO can be used as binary or unicode stream depending on arguments. Use io.BaseIO as a replacement for StringIO.StringIO/cStringIO.StringIO if you need a binary stream. -- http://mail.python.org/mailman/listinfo/python-list
Finding Relative Maxima in Python3
Hi all, The last few days I've been working on a script to manipulate some scientific data. One thing I would like to be able to do is find relative maxima in a data set. I'm using numpy in python3 (which I think I can't do without because of utf16 encoding of my data source) and a series of np.arrays. When looking around the web and some forums I came across the scipy function argrelextrema, which seemed to do just what I wanted. The problem is that I can't get the function to work, probably because scipy in python3 does not yet support the argrelextrema function. I can however, not find a reference to this really being the problem, and was wondering if someone here could maybe help me out. The code I used is shown below. The function to return the maximum values is called by a different script. Then, when running, it returns an error like the one below the code. Script: import numpy as np import scipy as sp def max_in_array_range(MaxArray, Column, LowBound): ''' Finding the max value an array with a predefined in a certain column and from a threshold index. The complete array is loaded through Max Array. The column is first selected. The, the LowBound is called (the data is only interesting from a certain point onward. ''' TempArray = MaxArray[:, Column] # Creation of Temporary Array to ensure 1D Array and specification of the LowBound in the next line. return sp.argrelextrema(TempArray[LowBound:], np.greater) Error message: Traceback (most recent call last): File MyScript.py, line 15, in module Varrr = FD.max_in_array_range(CalcAndDiffArray, 5 ,MyBound) File /MyPath/Script.py, line 82, in max_in_array_range return sp.argrelmax(TempArray[LowBound:], np.greater) AttributeError: 'module' object has no attribute 'argrelmax' -- http://mail.python.org/mailman/listinfo/python-list
Re: Piping processes works with 'shell = True' but not otherwise.
Luca Cerone wrote: That's because stdin/stdout/stderr take file descriptors or file objects, not path strings. Thanks Chris, how do I set the file descriptor to /dev/null then? For example: with open(os.devnull, wb) as stderr: p = subprocess.Popen(..., stderr=stderr) ... In Python 3.3 and above: p = subprocess.Popen(..., stderr=subprocess.DEVNULL) -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding Relative Maxima in Python3
On May 31, 2013 2:46 AM, Lourens-Jan Ugen lourensjan.u...@gmail.com wrote: Hi all, The last few days I've been working on a script to manipulate some scientific data. One thing I would like to be able to do is find relative maxima in a data set. I'm using numpy in python3 (which I think I can't do without because of utf16 encoding of my data source) and a series of np.arrays. When looking around the web and some forums I came across the scipy function argrelextrema, which seemed to do just what I wanted. The problem is that I can't get the function to work, probably because scipy in python3 does not yet support the argrelextrema function. I can however, not find a reference to this really being the problem, and was wondering if someone here could maybe help me out. The code I used is shown below. The function to return the maximum values is called by a different script. Then, when running, it returns an error like the one below the code. Script: import numpy as np import scipy as sp snip Error message: Traceback (most recent call last): File MyScript.py, line 15, in module Varrr = FD.max_in_array_range(CalcAndDiffArray, 5 ,MyBound) File /MyPath/Script.py, line 82, in max_in_array_range return sp.argrelmax(TempArray[LowBound:], np.greater) AttributeError: 'module' object has no attribute 'argrelmax' The docs would seem to indicate that that function resides in the signal submodule of scipy: http://docs.scipy.org/doc/scipy-dev/reference/generated/scipy.signal.argrelmax.html#scipy.signal.argrelmax Hence, it would be sp.signal.argrelmax() as opposed to just sp.argrelmax() Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Surprising difference between StringIO.StringIO and io.StringIO
Serhiy Storchaka wrote: 30.05.13 23:46, Skip Montanaro написав(ла): Am I missing something about how io.StringIO works? I thought it was a more-or-less drop-in replacement for StringIO.StringIO. io.StringIO was backported from Python 3. It is a text (unicode) stream. cStringIO.StringIO is a binary stream and StringIO.StringIO can be used as binary or unicode stream depending on arguments. Use io.BaseIO as a I think you mean io.BytesIO. replacement for StringIO.StringIO/cStringIO.StringIO if you need a binary stream. -- http://mail.python.org/mailman/listinfo/python-list
Re: How clean/elegant is Python's syntax?
On Fri, May 31, 2013 at 10:08 AM, Alister alister.w...@ntlworld.com wrote: I think that is the winning argument. Next question is what should be the default (, or',')? join, comma_join, whitejoin, linejoin variants, with different defaults? -- Fábio Santos -- http://mail.python.org/mailman/listinfo/python-list
Re: How clean/elegant is Python's syntax?
On May 31, 2:08 pm, Alister alister.w...@ntlworld.com wrote: On Thu, 30 May 2013 20:38:40 +0100, MRAB wrote: And additional argument (pun not intended) for putting sep second is that you can give it a default value: def join(iterable, sep=): return sep.join(iterable) I think that is the winning argument. Yes Next question is what should be the default (, or',')? Hmm... Never thought there was any choice here except . Yes can see the case for each. -- http://mail.python.org/mailman/listinfo/python-list
Re: Surprising difference between StringIO.StringIO and io.StringIO
31.05.13 12:55, Peter Otten написав(ла): Serhiy Storchaka wrote: 30.05.13 23:46, Skip Montanaro написав(ла): Am I missing something about how io.StringIO works? I thought it was a more-or-less drop-in replacement for StringIO.StringIO. io.StringIO was backported from Python 3. It is a text (unicode) stream. cStringIO.StringIO is a binary stream and StringIO.StringIO can be used as binary or unicode stream depending on arguments. Use io.BaseIO as a I think you mean io.BytesIO. Indead, thank you for correction. replacement for StringIO.StringIO/cStringIO.StringIO if you need a binary stream. -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a file in /etc/ as a non-root user
On 05/31/2013 05:27 AM, Luca Cerone wrote: fd = open('/etc/file','w') fd.write('jpdas') fd.close() Hi Bibhu, that is not a Python problem, but a permission one. You should configure the permissions so that you have write access to the folder. However unless you know what you are doing it is discouraged to save your file in the /etc/ folder. I don't know if on Mac the commands are the same, but in Unix systems (that I guess Mac is) you can manage permissions with chmod. That directory is protected from users for a reason. You defeat that and risk the system. Bibhu: for that reason I'd suggest simply telling your users to run your script as root. If they trust you, and it breaks something, at least they know why they were doing it. sudo python riskyscript.py -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Magazine
Hello all, Was busy with work. Finally finished the job of registering the domain name. Will be live soon. The url is http://pythonmagazine.org. Hope we will be live soon. Regards, DRJ. -- http://mail.python.org/mailman/listinfo/python-list
Re: serialize a class to XML and back
On 26.05.2013 22:48, Roy Smith wrote: In article mailman.2197.1369600623.3114.python-l...@python.org, Chris Rebert c...@rebertia.com wrote: On May 23, 2013 3:42 AM, Schneider j...@globe.de wrote: Hi list, how can I serialize a python class to XML? Plus a way to get the class back from the XML? There's pyxser: http://pythonhosted.org/pyxser/ My aim is to store instances of this class in a database. Honestly, I would avoid XML if you can. Consider using JSON (Python includes the `json` module in the std lib) or pickle instead. Compared to XML: The former is more standardized (in the context of serializing objects) and less verbose; the latter is more efficient (if you don't care about cross-language accessibility); both have more convenient APIs. Some other points... If you care about efficiency and want to use json, don't use the one that comes packaged with the standard library. There are lots of third-party json packages (ujson is the one we use) which are significantly faster. Not sure if that's true of the newest python releases, but it was certainly true in 2.6. I think performance can be a problem in future. This question is part of a multi-user rss-reader solution, which I'm going to develop. I want to store the feed entries (+ some additional data) as XML in a database. The advantage of pickle over json is that pickle can serialize many types of objects that json can't. The other side of the coin is that pickle is python-specific, so if you think you'll ever need to read your data from other languages, pickle is right out. -- GLOBE Development GmbH Königsberger Strasse 260 48157 MünsterGLOBE Development GmbH Königsberger Strasse 260 48157 Münster 0251/5205 390 -- http://mail.python.org/mailman/listinfo/python-list
Re: serialize a class to XML and back
On 25.05.2013 07:54, dieter wrote: Schneider j...@globe.de writes: how can I serialize a python class to XML? Plus a way to get the class back from the XML? My aim is to store instances of this class in a database. In case you want to describe the XML data via an XML-schema (e.g. to exchange it with other applications; maybe via WebServices), you may have a look at PyXB. The approach of PyXB may be a bit different from yours: It starts with an XML-schema description and from it generates Python classes corresponding to the types mentioned in the schema. Instances of those classes can then be easily serialized to XML and XML documents corresponding to types defined in the schema can easily be converted into corresponding class instances. It is not too difficult to customize the classes used for a given type - e.g. to give them special methods related to your application. You may want to start with your (arbitrary) Python classes and get their instances serialized into an adequate XML document. This will not work in all cases: some things are very difficult to serialize (maybe even not serializable at all - e.g. locks). I have just small classes containing text (strings) numbers (as ids) and references to other classes of this type. If you plan to use anything already existing, then almost surely, this will impose restrictions of your classes. -- GLOBE Development GmbH Königsberger Strasse 260 48157 MünsterGLOBE Development GmbH Königsberger Strasse 260 48157 Münster 0251/5205 390 -- http://mail.python.org/mailman/listinfo/python-list
Re: How clean/elegant is Python's syntax?
On Fri, 31 May 2013 03:27:52 -0700, rusi wrote: On May 31, 2:08 pm, Alister alister.w...@ntlworld.com wrote: On Thu, 30 May 2013 20:38:40 +0100, MRAB wrote: And additional argument (pun not intended) for putting sep second is that you can give it a default value: def join(iterable, sep=): return sep.join(iterable) I think that is the winning argument. Yes Next question is what should be the default (, or',')? Hmm... Never thought there was any choice here except . Yes can see the case for each. to be fair is probably the most sensible although in my programs most joins are using ',' -- We are governed not by armies and police but by ideas. -- Mona Caird, 1892 -- http://mail.python.org/mailman/listinfo/python-list
Re: Cutting a deck of cards
Why on Earth would you want to? Cutting a deck makes no sense in software. Randomize the deck properly (Google Fisher-Yates) and start dealing. Cutting the deck will not make it any more random, and in fact will probably make it worse depending on how you choose the cutpoint. The purpose of cutting cards is to make it more difficult for human dealers to stack a deck. Simulating it in software makes no more sense than simulating the cigars you smoke while playing. -- http://mail.python.org/mailman/listinfo/python-list
Re: Short-circuit Logic
In article 51a86319$0$29966$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: In an early talk Ken was explaining the advantages of tolerant comparison. A member of the audience asked incredulously, âSurely you donât mean that when A=B and B=C, A may not equal C?â Without skipping a beat, Ken replied, âAny carpenter knows that!â and went on to the next question. â Paul Berry Any any good carpenter also knows it's better to copy than to measure. Let's say I have a door frame and I need to trim a door to fit it exactly. I can do one of two things. First, I could take out my tape measure and measure that the frame is 29 and 11/32 inches wide. Then, carry that tape measure to the door, measure off 29 and 11/32 inches, and make a mark. Or, I could take a handy stick of wood which is 30-something inches long, lay it down at the bottom of the door frame with one end up snug against one side, and make a mark at the other side of the frame. Then carry my stick to the door and keep trimming until it's the same width as the marked section on the stick. Google for story stick. The tape measure is like digital floating point. It introduces all sorts of ways for errors to creep in and people who care about getting doors to properly fit into door frames understand all that. -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a file in /etc/ as a non-root user
On Fri, 31 May 2013 07:11:58 -0400, Dave Angel wrote: On 05/31/2013 05:27 AM, Luca Cerone wrote: fd = open('/etc/file','w') fd.write('jpdas') fd.close() Hi Bibhu, that is not a Python problem, but a permission one. You should configure the permissions so that you have write access to the folder. However unless you know what you are doing it is discouraged to save your file in the /etc/ folder. I don't know if on Mac the commands are the same, but in Unix systems (that I guess Mac is) you can manage permissions with chmod. That directory is protected from users for a reason. You defeat that and risk the system. Bibhu: for that reason I'd suggest simply telling your users to run your script as root. If they trust you, and it breaks something, at least they know why they were doing it. sudo python riskyscript.py Bibhu without wishing to seem rude, the fact that you had to ask this question indicates that you almost certainly should not be writing to this directory. /etc is used to store configuration files for the operating system if you inadvertently corrupt the wrong one then you could kill the system. if you can provide more details regarding what you are actually trying to achieve you may get some better answers will almost certainly save yourself a whole heap of pain -- It is not for me to attempt to fathom the inscrutable workings of Providence. -- The Earl of Birkenhead -- http://mail.python.org/mailman/listinfo/python-list
Re: Fatal Python error
On May 29, 10:05 am, Joshua Landau joshua.landau...@gmail.com wrote: On 29 May 2013 14:02, Dave Angel da...@davea.name wrote: On 05/29/2013 08:45 AM, Oscar Benjamin wrote: Joshua: Avoid doing anything complex inside an exception handler. Unfortunately, Ranger (the file manager in question) wraps a lot of stuff in one big exception handler. Hence there isn't much choice. The original wasn't actually in an infinite recursion, too, but just a recursion over a large directory. Is there a reason that Python 3 can't be made to work like Python 2 and PyPy, and -if not- should it? The catchable fail would be much nicer than just bombing the program. In the meantime the algorithm should just be reworked, but it seems like a larger step than should be needed. If nothing else, the exception frame is huge. I probably would have spotted it except for the indentation problem triggered by html. The top level code following your function didn't have any loops, so it wasn't a problem. Can anyone help Joshua put his gmail into text mode? I've found a new option. As a test, here's a simplified version without the property: def loop(): try: (lambda: None)() except: pass loop() try: loop() except RuntimeError: pass which is pretty much Oscar Benjamin's, but less stupid. If nobody else has, I would recommend you submit a bug at bugs.python.org. -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a file in /etc/ as a non-root user
On Sat, Jun 1, 2013 at 12:02 AM, Alister alister.w...@ntlworld.com wrote: /etc is used to store configuration files for the operating system if you inadvertently corrupt the wrong one then you could kill the system. Expanding on this: http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard The FHS applies to Linux, but you'll find it close to what other Unix-like OSes use too. It's extremely common to *read* config files from directories like /etc, but to require root privileges to edit them. If you need to store data files for some application that runs as your own user, one good place is a dot-file or directory in your home directory - for instance, I have: /home/rosuav/.wine/ /home/rosuav/.bash_history /home/rosuav/.ssh/ /home/rosuav/.SciTE.session and many more. All of these are happily read/written by processes running under the user 'rosuav' (my primary login user). If a different user fires up bash, a different .bash_history will be used. This system works well for users that represent humans. The other type of user is the one that, well, doesn't represent a human :) Figuring out where they can store files is a bit harder. PostgreSQL gets itself a directory somewhere - maybe /opt/postgresql, maybe /var/lib/postgresql - and restricts itself to that. But the directory is created by root and then handed over (chowned) to the other user. Both these options work well; random processes editing stuff in /etc doesn't :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Encodign issue in Python 3.3.1 (once again)
Τη Πέμπτη, 30 Μαΐου 2013 8:28:56 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: Wonder how much less exciting this mailing list would be if he switched to decaf... decaf is like tasting coffee without coffee! Caffeine gives the coffee a nice taste and make me sweaty and panik too if when i struggle to find something :) *ducks for cover* You don't have to hide :) I'am not after you yet! -- http://mail.python.org/mailman/listinfo/python-list
Too many python installations. Should i remove them all and install the latest?
I'am using CentOS v6.4 on my VPS and hence 'yum' install manager and i just tried: Code: root@nikos [~]# which python /usr/bin/python root@nikos [~]# which python3 /root/.local/lib/python2.7/bin/python3 root@nikos [~]# which python3.3 /root/.local/lib/python2.7/bin/python3.3 root@nikos [~]# Why so many pythons in my system. Now in the case of my Python3 installation, it looks like i have two parallel installations of Python3, but i don't. One is almost certainly a symlink to the other and not an actual installation. I'm thinking of: yum remove python yum remove python3 yum remove python3.3 and yum install python3.3.2 from scratch. I'm sceptic about uninstalling python 2.x though. Seems to me as a bad idea because most of the core system utilities are written in Python 2.6+. Yum, for example, is a collection of Python 2.6 programs. If i actually do yum remove python i will see most of my core system get listed in the uninstall dependency list -- which is a Bad Thing. But then again i dont like the idea of having too many Python into my system. What is you opinion? -- http://mail.python.org/mailman/listinfo/python-list
Re: Short-circuit Logic
On 2013-05-30 08:29:41 +, Steven D'Aprano said: On Thu, 30 May 2013 10:22:02 +0300, Jussi Piitulainen wrote: I wonder why floating-point errors are not routinely discussed in terms of ulps (units in last position). ... That is an excellent question! ... I have a module that works with ULPs. I may clean it up and publish it. Would there be interest in seeing it in the standard library? ... I am definitely interested seeing this in the python standard library. But as I continued to read the lines following your proposal and the excellent article from Bruce pointed to by Carlos on this thread, maybe a package on pypi first grounding somewhat the presumably massive discussion thread on python-ideas :-?) All the best, Stefan. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On 31 May 2013 16:28, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: I'am using CentOS v6.4 on my VPS and hence 'yum' install manager and i just tried: Code: root@nikos [~]# which python /usr/bin/python root@nikos [~]# which python3 /root/.local/lib/python2.7/bin/python3 root@nikos [~]# which python3.3 /root/.local/lib/python2.7/bin/python3.3 root@nikos [~]# Why so many pythons in my system. Now in the case of my Python3 installation, it looks like i have two parallel installations of Python3, but i don't. One is almost certainly a symlink to the other and not an actual installation. I'm thinking of: yum remove python yum remove python3 yum remove python3.3 and yum install python3.3.2 from scratch. I'm sceptic about uninstalling python 2.x though. Seems to me as a bad idea because most of the core system utilities are written in Python 2.6+. Yum, for example, is a collection of Python 2.6 programs. If i actually do yum remove python i will see most of my core system get listed in the uninstall dependency list -- which is a Bad Thing. But then again i dont like the idea of having too many Python into my system. What is you opinion? -- http://mail.python.org/mailman/listinfo/python-list Check if python3 and python3.3 aren't the same. Run them and look at the intro lines. -- http://mail.python.org/mailman/listinfo/python-list
Re: How clean/elegant is Python's syntax?
On Thu, May 30, 2013 at 1:38 PM, MRAB pyt...@mrabarnett.plus.com wrote: And additional argument (pun not intended) for putting sep second is that you can give it a default value: def join(iterable, sep=): return sep.join(iterable) One argument against the default is that it is specific to the str type. If you then tried to use join with an iterable of bytes objects and the default sep argument, you would get a TypeError. At least not having the default forces you to be explicit about which string type you're joining. -- http://mail.python.org/mailman/listinfo/python-list
Re: How clean/elegant is Python's syntax?
On Fri, May 31, 2013 at 4:16 AM, Fábio Santos fabiosantos...@gmail.com wrote: On Fri, May 31, 2013 at 10:08 AM, Alister alister.w...@ntlworld.com wrote: I think that is the winning argument. Next question is what should be the default (, or',')? join, comma_join, whitejoin, linejoin variants, with different defaults? The more specific versions should not even have the parameter as an argument that can be supplied. Otherwise you could do: comma_join(words, sep=';') which is just unclear, and there is no reason to allow it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
Τη Παρασκευή, 31 Μαΐου 2013 6:37:06 μ.μ. UTC+3, ο χρήστης Fábio Santos έγραψε: Check if python3 and python3.3 aren't the same. Run them and look at the intro lines. root@nikos [~]# python -V Python 2.6.6 root@nikos [~]# python3 -V Python 3.3.0 root@nikos [~]# python3.3 -V Python 3.3.0 root@nikos [~]# python3 Python 3.3.0 (default, Apr 6 2013, 01:53:31) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux Type help, copyright, credits or license for more information. exit() root@nikos [~]# python3.3 Python 3.3.0 (default, Apr 6 2013, 01:53:31) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux Type help, copyright, credits or license for more information. exit() root@nikos [~]# -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On 05/31/2013 09:20 AM, Νικόλαος Κούρας wrote: Why so many pythons in my system. Now in the case of my Python3 installation, it looks like i have two parallel installations of Python3, but i don't. One is almost certainly a symlink to the other and not an actual installation. Well is it a symlink? I'm thinking of: yum remove python yum remove python3 yum remove python3.3 What a fantastic way to completely break your os! Python 2 is is a deep dependency of CentOS. You cannot remove it. Python3 and 3.3 can be removed of course. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On Fri, May 31, 2013 at 9:41 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Τη Παρασκευή, 31 Μαΐου 2013 6:37:06 μ.μ. UTC+3, ο χρήστης Fábio Santos έγραψε: Check if python3 and python3.3 aren't the same. Run them and look at the intro lines. root@nikos [~]# python -V Python 2.6.6 root@nikos [~]# python3 -V Python 3.3.0 root@nikos [~]# python3.3 -V Python 3.3.0 So it looks like you have two Python installations, one for Python 2 and one for Python 3. Why is that too many? -- http://mail.python.org/mailman/listinfo/python-list
Re: sendmail smtplib.SMTP('localhost') Where is the email?
Your responses helped. The mailg for linux gave me information I didn't expect. regards, jol On Friday, May 31, 2013 08:55:12 AM Cameron Simpson wrote: On 30May2013 15:48, inq1ltd inq1...@inqvista.com wrote: | python help, Please do not make new discussions by replying to an old discussion. It is not enough to change the subject line; unless you also remove any References: and In-Reply-To: header lines your message is still considered part of the old discussion. | I've tried this code which I got from: | http://www.tutorialspoint.com/python/python_sending_email.htm | | I build this file and run it [...] |smtpObj = smtplib.SMTP('localhost') |smtpObj.sendmail(sender, receivers, message) |print Successfully sent email [...] | After running the the file and I get | Successfully sent email | | My question is why doesn't webmaster get an email? Well, this suggests that the message has been accepted by the mail system on localhost. Not that final delivery was made anywhere else. You now have to read the log files on your mail system to see what happened. One easy check to do first is to see if it is still in your mail system but undelivered. On a UNIX system running the command: mailq should tell you that. If the queue is empty, the message has been sent somewhere and you must dig through the logs to find out where. If the message is in the queue then the mailq command will probably give a suggestion as to why. Cheers,-- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
Τη Παρασκευή, 31 Μαΐου 2013 6:55:03 μ.μ. UTC+3, ο χρήστης Michael Torrie έγραψε: On 05/31/2013 09:20 AM, Νικόλαος Κούρας wrote: Why so many pythons in my system. Now in the case of my Python3 installation, it looks like i have two parallel installations of Python3, but i don't. One is almost certainly a symlink to the other and not an actual installation. Well is it a symlink? I'm thinking of: yum remove python yum remove python3 yum remove python3.3 What a fantastic way to completely break your os! Python 2 is is a deep dependency of CentOS. You cannot remove it. Python3 and 3.3 can be removed of course. root@nikos [~]# ls -al /usr/bin/python* -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python* lrwxrwxrwx 1 root root6 Apr 5 20:34 /usr/bin/python2 - python* -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python2.6* -rwxr-xr-x 1 root root 1418 Feb 22 02:00 /usr/bin/python2.6-config* lrwxrwxrwx 1 root root 24 Apr 7 22:10 /usr/bin/python3 - /opt/python3/bin/python3* lrwxrwxrwx 1 root root 16 Apr 5 20:35 /usr/bin/python-config - python2.6-config* root@nikos [~]# so, i should just 'yum remove python3' ? root@nikos [~]# python3 -V Python 3.3.0 root@nikos [~]# python3.3 -V Python 3.3.0 whre is that 3.3 anyway that which presents? -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
root@nikos [~]# yum remove python3 Loaded plugins: fastestmirror Setting up Remove Process No Match for argument: python3 Loading mirror speeds from cached hostfile * base: ftp.plusline.de * extras: ftp.plusline.de * updates: ftp.plusline.de base | 3.7 kB 00:00 extras | 3.5 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 2.6 MB 00:00 vz-base | 951 B 00:00 vz-updates | 951 B 00:00 No Packages marked for removal root@nikos [~]# yum remove python3.3 Loaded plugins: fastestmirror Setting up Remove Process No Match for argument: python3.3 Loading mirror speeds from cached hostfile * base: ftp.plusline.de * extras: ftp.plusline.de * updates: ftp.plusline.de No Packages marked for removal root@nikos [~]# i don'y understand, why didnt it removed it neither of ways? -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
root@nikos [~]# which python /usr/bin/python root@nikos [~]# which python2 /usr/bin/python2 root@nikos [~]# which python3 /root/.local/lib/python2.7/bin/python3 root@nikos [~]# which python3.3 /root/.local/lib/python2.7/bin/python3.3 root@nikos [~]# So i have 2.6 2.7 3 3.3 4 installations? -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On Fri, 31 May 2013 08:20:54 -0700, Νικόλαος Κούρας wrote: I'am using CentOS v6.4 on my VPS and hence 'yum' install manager and i just tried: Code: root@nikos [~]# which python /usr/bin/python root@nikos [~]# which python3 /root/.local/lib/python2.7/bin/python3 root@nikos [~]# which python3.3 /root/.local/lib/python2.7/bin/python3.3 root@nikos [~]# Why so many pythons in my system. Now in the case of my Python3 installation, it looks like i have two parallel installations of Python3, but i don't. One is almost certainly a symlink to the other and not an actual installation. I'm thinking of: yum remove python yum remove python3 yum remove python3.3 and yum install python3.3.2 from scratch. I'm sceptic about uninstalling python 2.x though. Seems to me as a bad idea because most of the core system utilities are written in Python 2.6+. Yum, for example, is a collection of Python 2.6 programs. If i actually do yum remove python i will see most of my core system get listed in the uninstall dependency list -- which is a Bad Thing. But then again i dont like the idea of having too many Python into my system. What is you opinion? Do not Yum Remove Python as you suggest this will remove vital system tools. I have both Python 2.7 python3 (Python 3.3) on my Fedora system with no problems so i would not worry -- No question is so difficult as one to which the answer is obvious. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On Fri, May 31, 2013 at 11:10 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: root@nikos [~]# ls -al /usr/bin/python* -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python* lrwxrwxrwx 1 root root6 Apr 5 20:34 /usr/bin/python2 - python* -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python2.6* -rwxr-xr-x 1 root root 1418 Feb 22 02:00 /usr/bin/python2.6-config* lrwxrwxrwx 1 root root 24 Apr 7 22:10 /usr/bin/python3 - /opt/python3/bin/python3* lrwxrwxrwx 1 root root 16 Apr 5 20:35 /usr/bin/python-config - python2.6-config* root@nikos [~]# so, i should just 'yum remove python3' ? If you're not using it, and if yum isn't going to remove anything else that has it as a dependency, then go ahead. On the other hand, there's really not much harm in leaving it. Python 2.6 is already your default Python. Is this the same system where you recently spent a lot of time upgrading your web scripts to Python 3? -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On Fri, May 31, 2013 at 11:16 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: root@nikos [~]# which python /usr/bin/python root@nikos [~]# which python2 /usr/bin/python2 root@nikos [~]# which python3 /root/.local/lib/python2.7/bin/python3 root@nikos [~]# which python3.3 /root/.local/lib/python2.7/bin/python3.3 root@nikos [~]# So i have 2.6 2.7 3 3.3 4 installations? Oh, I see. The python3 and python3.3 are probably the same binary, though. In any case, since Python 2.7 and Python 3 are both installed under /root/.local, it looks like you didn't install them using yum in the first place. You probably installed them from source. If that's the case, you can probably just rm -rf the python2.7 folder from each of the /root/.local subfolders that has it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
Τη Παρασκευή, 31 Μαΐου 2013 8:24:26 μ.μ. UTC+3, ο χρήστης Ian έγραψε: On the other hand, there's really not much harm in leaving it. Python 2.6 is already your default Python. Is this the same system where you recently spent a lot of time upgrading your web scripts to Python 3? Yes, its the same system but it reports python 4 times. I just hate seeing this: root@nikos [~]# which python /usr/bin/python root@nikos [~]# which python2 /usr/bin/python2 root@nikos [~]# which python3 /root/.local/lib/python2.7/bin/python3 root@nikos [~]# which python3.3 /root/.local/lib/python2.7/bin/python3.3 root@nikos [~]# and this too: root@nikos [~]# ls -al /usr/bin/python* -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python* lrwxrwxrwx 1 root root6 Apr 5 20:34 /usr/bin/python2 - python* -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python2.6* -rwxr-xr-x 1 root root 1418 Feb 22 02:00 /usr/bin/python2.6-config* lrwxrwxrwx 1 root root 24 Apr 7 22:10 /usr/bin/python3 - /opt/python3/bin/python3* lrwxrwxrwx 1 root root 16 Apr 5 20:35 /usr/bin/python-config - python2.6-config* root@nikos [~]# How can i fix this please. i just want to leave 2.7 and downlaod 3.3.2 could you please tell me what commands i should issue? -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
OMG i gave by mistake root@nikos [/]# rm -rf /root/.local/ did i screwed up my remote VPS which i host 10 peoples webpages? -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On Fri, May 31, 2013 at 11:42 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: OMG i gave by mistake root@nikos [/]# rm -rf /root/.local/ did i screwed up my remote VPS which i host 10 peoples webpages? I don't know, is that where you were keeping the data? The website still appears to be working, as best I can tell from this computer. I've never actually been able to view it from here, because I get a UnicodeDecodeError at this line: host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] But at least I'm still seeing that error, so the server is still responding to requests. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
Τη Παρασκευή, 31 Μαΐου 2013 8:55:51 μ.μ. UTC+3, ο χρήστης Ian έγραψε: On Fri, May 31, 2013 at 11:42 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: OMG i gave by mistake root@nikos [/]# rm -rf /root/.local/ did i screwed up my remote VPS which i host 10 peoples webpages? I don't know, is that where you were keeping the data? The website still appears to be working, as best I can tell from this computer. I've never actually been able to view it from here, because I get a UnicodeDecodeError at this line: host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] But at least I'm still seeing that error, so the server is still responding to requests. Everything seem to be workign as expected, my webiste and the other 10 client websites just chhecked. luckily i keep my stuff at /homw/nikos so there are untouched. i hope i havent deleted anything though system need form /root/.local but i guess this is where root's user personal stuff and instalation of python from source where. i ddidnt know if it has soemhtign else. root@nikos [/]# which python /usr/bin/python root@nikos [/]# which python3 /root/.local/lib/python2.7/bin/python3 root@nikos [/]# which python3.3 /usr/local/bin/python3.3 root@nikos [/]# ls -l /usr/bin/py pydoc pygettext.py pythonpython2.6 python3 pyflakes pynchepython2 python2.6-config python-config root@nikos [/]# ls -l /usr/bin/python* -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python* lrwxrwxrwx 1 root root6 Apr 5 20:34 /usr/bin/python2 - python* -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python2.6* -rwxr-xr-x 1 root root 1418 Feb 22 02:00 /usr/bin/python2.6-config* lrwxrwxrwx 1 root root 24 Apr 7 22:10 /usr/bin/python3 - /opt/python3/bin/python3* lrwxrwxrwx 1 root root 16 Apr 5 20:35 /usr/bin/python-config - python2.6-config* root@nikos [/]# please tell me how to unistall python 2.6 and just keep 2.7 and install 3.3.2 please uisng yum. yum install python3 doesnt work for me. -- http://mail.python.org/mailman/listinfo/python-list
Re: How clean/elegant is Python's syntax?
On Sat, Jun 1, 2013 at 1:43 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Thu, May 30, 2013 at 1:38 PM, MRAB pyt...@mrabarnett.plus.com wrote: And additional argument (pun not intended) for putting sep second is that you can give it a default value: def join(iterable, sep=): return sep.join(iterable) One argument against the default is that it is specific to the str type. If you then tried to use join with an iterable of bytes objects and the default sep argument, you would get a TypeError. At least not having the default forces you to be explicit about which string type you're joining. What about: def join(iterable, sep=None): if sep is not None: return sep.join(iterable) iterable=iter(iterable) first = next(iterable) return first + type(first)().join(iterable) Granted, it has some odd error messages if you pass it stuff that isn't strings: join([[1,2,3],[4,5,6]]) Traceback (most recent call last): File pyshell#241, line 1, in module join([[1,2,3],[4,5,6]]) File pyshell#235, line 5, in join return first + type(first)().join(iterable) AttributeError: 'list' object has no attribute 'join' but you'd get that sort of thing anyway. (NOTE: I am *not* advocating this. I just see it as a solution to one particular objection.) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Cutting a deck of cards
Why on Earth would you want to? Cutting a deck makes no sense in software. Randomize the deck properly (Google Fisher-Yates) and start dealing. Cutting the deck will not make it any more random, and in fact will probably make it worse depending on how you choose the cutpoint. The purpose of cutting cards is to make it more difficult for human dealers to stack a deck. Simulating it in software makes no more sense than simulating the cigars you smoke while playing. Perhaps the OP wanted to study the efficiency and affect of a real-world shuffling algorithm :-p Maybe he was designing a probabilistic magic trick and needed to evaluate how a cut would modify the outcome of a particular stack. Maybe it was a school assignment. Who knows? (But yeah if the purpose was for pure randomization then there's no real point.) There could be a lot of legitimate reasons though. -Modulok- -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Begin Web Development with Python ?
I have learnt python and used it for various purposes for scietific computing using sage and GUI development using Tkinter and lots more. I want to start web development using python My goal is to learn the web development in python from the basic level and understand the big web development projects like Django , MoinMoin Wiki , Plone and network programming further with twisted. I have found Web2Py to be an easy library to quickly use and develop the web application. Is there any other library to start my development with. and does my plan of learning Web2Py is good for Web development and getting involved in the big projects like Django , MoinMoin Wiki , Plone. Each web framework is kind of its own niche. I wouldn't learn one for the purpose of learning another. For example to use Django effectively requires knowledge specific to Django. Aside from some casual similarities between various web frameworks they're all pretty different. If you feel comfortable with web2Py and it does what you need - use the heck out of it! I've heard good things about Web2Py but not used it myself. I used Django for a while but found it to usually be over complicated for most of my needs. In other areas it wasn't advanced enough. (For instance I had an unusual requirement once for composite foreign key support, something Django's ORM couldn't handle at the time. I also disliked the template language. By the time I replaced the ORM and the template language the only thing I was really using was the URL routing so I jumped ship. (Don't get me wrong, I know people who love Django - just not me.) Cherrypy is neat but I found it to be more spartan than I prefer. I've since settled on Flask with SQLAlchemy and am liking it very much. It's a nice middle ground. It also has extensive documentation and example files too. Of course it really helped that I already knew SQLAlchemy, thus pairing it with Flask was cake. While not a web framework, learning SQLAlchemy is useful in its own right because it can be used in a wide variety of projects and is used by some web frameworks. It's also an excellent package that lets you use most of the features of your specific database backend. For web apps staying abstract is usually a good idea, but honestly how often do you change SQL backends? I think I've done it once in my career. I've found the advantage of using database specific features generally outweighs the drawbacks. This is especially true if you have more than one client/website accessing the same database. SQLAlchemy gets me the best of both worlds. I can define check constraints and enumerations and all the other goodies and have them match between database clients. If you don't already know this from scientific computing, learning some raw SQL is quite useful too! Sometimes you need a non-trivial query. -Modulok- -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On 31 May 2013 19:09, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: On Fri, May 31, 2013 at 11:42 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: OMG i gave by mistake root@nikos [/]# rm -rf /root/.local/ did i screwed up my remote VPS which i host 10 peoples webpages? Couldn't you check ten websites which are your responsibility, instead of asking this list? Everything seem to be workign as expected, my webiste and the other 10 client websites just chhecked. Good. please tell me how to unistall python 2.6 and just keep 2.7 and install 3.3.2 please uisng yum. yum install python3 doesnt work for me. No. Wait. Why are you uninstalling python 2.6? Because you have too many python installations? If you're on a production server with client data, should you really have a root shell? -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On 01/06/2013, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Why so many pythons in my system. Explained below, underneath each pertinent info you provided. First, let's discuss Python 2.6: On 01/06/2013, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: I'am using CentOS v6.4 on my VPS and hence 'yum' install manager and i just tried: Code: root@nikos [~]# which python /usr/bin/python This is the version of that CentOS 6 is using. It is Python 2.6 as shown in the next paragraph. This version is essential to CentOS 6. This cannot be changed or upgraded without so much work that no sane person on the planet would bother. Stop worrying about it. On 01/06/2013, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: root@nikos [~]# python -V Python 2.6.6 See above. On 01/06/2013, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: root@nikos [/]# ls -l /usr/bin/python* -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python* lrwxrwxrwx 1 root root6 Apr 5 20:34 /usr/bin/python2 - python* -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python2.6* -rwxr-xr-x 1 root root 1418 Feb 22 02:00 /usr/bin/python2.6-config* [... python3 line removed for clarity ...] lrwxrwxrwx 1 root root 16 Apr 5 20:35 /usr/bin/python-config - python2.6-config* Apart from the bizarre trailing '*' characters which for which I have no sane explanation, all of the above is standard for Python 2.6 which is essential for Centos 6. Stop worrying about it. Now let's talk about yum: On 01/06/2013, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: root@nikos [~]# yum remove python3 [...] No Match for argument: python3 [...] root@nikos [~]# yum remove python3.3 [...] No Match for argument: python3.3 i don'y understand, why didnt it removed it neither of ways? Your yum setup does not find python3 or python3.3 packages. So you could not have used yum to install it. Therefore, you cannot use yum to remove it. And, you cannot use yum to install it. Now let's talk about Python 2.7: On 01/06/2013, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: root@nikos [~]# which python3 /root/.local/lib/python2.7/bin/python3 There's a python2.7 directory there under /root/.local. Maybe you installed python2.7 from source using some kind of 'make install' command (ie not using yum)? If so, and you wish to remove it, there will probably be another 'make' command to remove it, which must be run from the same directory that you ran 'make install'. Try 'make help' in that directory. Maybe someone else can explain why there is a python3 command under that directory, because I can't. Now let's talk about Python 3: On 01/06/2013, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: root@nikos [~]# ls -al /usr/bin/python* [...] lrwxrwxrwx 1 root root 24 Apr 7 22:10 /usr/bin/python3 - /opt/python3/bin/python3* There's a python3 directory there under /opt. Maybe you installed python3 from source using some kind of 'make install' command (ie not using yum)? If so, and you wish to remove it, there will probably be another 'make' command to remove it, which must be run from the same directory that you ran 'make install'. Try 'make help' in that directory. On 01/06/2013, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: OMG i gave by mistake root@nikos [/]# rm -rf /root/.local/ did i screwed up my remote VPS which i host 10 peoples webpages? When trying something you don't fully understand, first experiment somewhere you don't care if bad things happen. On 01/06/2013, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Should i remove them all and install the latest? No. Different versions do different things. Don't install or remove them until you understand the different things they do. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
Indeed i have comiled python 2.7 and 3.3 form source after wget and ./configure an make install but i belive somehting is mixed up althouh python works ok. root@nikos [/opt/python3/bin]# ls -al total 15180 drwxr-xr-x 2 root root4096 Apr 7 22:09 ./ drwxr-xr-x 6 root root4096 Apr 7 22:09 ../ lrwxrwxrwx 1 root root 8 Apr 7 22:09 2to3 - 2to3-3.3* -rwxr-xr-x 1 root root 103 Apr 7 22:09 2to3-3.3* lrwxrwxrwx 1 root root 7 Apr 7 22:09 idle3 - idle3.3* -rwxr-xr-x 1 root root 101 Apr 7 22:09 idle3.3* lrwxrwxrwx 1 root root 8 Apr 7 22:09 pydoc3 - pydoc3.3* -rwxr-xr-x 1 root root 86 Apr 7 22:09 pydoc3.3* lrwxrwxrwx 1 root root 9 Apr 7 22:09 python3 - python3.3* -rwxr-xr-x 2 root root 7757695 Apr 7 22:09 python3.3* lrwxrwxrwx 1 root root 17 Apr 7 22:09 python3.3-config - python3.3m-config* -rwxr-xr-x 2 root root 7757695 Apr 7 22:09 python3.3m* -rwxr-xr-x 1 root root1980 Apr 7 22:09 python3.3m-config* lrwxrwxrwx 1 root root 16 Apr 7 22:09 python3-config - python3.3-config* lrwxrwxrwx 1 root root 10 Apr 7 22:09 pyvenv - pyvenv-3.3* -rwxr-xr-x 1 root root 238 Apr 7 22:09 pyvenv-3.3* root@nikos [/opt/python3/bin]# make help make: *** No rule to make target `help'. Stop. root@nikos [/opt/python3/bin]# cant remove it. Why you say i cant just yum install python3.3.2 that way it would be installed correcttly automaticall by yum manager and if later i want to remove ot to install 3.3.3 or a later version i would have to do yum remove python3.3.2 but yum cant seem to find any python packages to install. Still i feel my system is a bit messed p and i just want to leave the 2.6 installed and remove all the rest python and then yum install the_latest_one. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On Sat, Jun 1, 2013 at 9:30 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Still i feel my system is a bit messed p and i just want to leave the 2.6 installed and remove all the rest python and then yum install the_latest_one. It's not half as messed up as... uhh, scratch that. It's not half as messed up as the testbox I have at work. (Yeah, we'll go with that. More courteous.) You do not have a problem there that is worth breaking your system for. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On Sat, Jun 1, 2013 at 8:50 AM, David bouncingc...@gmail.com wrote: On 01/06/2013, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: root@nikos [/]# ls -l /usr/bin/python* -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python* lrwxrwxrwx 1 root root6 Apr 5 20:34 /usr/bin/python2 - python* -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python2.6* -rwxr-xr-x 1 root root 1418 Feb 22 02:00 /usr/bin/python2.6-config* [... python3 line removed for clarity ...] lrwxrwxrwx 1 root root 16 Apr 5 20:35 /usr/bin/python-config - python2.6-config* Apart from the bizarre trailing '*' characters which for which I have no sane explanation... I believe that indicates that his 'ls' is aliased to 'ls --classify', which puts * after executables (and / after directories, and @ after symlinks, also a few others). Not a problem. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this code correct?
On 30May2013 06:45, Nikos as SuperHost Support supp...@superhost.gr wrote: | Τη Πέμπτη, 30 Μαΐου 2013 4:36:11 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: | Lemme guess, he's next going to ask on the PostgreSQL mailing list. I | mean, that's unrelated to Python, right? | | Well Chris, i'am not that stupid :) | | I intend to ask questions unrelated to Python to a list unrelated to Python but related to my subject, whish is 'suexec', that would mean a linux list. Actually, you need an apache httpd list for suexec. It is part of the web server CGI implementation. -- Cameron Simpson c...@zip.com.au -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On Fri, May 31, 2013 at 5:30 PM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Indeed i have comiled python 2.7 and 3.3 form source after wget and ./configure an make install but i belive somehting is mixed up althouh python works ok. root@nikos [/opt/python3/bin]# ls -al ... root@nikos [/opt/python3/bin]# make help make: *** No rule to make target `help'. Stop. root@nikos [/opt/python3/bin]# cant remove it. The Makefile would be located in the source directory where you built Python, not in the installation directory. But in any case, I don't think the Python Makefile includes an uninstall option. If you want to uninstall Python that was built from source, you need to remove the files by hand. Why you say i cant just yum install python3.3.2 Because CentOS 6 evidently does not provide a package for any version of Python other than 2.6. If you want to install another version, you will need to do it from source. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
Τη Σάββατο, 1 Ιουνίου 2013 2:55:38 π.μ. UTC+3, ο χρήστης Ian έγραψε: On Fri, May 31, 2013 at 5:30 PM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Indeed i have comiled python 2.7 and 3.3 form source after wget and ./configure an make install but i belive somehting is mixed up althouh python works ok. root@nikos [/opt/python3/bin]# ls -al ... root@nikos [/opt/python3/bin]# make help make: *** No rule to make target `help'. Stop. root@nikos [/opt/python3/bin]# cant remove it. The Makefile would be located in the source directory where you built Python, not in the installation directory. But in any case, I don't think the Python Makefile includes an uninstall option. If you want to uninstall Python that was built from source, you need to remove the files by hand. Why you say i cant just yum install python3.3.2 Because CentOS 6 evidently does not provide a package for any version of Python other than 2.6. If you want to install another version, you will need to do it from source. Do you think that i should have my VPS copmany to install ubuntu for me and use apt-get install python3 ? I think ubuntu is friendlier. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On 01/06/2013, Chris Angelico ros...@gmail.com wrote: On Sat, Jun 1, 2013 at 8:50 AM, David bouncingc...@gmail.com wrote: Apart from the bizarre trailing '*' characters which for which I have no sane explanation... I believe that indicates that his 'ls' is aliased to 'ls --classify', which puts * after executables (and / after directories, and @ after symlinks, also a few others). Not a problem. Ah, old skool. I have seen that before now that you mention it. Thanks for the correction. I knew I didn't have all the answers, but felt that I'd try some pig wrestling anyway. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On Sat, Jun 1, 2013 at 10:08 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Τη Σάββατο, 1 Ιουνίου 2013 2:55:38 π.μ. UTC+3, ο χρήστης Ian έγραψε: [ snip lots of double-spaced quoted text ] Do you think that i should have my VPS copmany to install ubuntu for me and use apt-get install python3 ? I think ubuntu is friendlier. Probably friendlier than humans will be, considering that Ubuntu doesn't complain about careless use of Google Groups. Why not try making your own administrative decisions, rather than expecting other people to validate you? Are you that short on confidence that you need someone to say Yes yes, you're doing the right thing and pat you on the back? ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On Sat, Jun 1, 2013 at 10:18 AM, David bouncingc...@gmail.com wrote: On 01/06/2013, Chris Angelico ros...@gmail.com wrote: On Sat, Jun 1, 2013 at 8:50 AM, David bouncingc...@gmail.com wrote: Apart from the bizarre trailing '*' characters which for which I have no sane explanation... I believe that indicates that his 'ls' is aliased to 'ls --classify', which puts * after executables (and / after directories, and @ after symlinks, also a few others). Not a problem. Ah, old skool. I have seen that before now that you mention it. Thanks for the correction. I knew I didn't have all the answers, but felt that I'd try some pig wrestling anyway. Yeah. I know that particular one because I have l aliased to ls -CF (aka --columns --classify), mainly because it came that way as a commented-out entry in my first Debian. Have since become quite accustomed to it; to me, 'l' means 'look' (I do love my MUDs), so I'm considering aliasing 'gl' to 'pwd' so that I can 'glance' too :) Hmm. What other MUD commands have obvious Unix equivalents? say -- echo emote -- python -c attack -- sudo rm -f ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a file in /etc/ as a non-root user
On Fri, 31 May 2013 02:12:58 -0700, BIBHU DAS wrote: I am a python novice;request all to kindly bear with me. fd = open('/etc/file','w') fd.write('jpdas') fd.close() The above snippet fails with: IOError: [Errno 13] Permission denied: '/etc/file' As it should. Any Idea how to create a file in /etc as non-root user? This should not be possible. The language used is irrelevant. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On 01/06/2013 01:18, David wrote: I knew I didn't have all the answers, but felt that I'd try some pig wrestling anyway. To carry on with the animal analogy, the OP appears to me a very dangerous combination of headless chicken and bull in a china shop. -- Steve is going for the pink ball - and for those of you who are watching in black and white, the pink is next to the green. Snooker commentator 'Whispering' Ted Lowe. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a file in /etc/ as a non-root user
On 2013-06-01 01:20, Nobody wrote: On Fri, 31 May 2013 02:12:58 -0700, BIBHU DAS wrote: Any Idea how to create a file in /etc as non-root user? This should not be possible. The language used is irrelevant. It's theoretically possible to pre-create the file (or a subdirectory) in /etc as root, then chown it to have a group for which certain users can be members. Something like $ su - # or sudo sh # addgroup bibhusers # mkdir /etc/bibhu # chown :bibhusers /etc/bibhu # chmod g+rwx /etc/bibhu # for user in bibhu tim guido; do adduser $user bibhusers ; done # exit $ logout Upon next login, the users listed in the for user in ... command should have write access to the directory created in /etc Not that this would generally be considered a good idea, but if you wanted to have a global configuration and wanted select users (as members of a defined group) to have the ability to tweak this global configuration, this is how it would be done. Otherwise, it's generally advisable to just have one admin maintain the global configuration file and then give users a local (in $HOME/.config/$APPNAME/filename.ext) configuration file to override those global settings. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On 05/31/2013 12:02 PM, Νικόλαος Κούρας wrote: please tell me how to unistall python 2.6 and just keep 2.7 and install 3.3.2 please uisng yum. Python 2.6 is required for CentOS to function. You simply cannot remove it. You can't replace it with 2.7 either. You can install 2.7 alongside it if you want (seems like you have). -- http://mail.python.org/mailman/listinfo/python-list
netcdF4 variables
Dear members, I have been using python NetcdF for some time. I understand that we can get variables from a netcdf one by one by using temp=ncf.variable['temp'][:] but is there a way to get a list of variables with out the rest of the stuff as seen below? some hing like a list xx=nc,variables[:] should get me all variable names with out other surrounding stuff?? with best regards. Sudheer In [4]: ncf.variables Out[4]: OrderedDict([(u'LON', netCDF4.Variable object at 0x254aad0), (u'LAT', netCDF4.Variable object at 0x254ab50), (u'DEPTH1_1', netCDF4.Variable object at 0x254abd0), (u'TAX', netCDF4.Variable object at 0x254ac50), (u'DIF_FD1', netCDF4.Variable object at 0x254acd0), (u'DIF_FD2', netCDF4.Variable object at 0x254ad50), (u'DIF_FD3', netCDF4.Variable object at 0x254add0), (u'DIF_FD4', netCDF4.Variable object at 0x254ae50), (u'DIF_FD5', netCDF4.Variable object at 0x254aed0), (u'DEPTH', netCDF4.Variable object at 0x254af50), (u'DEPTH_bnds', netCDF4.Variable object at 0x261b050), (u'TIME', netCDF4.Variable object at 0x261b0d0), (u'TEMP_BIAS', netCDF4.Variable object at 0x261b150)]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a file in /etc/ as a non-root user
On May 31, 7:42 pm, Chris Angelico ros...@gmail.com wrote: On Sat, Jun 1, 2013 at 12:02 AM, Alister alister.w...@ntlworld.com wrote: /etc is used to store configuration files for the operating system if you inadvertently corrupt the wrong one then you could kill the system. Expanding on this: http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard The FHS applies to Linux, but you'll find it close to what other Unix-like OSes use too. Yes the FHS is a good center for such discussions. Let me expand on this a bit. I am going to use debian/ubuntu+apt because I know it a bit. You can substitute RH/Centos+yum or whatever... Modern linuxes are SOAs (service oriented architectures) or cloud architectures even if we dont like the buzzwords. This means that when I install debian/ubuntu on my personal computer there is some kind of contract-ing that goes on between me and debian. Some of it legal, some semi-legal some entirely informal/ conventional but still very important. Legal: For example it may be 'my very own computer' but if I take sources under a certain license and use them in violation of that license I could get into legal trouble. Semi-legal: Free and not-free software can coexist in ways that are at least legally nebulous Conventional: Debian must not use the machine (and file-system in particular) in ways that disrespect me. Note I am not talking of obvious legal gaffes like stealing my private data but of more 'conventional' problems like strewing my home directory with meaningless temporary files. Likewise: I MUST RESPECT Debian's AREA. For example I cant go messing about in /usr/bin [the name 'usr' is misleading and unfortunate] and expect support from debian. So $ sudo rm /usr/bin/foo is improper whereas $ sudo apt-get purge foo is proper. And its improper because you are not to mess around in debian's area -- except for officially approved channels like 'apt-get purge…' -- just as debian is not to mess around in yours. And writing into /etc constitutes messing with debian (or whatever is your distro). So yes, as Chris suggested read the FHS. And consider using a 'public-messable' area like /usr/local instead of /etc. Actually the situation is more complicated: the deal is not between just ordinary users like you/me and the distro. There's - ordinary users like you/me - packagers - the distro - upstream each with their own rights and responsibilities. What these are and how to navigate them is best discussed in your distro's fora eg http://forums.debian.net/ http://ubuntuforums.org/forum.php -- http://mail.python.org/mailman/listinfo/python-list
Apache and suexec issue that wont let me run my python script
I have asked this in alt.apache.configuration but received no response at all, so i was thinking of you guys as a last resort to this. Sorry about that but koukos.py need to set a cookies that other scripts depend upon for identification. 'python3 koukos.py' runs properly. chown nikos:nikos koukos.py chmod 755 koukos.py are all in place. i want to run a python script 4 days now and i receive this message: [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] suexec failure: could not open log file [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] fopen: Permission denied [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] Premature end of script headers: koukos.py [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] File does not exist: /home/nikos/public_html/500.shtml when i tail -F /usr/local/apache/logs/error_log What this error means? It appears that the effective user of the script does not have permission to open the log file that the suexec call requires. - fopen reported permission denied, presumably on the logfile - suexec, receiving the fopen permission denied error, reported could not open log file These errors, in turn, seem to have prematurely terminated the script headers that i use in koukos.py script, causing the koukos.py script to fail. This caused apache to report (with a generic and inappropriate error message) that the shtml file that invokes the script failed. [code] root@nikos [/home/nikos/www/cgi-bin]# chmod g+w /usr/local/apache/logs/suexec_log root@nikos [/home/nikos/www/cgi-bin]# ls -al /usr/local/apache/logs/suexec_log -rw-rw-r-- 1 root apache 506823 Jun 1 02:55 /usr/local/apache/logs/suexec_log [/code] [code] root@nikos [/home/nikos/www/cgi-bin]# chmod g+w /var/log/httpd/suexec.log root@nikos [/home/nikos/www/cgi-bin]# ls -l /var/log/httpd/suexec.log -rw-rw-r-- 1 root root 0 Jun 1 02:52 /var/log/httpd/suexec.log [/code] and still iam receiving the same error. -- http://mail.python.org/mailman/listinfo/python-list
Re: Apache and suexec issue that wont let me run my python script
On Sat, Jun 1, 2013 at 3:30 PM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: I have asked this in alt.apache.configuration but received no response at all You posted it FIFTEEN HOURS AGO on a low-traffic forum. Sheesh! Learn a little patience. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
Τη Σάββατο, 1 Ιουνίου 2013 3:15:22 π.μ. UTC+3, ο χρήστης Dennis Lee Bieber έγραψε: On Fri, 31 May 2013 08:20:54 -0700 (PDT), �������� ������ nikos.gr...@gmail.com declaimed the following in gmane.comp.python.general: I'am using CentOS v6.4 on my VPS and hence 'yum' install manager and i just tried: Code: root@nikos [~]# which python /usr/bin/python root@nikos [~]# which python3 /root/.local/lib/python2.7/bin/python3 root@nikos [~]# which python3.3 /root/.local/lib/python2.7/bin/python3.3 root@nikos [~]# I'd be concerned that those 3/3.3 entries are showing up in a 2.7 installation directory! Other than that, I'd see if some of those of softlinks (or even hardlinks) to another... That is: /usr/bin/python maybe links to your python3.3, and your python3 also links to the python3.3 -- meaning you really only have one Python in the 3.x branch (you didn't check for 2.x) -- Wulfraed Dennis Lee Bieber AF6VN wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ Thats exactly my thoughts. Can you please tell me HOW TO GET RID OF ALL PYTHON SETUPS except 2.6 that is needed for system core and then just install 3.3.2? also why cant i install 3.3.2 using yum. if i could instead of building from source then i wouldn't have this installed mess but i could simply yum remove python* -- http://mail.python.org/mailman/listinfo/python-list
[issue18078] threading.Condition to allow notify on a specific waiter
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18078 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18105] ElementTree writes invalid files when UTF-16 encoding is specified
New submission from Adam Urban: import xml.etree.ElementTree as ET tree = ET.parse(myinput.xml) tree.write(myoutput.xml, encoding=utf-16) ...Output is a garbled mess, often a mix of UTF-8 and UTF-16 bytes... UTF-8 output works fine, but when UTF-16, UTF-16LE, or UTF-16BE are specified the output is mangled. -- components: Unicode, XML messages: 190392 nosy: Adam.Urban, ezio.melotti priority: normal severity: normal status: open title: ElementTree writes invalid files when UTF-16 encoding is specified type: behavior versions: 3rd party, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18105 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12425] gettext breaks on empty plural-forms value
Changes by Bohuslav Slavek Kabrda bkab...@redhat.com: -- nosy: +bkabrda ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12425 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18106] There are unused variables in Lib/test/test_collections.py
New submission from Vajrasky Kok: In two test_copying methods in Lib/test/test_collections.py, variable i is never used. My guess is the original test writer forgot to utilize the variable i. For example, in test_copying method in TestOrderedDict class: def test_copying(self): # Check that ordered dicts are copyable, deepcopyable, picklable, # and have a repr/eval round-trip pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)] od = OrderedDict(pairs) update_test = OrderedDict() update_test.update(od) for i, dup in enumerate([ od.copy(), copy.copy(od), copy.deepcopy(od), pickle.loads(pickle.dumps(od, 0)), pickle.loads(pickle.dumps(od, 1)), pickle.loads(pickle.dumps(od, 2)), pickle.loads(pickle.dumps(od, 3)), pickle.loads(pickle.dumps(od, -1)), eval(repr(od)), update_test, OrderedDict(od), ]): self.assertTrue(dup is not od) self.assertEqual(dup, od) self.assertEqual(list(dup.items()), list(od.items())) self.assertEqual(len(dup), len(od)) self.assertEqual(type(dup), type(od)) The variable i in for i, dup in enumerate is never used. The test_copying method in TestCounter class has the same problem. In my opinion, we need to put variable i inside the message in the assert functions to detect which place inside the iteration the test fails. -- components: Tests files: test_copying.patch keywords: patch messages: 190393 nosy: vajrasky priority: normal severity: normal status: open title: There are unused variables in Lib/test/test_collections.py versions: Python 3.4 Added file: http://bugs.python.org/file30432/test_copying.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18106 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18106] There are unused variables in Lib/test/test_collections.py
Serhiy Storchaka added the comment: Perhaps it will be even better to extract loop body as a local function and then call it with different arguments. def check(dup): self.assertTrue(dup is not od) self.assertEqual(dup, od) ... check(od.copy()) check(copy.copy(od)) ... In this case we will see a tested case right in the traceback. -- nosy: +ezio.melotti, michael.foord, pitrou, serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18106 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18105] ElementTree writes invalid files when UTF-16 encoding is specified
Serhiy Storchaka added the comment: For 3.3+ it was fixed in issue1767933. -- nosy: +eli.bendersky, serhiy.storchaka versions: -3rd party, Python 2.6, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18105 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10224] Build 3.x documentation using python3.x
Cherniavsky Beni added the comment: I was only thinking of 3.4, which will have venv and a pip bootstrapper. Is changing the doc build / doctest in scope for minor releases of 3.3 (or even earlier)? The commands I listed (using setup_distribute.py) also work with 3.3. (But they're unsecure -- https://bitbucket.org/tarek/distribute/issue/374/) 3.2 is harder as it doesn't even have builtin venv. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10224 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18107] 'str(long)' can be made faster
New submission from Armin Rigo: If you have in x some very large number, like 3**20, then the computation for 'str(x)' is sub-efficient. Nathan Hurst posted to the pypy-dev mailing list a pure Python algo that gives the same result in 2/3rd of the time (in either CPython or PyPy). We would get a similar gain by recoding this algorithm in C. The mail is here: http://mail.python.org/pipermail/pypy-dev/2013-May/011433.html -- messages: 190397 nosy: arigo priority: normal severity: normal status: open title: 'str(long)' can be made faster type: performance ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18107 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18107] 'str(long)' can be made faster
Serhiy Storchaka added the comment: See also issue3451. -- nosy: +mark.dickinson, serhiy.storchaka versions: +Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18107 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18106] There are unused variables in Lib/test/test_collections.py
Vajrasky Kok added the comment: According to R. David Murray in Python core-mentorship mailing list addressing me: It could be that the bug is that the i is not used...it may have been intended to be used in an extended error message in the asserts, so that it would be clear which input failed. In any case, I think the best fix here would probably be to use the new subtests support in unittest. So I used subTest feature in the second patch I upload according to his advice. What do you think? subTest can recognize where the test fails immediately as well. You just have to count the line in the loop. -- Added file: http://bugs.python.org/file30433/test_copying_with_subTest.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18106 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18106] There are unused variables in Lib/test/test_collections.py
Vajrasky Kok added the comment: Anyway to make it complete, I upload the patch according to Storchaka's advice too. May the best patch wins! -- Added file: http://bugs.python.org/file30434/test_copying_with_def.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18106 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18039] dbm.open(..., flag=n) does not work and does not give a warning
Berker Peksag added the comment: I can't reproduce it on Windows 7 with Python 3.3.2. Attaching my test script. Here's the output: C:\Python33python.exe -V Python 3.3.2 C:\Python33python.exe dbmopen.py dbm.dumb._Database object at 0x027C15B0 bzdew.dat exists? True bzdew.dir exists? True b'hello' b'there' Could you run it and paste here the output? -- nosy: +berker.peksag stage: - test needed Added file: http://bugs.python.org/file30435/dbmopen.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18039 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue744841] Python-Profiler bug: Bad call
Terje Wiesener added the comment: This bug seems to have resurfaced in newer python versions. I have tested the file attached in the original report (prof2.py) in python 2.6.6 and 2.7 (x86 versions) under Windows 7, and both give the same output: c:\tempc:\Python27\python.exe prof2.py type 'exceptions.ZeroDivisionError' Exception AssertionError: AssertionError('Bad call', ('prof2.py', 19, 'h'), frame object at 0x023880E0, frame object at 0x00586E18, frame object at 0x02388518, frame object at 0x02388248) in bound method C.__del__ of __main__.C instance at 0x02342A80 ignored 5 function calls in 0.007 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 10.0000.0000.0070.007 string:1(module) 10.0010.0010.0010.001 prof2.py:11(g) 10.0060.0060.0070.007 prof2.py:19(h) 10.0000.0000.0000.000 prof2.py:7(f) 10.0000.0000.0070.007 profile:0(h()) 00.000 0.000 profile:0(profiler) -- nosy: +Terje.Wiesener type: - performance versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue744841 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18039] dbm.open(..., flag=n) does not work and does not give a warning
Sashko Kopyl added the comment: Here is the output. *** Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32. *** *** Remote Python engine is active *** *** Remote Interpreter Reinitialized *** dbm.dumb._Database object at 0x02B95210 yoqaA.dat exists? True yoqaA.dir exists? True b'hello' b'there' I would like to focus your attention, that flag n creates a database, but does not overwrite it once it is created. So in Windows case there is no difference between c and n flag. You can have a look at this link where it was originally discussed. http://stackoverflow.com/questions/16647131/how-to-empty-dbm-file-in-python-efficiently -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18039 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18108] shutil.chown should support dir_fd and follow_symlinks keyword arguments
New submission from Colin Watson: Python 3.3 added the dir_fd and follow_symlinks keyword arguments to os.chown; it also added the shutil.chown function. Unfortunately the latter, while useful, does not support these new keyword arguments. It would be helpful if it did. -- components: Library (Lib) messages: 190404 nosy: cjwatson priority: normal severity: normal status: open title: shutil.chown should support dir_fd and follow_symlinks keyword arguments versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18108 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15239] Abandoned Tools/unicode/mkstringprep.py
Martin v. Löwis added the comment: Ok, these patches all look fine. Thanks for your effort. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18107] 'str(long)' can be made faster
Armin Rigo added the comment: Thanks, I missed it. Sorry for the noise. -- resolution: - duplicate status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18107 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3451] Asymptotically faster divmod and str(long)
Eric V. Smith added the comment: See also issue18107, in particular http://mail.python.org/pipermail/pypy-dev/2013-May/011433.html. -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18093] Move main functions to a separate Programs directory
Zachary Ware added the comment: I can confirm that the patch doesn't break building on Windows. Would it make any sense to move Windows-specific sources for things like kill_python.exe (PCbuild/kill_python.c), make_buildinfo.exe, make_versioninfo.exe, py.exe (PC/launcher.c) into Programs? Or better to keep them in PC or PCbuild (at least for now, until after this patch is approved)? -- nosy: +zach.ware ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18093 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18094] Skip tests in test_uuid not silently
Changes by Zachary Ware zachary.w...@gmail.com: -- nosy: +zach.ware ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18103] Create a GUI test framework for Idle
Changes by Todd Rovito rovit...@gmail.com: -- nosy: +Todd.Rovito ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18103 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18104] Idle: make human-mediated GUI tests usable
Changes by Todd Rovito rovit...@gmail.com: -- nosy: +Todd.Rovito ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18104 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18108] shutil.chown should support dir_fd and follow_symlinks keyword arguments
Changes by Hynek Schlawack h...@ox.cx: -- nosy: +hynek versions: +Python 3.4 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18108 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18066] Remove SGI-specific code from pty.py
Éric Araujo added the comment: LGTM. -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18066 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18094] Skip tests in test_uuid not silently
Éric Araujo added the comment: +1 -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18094] Skip tests in test_uuid not silently
Roundup Robot added the comment: New changeset 81c02d2c830d by Serhiy Storchaka in branch '3.3': Issue #18094: test_uuid no more reports skipped tests as passed. http://hg.python.org/cpython/rev/81c02d2c830d New changeset ebd11a19d830 by Serhiy Storchaka in branch 'default': Issue #18094: test_uuid no more reports skipped tests as passed. http://hg.python.org/cpython/rev/ebd11a19d830 New changeset 6ceb5bf24da8 by Serhiy Storchaka in branch '2.7': Issue #18094: test_uuid no more reports skipped tests as passed. http://hg.python.org/cpython/rev/6ceb5bf24da8 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18094] Skip tests in test_uuid not silently
Changes by Serhiy Storchaka storch...@gmail.com: -- assignee: - serhiy.storchaka resolution: - fixed stage: patch review - committed/rejected status: open - closed versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15239] Abandoned Tools/unicode/mkstringprep.py
Serhiy Storchaka added the comment: Thank you for review. Should we regenerate Lib/stringprep.py now? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18109] os.uname() crashes if hostname contains non-ascii characters
New submission from Dominik Richter: To reproduce (tested on Arch Linux, python 3.3.2): sudo hostname hât python -c import os; os.uname() produces: Traceback (most recent call last): File string, line 1, in module UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128) -- components: Unicode messages: 190413 nosy: Dominik.Richter, ezio.melotti priority: normal severity: normal status: open title: os.uname() crashes if hostname contains non-ascii characters type: crash versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18109 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com