Python mange with liste
Hello guys, i need some help with is program I have a txt file test.txt where there is Name;Sexe;Answer(Y or N) example of txt file: -- *nam1;F*;Y nam2;M;N nam3;F;Y nam4;M;N halo;M;Y rock;M;N nam1;F;N _ so my program will ask the name, sexe, and answer and it will tell me if the name exist or not example i will enter nam1;F;O The program must tell me that *nam1 *with sexe *F* existe. (it must take in count the answer) name = raw_input('name: ') sexe = raw_input('sexe: ') r1 = raw_input('r1 Y or N: ') infos = name+;+sexe+;+r1 f=open(test.txt,r) conten = f.read() print conten f.close() #f=open(test.txt,a) #f.write(infos) #f.write('\n') #f.close() thank you =) -- https://mail.python.org/mailman/listinfo/python-list
RE: Unit tests and coverage
As the script is being invoked with Popen, I lose that luxury and only gain the assertions tests but that of course doesn't show me untested branches. Should have read the docs more thoroughly, works quite nice. jlc -- https://mail.python.org/mailman/listinfo/python-list
Re: Python mange with liste
Bala Ji bala...@gmail.com writes: Hello guys, i need some help with is program I have a txt file test.txt where there is Name;Sexe;Answer(Y or N) example of txt file: -- nam1;F;Y nam2;M;N nam3;F;Y nam4;M;N halo;M;Y rock;M;N nam1;F;N _ so my program will ask the name, sexe, and answer and it will tell me if the name exist or not example i will enter nam1;F;O What does the O mean here? The program must tell me that nam1 with sexe F existe. (it must take in count the answer) name = raw_input('name: ') sexe = raw_input('sexe: ') r1 = raw_input('r1 Y or N: ') infos = name+;+sexe+;+r1 f=open(test.txt,r) conten = f.read() print conten f.close() #f=open(test.txt,a) #f.write(infos) #f.write('\n') #f.close() thank you =) -- Piet van Oostrum p...@vanoostrum.org WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Python mange with liste
hello, thank you for your help i wrote this: x=nam1 y=F names = [(nam1, F, Y), (nam2, M, N)] l = len(names) for i in range(0,l): print names[i][0] print names[i][1] if x == names[i][0] and y == names[i][1]: message = right else: message = wrong print message normally it must tell me right but it tells me wrong best -- https://mail.python.org/mailman/listinfo/python-list
Re: Python mange with liste
Oh sorry it's a Y (in french it's O) sorry for the mistake Le dimanche 29 décembre 2013 00:30:23 UTC+1, Bala Ji a écrit : Hello guys, i need some help with is program I have a txt file test.txt where there is Name;Sexe;Answer(Y or N) example of txt file: -- nam1;F;Y nam2;M;N nam3;F;Y nam4;M;N halo;M;Y rock;M;N nam1;F;N _ so my program will ask the name, sexe, and answer and it will tell me if the name exist or not example i will enter nam1;F;O The program must tell me that nam1 with sexe F existe. (it must take in count the answer) name = raw_input('name: ') sexe = raw_input('sexe: ') r1 = raw_input('r1 Y or N: ') infos = name+;+sexe+;+r1 f=open(test.txt,r) conten = f.read() print conten f.close() #f=open(test.txt,a) #f.write(infos) #f.write('\n') #f.close() thank you =) -- https://mail.python.org/mailman/listinfo/python-list
Re: Python mange with liste
On Sun, Dec 29, 2013 at 3:49 PM, Bala Ji bala...@gmail.com wrote: hello, thank you for your help i wrote this: x=nam1 y=F names = [(nam1, F, Y), (nam2, M, N)] l = len(names) for i in range(0,l): print names[i][0] print names[i][1] if x == names[i][0] and y == names[i][1]: message = right else: message = wrong print message Ok lets start with 1. l = len(names) for i in range(0,l): ... names[1] ... Better to do in python as for n in names: ... n ... ie use n where you were using names[i] no need for range, len, indexing etc etc 2. You are setting (ie assigning) message each time round the loop Try writing a function that does NO set (assign) NO print Ok this time let me write it for you So I write a function called foo, taking an argument called nn def foo(nn): ... for n in names: ... if n == nn: return True ... return False ... Note: No input, No output, No file IO and above all No assignment foo((nam1,F,Y)) True foo((nam4,F,Y)) False Notice my foo takes an argument that is a triplet You need to change foo to taking name and sex and ignoring the third element Your homework -- Oui?? -- https://mail.python.org/mailman/listinfo/python-list
Re: Python mange with liste
Bala Ji bala...@gmail.com wrote in message news:11c1b4ef-07a3-4424-b356-9a9cf635f...@googlegroups.com... hello, thank you for your help i wrote this: x=nam1 y=F names = [(nam1, F, Y), (nam2, M, N)] l = len(names) for i in range(0,l): print names[i][0] print names[i][1] if x == names[i][0] and y == names[i][1]: message = right else: message = wrong print message normally it must tell me right but it tells me wrong best Your problem is that, after you find a valid name, you continue looping, and then find an invalid name, so the message is over-written. The usual way to terminate a loop without continuing to the next item is with the 'break' statement. Here are three variations of your code, each with an improvement over the previous one - 1. This adds the break statement - it should do what you want - l = len(names) for i in range(0,l): print names[i][0] print names[i][1] if x == names[i][0] and y == names[i][1]: message = right break else: message = wrong 2. This uses a feature of python which specifies an action to be taken only if the loop continues to the end without interruption - l = len(names) for i in range(0,l): print names[i][0] print names[i][1] if x == names[i][0] and y == names[i][1]: message = right break else: message = wrong Note that the last two lines are indented to line up with the 'for ' statement. In the previous version, message is set to 'wrong' for every iteration of the loop until a valid name is found. In this version, it is only set to 'wrong' if no valid name is found. 3. This uses a feature of python which allows you to iterate over the contents of a list directly - for name in names: print name[0] print name[1] if x == name[0] and y == name[1]: message = right break else: message = wrong Hope this gives you some ideas. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list
Re: Unit tests and coverage
On 12/28/13 11:21 PM, Joseph L. Casale wrote: I have a script that accepts cmdline arguments and receives input via stdin. I have a unit test for it that uses Popen to setup an environment, pass the args and provide the stdin. Problem is obviously this does nothing for providing coverage. Given the above specifics, anyone know of a way to work around this? Thanks, jlc It sounds like you may have already found the coverage.py docs on measuring subprocesses. Another approach is to refactor your code so that the bulk of it can be invoked without a subprocess, then test that code with simple function calls. Those tests will be easy to measure with coverage.py, and by the way, they'll run much faster and be easier to debug. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list
Re: outsmarting context managers with coroutines
On 12/29/13 07:06, Ian Kelly wrote: On Sat, Dec 28, 2013 at 5:35 PM, Burak Arslan burak.ars...@arskom.com.tr wrote: On 12/29/13 00:13, Burak Arslan wrote: Hi, Have a look at the following code snippets: https://gist.github.com/plq/8164035 Observations: output2: I can break out of outer context without closing the inner one in Python 2 output3: Breaking out of outer context closes the inner one, but the closing order is wrong. output3-yf: With yield from, the closing order is fine but yield returns None before throwing. It doesn't, my mistake. Python 3 yield from case does the right thing, I updated the gist. The other two cases still seem weird to me though. I also added a possible fix for python 2 behaviour in a separate script, though I'm not sure that the best way of implementing poor man's yield from. I don't see any problems here. The context managers in question are created in separate coroutines and stored on separate stacks, so there is no inner and outer context in the thread that you posted. I don't believe that they are guaranteed to be called in any particular order in this case, nor do I think they should be. First, Python 2 and Python 3 are doing two separate things here: Python 2 doesn't destroy an orphaned generator and waits until the end of the execution. The point of having raw_input at the end is to illustrate this. I'm tempted to call this a memory leak bug, especially after seeing that Python 3 doesn't behave the same way. As for the destruction order, I don't agree that destruction order of contexts should be arbitrary. Triggering the destruction of a suspended stack should first make sure that any allocated objects get destroyed *before* destroying the parent object. But then, I can think of all sorts of reasons why this guarantee could be tricky to implement, so I can live with this fact if it's properly documented. We should just use 'yield from' anyway. For example, the first generator could yield the second generator back to its caller and then exit, in which case the second generator would still be active while the context manager in the first generator would already have done its clean-up. Sure, if you pass the inner generator back to the caller of the outer one, the inner one should survive. The refcount of the inner is not zero yet. That's doesn't have much to do with what I'm trying to illustrate here though. Best, Burak -- https://mail.python.org/mailman/listinfo/python-list
Re: eclipse+pyDev code complete problem
Hi there, Please create an issue in the PyDev tracker for that: https://sw-brainwy.rhcloud.com/tracker/PyDev/ Cheers, Fabio On Fri, Dec 27, 2013 at 4:54 PM, zhaoyunsong zhao_yuns...@163.com wrote: dear all, I am trying to configure eclipse + pydev as my ide, but there seems to be some problem on code complete. the attached is the case when code complete does not work. any suggestions? Thanks! my system is win 64bit pyhon 3.3 64bit eclipse kepler-SR1 pydev 3.1 I downloaded pillow from this website: http://www.lfd.uci.edu/~gohlke/pythonlibs/ Yunsong Zhao -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: outsmarting context managers with coroutines
On Sun, Dec 29, 2013 at 7:44 AM, Burak Arslan burak.ars...@arskom.com.tr wrote: On 12/29/13 07:06, Ian Kelly wrote: On Sat, Dec 28, 2013 at 5:35 PM, Burak Arslan burak.ars...@arskom.com.tr wrote: On 12/29/13 00:13, Burak Arslan wrote: Hi, Have a look at the following code snippets: https://gist.github.com/plq/8164035 Observations: output2: I can break out of outer context without closing the inner one in Python 2 output3: Breaking out of outer context closes the inner one, but the closing order is wrong. output3-yf: With yield from, the closing order is fine but yield returns None before throwing. It doesn't, my mistake. Python 3 yield from case does the right thing, I updated the gist. The other two cases still seem weird to me though. I also added a possible fix for python 2 behaviour in a separate script, though I'm not sure that the best way of implementing poor man's yield from. I don't see any problems here. The context managers in question are created in separate coroutines and stored on separate stacks, so there is no inner and outer context in the thread that you posted. I don't believe that they are guaranteed to be called in any particular order in this case, nor do I think they should be. First, Python 2 and Python 3 are doing two separate things here: Python 2 doesn't destroy an orphaned generator and waits until the end of the execution. The point of having raw_input at the end is to illustrate this. I'm tempted to call this a memory leak bug, especially after seeing that Python 3 doesn't behave the same way. Ah, you may be right. I'm not sure what's going on with Python 2 here, and all my attempts to collect the inaccessible generator have failed. The only times it seems to clean up are when Python exits and, strangely, when dropping to an interactive shell using the -i command line option. It also cleans up properly if the first generator explicitly dels its reference to the second before exiting. This doesn't have anything to do with the context manager though, as I see the same behavior without it. As for the destruction order, I don't agree that destruction order of contexts should be arbitrary. Triggering the destruction of a suspended stack should first make sure that any allocated objects get destroyed *before* destroying the parent object. But then, I can think of all sorts of reasons why this guarantee could be tricky to implement, so I can live with this fact if it's properly documented. We should just use 'yield from' anyway. You generally get this behavior when objects are deleted by the reference counting mechanism, but that is an implementation detail of CPython. Since different implementations use different collection schemes, there is no language guarantee of when or in what order finalizers will be called, and even in CPython with the new PEP 442, there is no guarantee of what order finalizers will be called when garbage collecting reference cycles. For example, the first generator could yield the second generator back to its caller and then exit, in which case the second generator would still be active while the context manager in the first generator would already have done its clean-up. Sure, if you pass the inner generator back to the caller of the outer one, the inner one should survive. The refcount of the inner is not zero yet. That's doesn't have much to do with what I'm trying to illustrate here though. The point I'm trying to make is that either context has the potential to long outlive the other one, so you can't make any guarantee that they will be exited in LIFO order. -- https://mail.python.org/mailman/listinfo/python-list
abrt: detected unhandled Python exception
Hi all, I am facing a script issue whenever i run my script in /var/log/messages and it gives error something as below: abrt: detected unhandled Python exception in x.py. Can anybody help me figuring out how do i know which line number has thrown the python exception? Regards Pradeep -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3.2 Shell Message
Hi Ned, I am running into the same problem described by Bart. I am teaching my kids to program using the Python For Kids book on a Mac OSX 10.8.5. I have installed Mac OS X 64-bit/32-bit Installer (3.3.3) for Mac OS X 10.6 and later (file: python-3.3.3-macosx10.6.dmg) and installed the ActiveTcl 8.6.1 for Mac OS X (10.5+, x86_64/x86) (file: ActiveTcl8.6.1.1.297588-macosx10.5-i386-x86_64-threaded), but IDLE keeps showing the message WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. Visit http://www.python.org/download/mac/tcltk/ for current information. Per your instructions in the thread http://code.activestate.com/lists/python-dev/117314/ I have inspected the IDLE process using Activity Monitor and the Tcl/Tk processes being used are: /System/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk Is there a PATH setting or something I can use to force the use of the ActiveTcl Tcl/Tk located in: /Library/Frameworks/Tcl.framework/Versions/8.5/Tcl and /Library/Frameworks/Tk.framework/Versions/8.5/Tk I have tried a bunch of different things all to no avail, so I am now reaching for help. I have UNIX experience and a CS degree, although very rusty, so have at with any technical instructions. Thank you very much!!! -- https://mail.python.org/mailman/listinfo/python-list
Tkinter problem: TclError couldn't connect to display :0
Hi, I use live Debian on VM and trying to compile this code. import Tkinter root = Tkinter.Tk() root.title(Fenster 1) root.geometry(100x100) root.mainloop() The shell gives out that kind of message: File test.py, line 5, in module root = Tkinter.Tk() File /usr/lib/python2.7/lib-tk/Tkinter.py, line 1712, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: couldn't connect to display :0 thanks for helping out. greets. Mike -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3.2 Shell Message
Is there a PATH setting or something I can use to force the use of the ActiveTcl Tcl/Tk located in: /Library/Frameworks/Tcl.framework/Versions/8.5/Tcl and /Library/Frameworks/Tk.framework/Versions/8.5/Tk Correction. The ActiveTcl /Library directions are: /Library/Frameworks/Tcl.framework/Versions/8.6 /Library/Frameworks/Tcl.framework/Versions/8.6 Note also that symbolic links were created by something (assume the install script) from: /Library/Frameworks/Tcl.framework/Versions/Current to /Library/Frameworks/Tcl.framework/Versions/8.6 to and /Library/Frameworks/Tk.framework/Versions/Current to /Library/Frameworks/Tk.framework/Versions/8.6 Also, the IDLE message I am getting (which is slightly different than Bart's) is: WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. I assume this is referring to the Apple system version of Tcl/Tk. Maybe there is symbolic link I need to set-up... By the way, I have tried to address with setting to PATH in .bash_profile, having /usr/local/bin first in the path. This has created a situation of running the correct version of tclsh from bash, but it does not solve the problem for IDLE, even if putting a specific call to . .bash_profile from the Automator script which starts IDLE. Actively working on this... may try to create a symbolic link from /System/Library/Frameworks/Tcl.framework/Versions/Current to /Library/Frameworks/Tcl.framework/Versions/Current -- https://mail.python.org/mailman/listinfo/python-list
Sania Mirza Naked Pics at www.ZHAKKAS.com
-- https://mail.python.org/mailman/listinfo/python-list
Re: abrt: detected unhandled Python exception
On Mon, Dec 30, 2013 at 6:35 AM, smilesonisa...@gmail.com wrote: Hi all, I am facing a script issue whenever i run my script in /var/log/messages and it gives error something as below: abrt: detected unhandled Python exception in x.py. Can anybody help me figuring out how do i know which line number has thrown the python exception? Google results suggest that this is a Red Hat thing: abrt = Automatic Bug Reporting Tool. https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/ch-abrt.html I'm not a Red Hat person myself (I use Debian), so I can't really much help; but my suspicion is that it'll be logging the full traceback somewhere (some of the posts I found referred to it sending mail, so you might find it in your /var/spool/mail). Alternatively, are you able to simply run the script from the command line? That ought to make the traceback come to your console. Not possible if it's a CGI script or something, though. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError couldn't connect to display :0
On Mon, Dec 30, 2013 at 7:20 AM, Michael Matveev misch...@googlemail.com wrote: The shell gives out that kind of message: File test.py, line 5, in module root = Tkinter.Tk() File /usr/lib/python2.7/lib-tk/Tkinter.py, line 1712, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: couldn't connect to display :0 Worked for me on an installed Debian, inside Xfce with xfce4-terminal. 1) What version of Python are you running? 2) Are you running inside some kind of graphical environment? 3) Do you have any sort of permissions/environment change happening? I get an error like that if I try sudo python without any sort of guard. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3.2 Shell Message
Is there a PATH setting or something I can use to force the use of the ActiveTcl Tcl/Tk located in: /Library/Frameworks/Tcl.framework/Versions/8.5/Tcl and /Library/Frameworks/Tk.framework/Versions/8.5/Tk Correction. The ActiveTcl /Library directions are: /Library/Frameworks/Tcl.framework/Versions/8.6 /Library/Frameworks/Tk.framework/Versions/8.6 Note also that symbolic links were created by something (assume the install script) from: /Library/Frameworks/Tcl.framework/Versions/Current to /Library/Frameworks/Tcl.framework/Versions/8.6 to and /Library/Frameworks/Tk.framework/Versions/Current to /Library/Frameworks/Tk.framework/Versions/8.6 Also, the IDLE message I am getting (which is slightly different than Bart's) is: WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. I assume this is referring to the Apple system version of Tcl/Tk. Maybe there is symbolic link I need to set-up... By the way, I have tried to address with setting to PATH in .bash_profile, having /usr/local/bin first in the path. This has created a situation of running the correct version of tclsh from bash, but it does not solve the problem for IDLE, even if putting a specific call to . .bash_profile from the Automator script which starts IDLE. Actively working on this...May try to create a symbolic link from /System/Library/Frameworks/Tcl.framework/Versions/Current to /Library/Frameworks/Tcl.framework/Versions/Current -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3.2 Shell Message
Actively working on this... may try to create a symbolic link from /System/Library/Frameworks/Tcl.framework/Versions/Current to /Library/Frameworks/Tcl.framework/Versions/Current Symbolic link (ln -s) does not seem to have worked either. G. Tried /System/Library/Frameworks/Tcl.framework/Versions, did ln -s /Library/Frameworks/Tcl.framework/Versions/8.6 Current and /System/Library/Frameworks/Tk.framework/Versions, did ln -s /Library/Frameworks/Tk.framework/Versions/8.6 Current Also tried /System/Library/Frameworks/Tcl.framework/Versions, did ln -s /Library/Frameworks/Tcl.framework/Versions/Current Current and /System/Library/Frameworks/Tk.framework/Versions, did ln -s /Library/Frameworks/Tk.framework/Versions/Current Current such as /System/Library/Frameworks/Tcl.framework/Versions/Current to /Library/Frameworks/Tcl.framework/Versions/8.6 (instead of Current). -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError couldn't connect to display :0
Michael Matveev wrote: Hi, I use live Debian on VM and trying to compile this code. import Tkinter root = Tkinter.Tk() root.title(Fenster 1) root.geometry(100x100) root.mainloop() The shell gives out that kind of message: File test.py, line 5, in module root = Tkinter.Tk() File /usr/lib/python2.7/lib-tk/Tkinter.py, line 1712, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: couldn't connect to display :0 Are you using ssh to connect to the system? If I create a file and run it directly from the machine I am physically sitting at, it works fine and the window is displayed as expected: [steve@ando ~]$ cat test.py import Tkinter root = Tkinter.Tk() root.title(Fenster 1) root.geometry(100x100) root.mainloop() [steve@ando ~]$ python2.7 test.py [steve@ando ~]$ But if I ssh to the machine, I get an error (although a different error from you): steve@orac:~$ ssh ando steve@ando's password: Last login: Thu Dec 12 19:27:04 2013 from 203.7.155.68 [steve@ando ~]$ python2.7 test.py Traceback (most recent call last): File test.py, line 2, in module root = Tkinter.Tk() File /usr/local/lib/python2.7/lib-tk/Tkinter.py, line 1685, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: no display name and no $DISPLAY environment variable If I set the $DISPLAY environment variable, it works for me: [steve@ando ~]$ export DISPLAY=:0 [steve@ando ~]$ python2.7 test.py [steve@ando ~]$ logout Connection to ando closed. But ando is the machine I am physically seated at, so it's not surprising that I can see the window on the X display. If I go the other way, and try to run the code on orac (the remote machine), I get the same error as you: steve@orac:~$ export DISPLAY=:0 steve@orac:~$ python2.6 test.py No protocol specified Traceback (most recent call last): File test.py, line 2, in module root = Tkinter.Tk() File /usr/lib/python2.6/lib-tk/Tkinter.py, line 1646, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: couldn't connect to display :0 So you need to X-forward from the remote machine to the machine you are physically on, or perhaps it's the other way (X is really weird). I have no idea how to do that, but would love to know. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError couldn't connect to display :0
On Mon, Dec 30, 2013 at 10:22 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: So you need to X-forward from the remote machine to the machine you are physically on, or perhaps it's the other way (X is really weird). I have no idea how to do that, but would love to know. With SSH, that's usually just ssh -X target, and it'll mostly work. But there are potential issues with .Xauthority, which is why the sudo example fails. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError couldn't connect to display :0
On Mon, 30 Dec 2013 10:30:11 +1100, Chris Angelico wrote: On Mon, Dec 30, 2013 at 10:22 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: So you need to X-forward from the remote machine to the machine you are physically on, or perhaps it's the other way (X is really weird). I have no idea how to do that, but would love to know. With SSH, that's usually just ssh -X target, and it'll mostly work. Holy cow, it works! Slwly, but works. steve@runes:~$ ssh -X ando.pearwood.info st...@ando.pearwood.info's password: Last login: Mon Dec 30 10:10:13 2013 from orac [steve@ando ~]$ python2.7 test.py [steve@ando ~]$ -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError couldn't connect to display :0
On Mon, Dec 30, 2013 at 2:29 PM, Steven D'Aprano st...@pearwood.info wrote: On Mon, 30 Dec 2013 10:30:11 +1100, Chris Angelico wrote: On Mon, Dec 30, 2013 at 10:22 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: So you need to X-forward from the remote machine to the machine you are physically on, or perhaps it's the other way (X is really weird). I have no idea how to do that, but would love to know. With SSH, that's usually just ssh -X target, and it'll mostly work. Holy cow, it works! Slwly, but works. steve@runes:~$ ssh -X ando.pearwood.info st...@ando.pearwood.info's password: Last login: Mon Dec 30 10:10:13 2013 from orac [steve@ando ~]$ python2.7 test.py [steve@ando ~]$ On a LAN, it's not even slow! I've actually run VLC through ssh -X and watched a DVD that was in a different computer's drive. That was fun. You can even get a Windows X server and run Linux GUI programs on a Windows client. *Very* useful if you're working with both types of computer. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3.2 Shell Message
On Sunday, December 29, 2013 5:18:18 PM UTC-5, Stan Ward wrote: Note: I do not get the WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. message when I run python directly from bash (Mac Terminal), but I do get it in the IDLE.app Shell Window, run as follows, based on the recommendation in Python for Kids, with the addition of the .bash_profile call to to try to ensure paths. . .bash_profile open -a //Applications/Python 3.3/IDLE.app --args -n Sorry about all this newbie questions/info. -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError couldn't connect to display :0
On Sun, Dec 29, 2013 at 10:29 PM, Steven D'Aprano st...@pearwood.infowrote: On Mon, 30 Dec 2013 10:30:11 +1100, Chris Angelico wrote: On Mon, Dec 30, 2013 at 10:22 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: So you need to X-forward from the remote machine to the machine you are physically on, or perhaps it's the other way (X is really weird). I have no idea how to do that, but would love to know. With SSH, that's usually just ssh -X target, and it'll mostly work. Holy cow, it works! Slwly, but works. I usually use ssh -Y. The -Y argument toggles trusted forwarding. From the ssh man-page: -Y Enables trusted X11 forwarding. Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls. I've found -Y is a bit faster than -X in my experience (I've never really had many problems with X-forwarding on LANs in my experience -- even with OpenGL windows) -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3.2 Shell Message
In article 78312fc7-adf1-4324-82f3-c53a4622b...@googlegroups.com, stanw...@gmail.com wrote: I have installed Mac OS X 64-bit/32-bit Installer (3.3.3) for Mac OS X 10.6 and later (file: python-3.3.3-macosx10.6.dmg) and installed the ActiveTcl 8.6.1 for Mac OS X (10.5+, x86_64/x86) (file: ActiveTcl8.6.1.1.297588-macosx10.5-i386-x86_64-threaded), but IDLE keeps showing the message WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. Visit http://www.python.org/download/mac/tcltk/ for current information. You need to install ActiveTcl 8.5 for OS X, currently 8.5.15.0. It's further down on the ActiveTcl download page (http://www.activestate.com/activetcl/downloads). Installing 8.6.1 does not help (it doesn't hurt, either, so you don't need to worry about removing it). -- Ned Deily, n...@acm.org -- https://mail.python.org/mailman/listinfo/python-list
Re: Apache restart after source changes
In development environment I suggest to use build-in webserver from wsgiref module, see http://docs.python.org/2/library/wsgiref.html#examples Then it's easy to run webserver in console and killstart it with Ctrl+C keystroke. In production environment, use your prefered webserver like apache,nginx etc... Dne čtvrtek, 26. prosince 2013 7:36:45 UTC+1 Fredrik Bertilsson napsal(a): Also, it's not a python issue, it's an issue with your particular stack. Other stacks do automatic reloading (for example, the web server that Django uses). Which web server do you suggest instead of Apache, which doesn't have this problem? (I am not planning to use Django) -- https://mail.python.org/mailman/listinfo/python-list
[issue20079] Add support for glibc supported locales
Changes by Berker Peksag berker.pek...@gmail.com: -- nosy: +berker.peksag ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20079 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20092] type() constructor should bind __int__ to __index__ when __index__ is defined and __int__ is not
Ethan Furman added the comment: In issue19995, in msg206339, Guido exhorted: [Ethan claimed] it is possible to want a type that can be used as an index or slice but that is still not a number I'm sorry, but this requirement is absurd. An index *is* a number. You have to make up your mind. (I know, in the context of the example that started this, this is funny, but I still stand by it.) Finally, the correct name should perhaps have been __integer__ but I don't see enough reason to change it now. The de facto API that is forming is that if an actual int is needed from an actual integer type (not float, not complex, not etc.), then __index__ is used. If __index__ is not defined by some numeric type then it will not be considered a true int in certain key places in Python, such as as indices, arguments to hex(), etc. Making the change suggested in the title would help solidify the API. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20092 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19995] %c, %o, %x, %X accept non-integer values instead of raising an exception
Ethan Furman added the comment: Ran full test suite; some errors came up in test_format from the following test lines: testformat(%#x, 1.0, 0x1) testformat(%x, float(big), 123456___, 6) testformat(%o, float(big), 123456__, 6) testformat(%x, float(0x42), 42) testformat(%o, float(0o42), 42) Removed as float() is not supposed to be valid input. Also fixed two memory leaks in unicodeobject from my changes, and a float-oct bug in tarfile. -- Added file: http://bugs.python.org/file33286/issue19995.stoneleaf.02.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19995 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11798] Test cases not garbage collected after run
Antoine Pitrou added the comment: It is used, see countTestCases(). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11798 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20084] smtplib: support for UTF-8 encoded headers (SMTPUTF8)
Freek Dijkstra added the comment: we want our message to get delivered regardless of whether or not smtputf8 is available. This is not possible if the user specifies an (sender or recipient) email address with non-ASCII characters and the first-hop mail system does not support SMTPUTF8. Section 8 of RFC 6530 seems to suggest that in that case either an all-ASCII email address should be used, and if that is not available, the mail should bounce. In my interpretation smtplib should fail by raising an Exception. [...] a Message object, which can be automatically serialised as utf8 if smtputf8 is available [...] I hadn't given the mail body much thought. I think that this is covered by the existing 8BITMIME extension, in which case the client can add the header 'Content-Type: text/plain; charset=utf-8'. From what I understand SMTPUTF8 only concerns the encoding of the header. I prefer that this particular issue (enhancement request) only concerns the mail headers, not the mail body. (I see that you also have some ideas on this, perhaps this is for a different issue?) PS: I planned to use smtplib to see if I could understand the standard for international email addresses. Turns out I'm not reading the standard to see how smtplib should work. Also nice, but not what I had intended to do. :). It seems that STMPUTF8 is not yet implemented that much. I've learned that my production MTA does not support it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20084 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20092] type() constructor should bind __int__ to __index__ when __index__ is defined and __int__ is not
R. David Murray added the comment: Ah, I see. A link to that issue would have been helpful :). To summarize for anyone like me who didn't follow that issue: __index__ means the object can be losslessly converted to an int (is a true int), while __int__ may be an approximate conversion. Thus it makes sense for an object to have an __int__ but not __index__, but vice-versa does not make sense. Is someone updating the docs to reflect this, or should that be spun off as a separate issue as well? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20092 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20084] smtplib: support for UTF-8 encoded headers (SMTPUTF8)
R. David Murray added the comment: Yeah, I've been doing a lot of reading of standards while trying to hide all the messy details from users of the new API I've added to the email package. I haven't gotten to smtplib yet :) But, this stuff is messy. If you want to understand a standard, you really have to read it, and lots of others standards besides, and then look at what various packages have chosen to implement, and figure out all the ways you think they did it wrong :) As you have observed, implementations of SMTPUTF8 are scarce on the ground so far. SMTPUTF8 may be about headers, but because the natural way of representing non-ascii headers in Python is as a (unicode) string, and SEND takes a single string (or bytes) argument, you can't separate dealing with the encoding of the headers from dealing with the encoding of the body unless you *parse* the payload as an email message so you can do the right thing with the body. Thus you can't address adding SMTPUTF8 to smtplib without figuring out the API for the whole message, not just the headers. So yes, the client can 'add Content-Type: text/plain; charset=utf-8', but the process of doing that is exactly what I was talking about :) Now, one option, as I said, it to put the burden on the application: it can check to see if SMTPUTF8 is available, and if so provide a DATA formatted with utf8 headers and charset='utf-8' bodies, and if it is not available, provide a DATA formatted with RFC2047 headers and charset=utf-8 bodies. But I'd rather make smtplib (with the help of the email package) do the hard work, rather than have every application have to do it. Still, we could start with a patch that just makes it possible for an application to do it itself. That would just need to accept non-ascii in the RCPT etc commands, pass it through as utf8 if SMTPUTF8 is available, and raise an error otherwise. You are correct that the more convenient API I'm talking about also needs to be enhanced to provide a way to specify the alternate ASCII-only address. I'd forgotten about that detail. That's going to be very annoying from a clean-API point of view :( And yes, it should raise an exception if SMTPUTF8 is not available and no ascii address was provided. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20084 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16778] Logger.findCaller needs to be smarter
Nick Coghlan added the comment: I think we need to look seriously at the frame annotations idea discussed in other issues. Eliminating noise from tracebacks and correctly reporting user code rather than infrastructure could should be achievable through local state rather than needing global registries. The workaround we put in place for importlib is an awful hack, and there's a problem where PEP 3144 allows the creation of exception *trees*, but we can currently only record stacks properly. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16778 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20092] type() constructor should bind __int__ to __index__ when __index__ is defined and __int__ is not
Ethan Furman added the comment: I have the following as part of the patch for that issue: - diff -r b668c409c10a Doc/reference/datamodel.rst --- a/Doc/reference/datamodel.rst Sat Dec 28 20:37:58 2013 +0100 +++ b/Doc/reference/datamodel.rst Sun Dec 29 06:55:11 2013 -0800 @@ -2073,23 +2073,31 @@ left undefined. builtin: float builtin: round Called to implement the built-in functions :func:`complex`, :func:`int`, :func:`float` and :func:`round`. Should return a value of the appropriate type. .. method:: object.__index__(self) - Called to implement :func:`operator.index`. Also called whenever Python needs - an integer object (such as in slicing, or in the built-in :func:`bin`, - :func:`hex` and :func:`oct` functions). Must return an integer. + Called to implement :func:`operator.index`, and whenever Python needs to + losslessly convert the numeric object to an integer object (such as in + slicing, or in the built-in :func:`bin`, :func:`hex` and :func:`oct` + functions). Presence of this method indicates that the numeric object is + an integer type. Must return an integer. + + .. note:: + + When :meth:`__index__` is defined, :meth:`__int__` should also be defined, + and both shuld return the same value, in order to have a coherent integer + type class. - If for some reason that patch doesn't make it into 3.4 I'll split the doc change off to its own issue, unless you think it should be split off anyway? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20092 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9291] mimetypes initialization fails on Windows because of non-Latin characters in registry
Jason R. Coombs added the comment: The bug as reported against setuptools: https://bitbucket.org/pypa/setuptools/issue/127/unicodedecodeerror-when-install-in-windows -- nosy: +jason.coombs ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9291 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20093] Wrong OSError message from os.rename() when dst is a non-empty directory
Dmitry Shachnev added the comment: This is a result of http://hg.python.org/cpython/rev/6903f5214e99. Looks like we should check the error code and conditionally set the file name to either src or dst. -- nosy: +haypo, mitya57 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20093 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16778] Logger.findCaller needs to be smarter
Vinay Sajip added the comment: the frame annotations idea discussed in other issues If you mean #19585 and #18861, they seem to be related to exceptions - the logging use case is not exception-related. I couldn't find any other discussions about frame annotations. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16778 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19890] Typo in multiprocessing docs
Changes by Mike Short bmsh...@gmail.com: -- keywords: +patch Added file: http://bugs.python.org/file33287/multiprocessing.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19890 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19890] Typo in multiprocessing docs
Changes by Mike Short bmsh...@gmail.com: -- nosy: +Mike.Short ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19890 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20094] intermitent failures with test_dbm
New submission from Ethan Furman: Following errors occur about half the time: == ERROR: test_anydbm_creation (test.test_dbm.TestCase-dbm.ndbm) -- Traceback (most recent call last): File /home/ethan/source/python/issue19995/Lib/test/test_dbm.py, line 75, in test_anydbm_creation self.read_helper(f) File /home/ethan/source/python/issue19995/Lib/test/test_dbm.py, line 117, in read_helper self.assertEqual(self._dict[key], f[key.encode(ascii)]) KeyError: b'0' == ERROR: test_anydbm_modification (test.test_dbm.TestCase-dbm.ndbm) -- Traceback (most recent call last): File /home/ethan/source/python/issue19995/Lib/test/test_dbm.py, line 90, in test_anydbm_modification self.read_helper(f) File /home/ethan/source/python/issue19995/Lib/test/test_dbm.py, line 117, in read_helper self.assertEqual(self._dict[key], f[key.encode(ascii)]) KeyError: b'0' == ERROR: test_anydbm_read (test.test_dbm.TestCase-dbm.ndbm) -- Traceback (most recent call last): File /home/ethan/source/python/issue19995/Lib/test/test_dbm.py, line 96, in test_anydbm_read self.read_helper(f) File /home/ethan/source/python/issue19995/Lib/test/test_dbm.py, line 117, in read_helper self.assertEqual(self._dict[key], f[key.encode(ascii)]) KeyError: b'0' -- messages: 207079 nosy: ethan.furman priority: normal severity: normal status: open title: intermitent failures with test_dbm versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20094 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20094] intermitent failures with test_dbm
Ethan Furman added the comment: Actually, make that about 1/5 of the time. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20094 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11798] Test cases not garbage collected after run
Michael Foord added the comment: Ah yes, I see - sorry. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11798 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19732] python fails to build when configured with --with-system-libmpdec
Matthias Klose added the comment: your current repo doesn't create and install the .so symlink, and thus won't be used for linking. Also the sphinx docs are missing, which were included in 2.3. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19732 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19940] ssl.cert_time_to_seconds() returns wrong results if local timezone is not UTC
gudge added the comment: Can you please provide some hints on how to handle http://bugs.python.org/issue19940#msg205860. The value of format_regex 1) Without locale set: re.compile('(?Pbjan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\\s+(?Pd3[0-1]|[1-2]\\d|0[1- 9]|[1-9]| [1-9])\\s+(?PH2[0-3]|[0-1]\\d|\\d):(?PM[0-5]\\d|\\d):(?PS6[0-1]|[0-5]\\d|\\d)\\s +(?PY\\d\\d\\d\\d, re.IGNORECASE) 2) With locale set: re.compile('(?Pbsty|lut|mar|kwi|maj|cze|lip|sie|wrz|pa\\ź|lis|gru)\\s+(?Pd3[0-1]|[1-2]\\d|0[ 1-9]|[1-9]| [1-9])\\s+(?PH2[0-3]|[0-1]\\d|\\d):(?PM[0-5]\\d|\\d):(?PS6[0-1]|[0-5]\\d|\\d)\ \s+(?PY\\d\\d\\d\, re.IGNORECASE) The value of months are different. Thanks -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19940 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20092] type() constructor should bind __int__ to __index__ when __index__ is defined and __int__ is not
R. David Murray added the comment: Nah, splitting it doesn't seem worth it unless you think the patch won't make it in. (Not that I looked at it earlier, but he patch on the issue doesn't look like what you just posted here...and here there's a typo: shuld). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20092 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20092] type() constructor should bind __int__ to __index__ when __index__ is defined and __int__ is not
Ethan Furman added the comment: I updated it as I liked your wording better. :) Doing more testing to see if anything else needs fixing before I make the next patch for the tracker on that issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20092 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20031] unittest.TextTestRunner missing run() documentation.
Roundup Robot added the comment: New changeset 19464d77ec2e by Michael Foord in branch 'default': Closes issue 20031. Document unittest.TextTestRunner.run method. http://hg.python.org/cpython/rev/19464d77ec2e -- nosy: +python-dev resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20031 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18566] In unittest.TestCase docs for setUp() and tearDown() don't mention AssertionError
Michael Foord added the comment: Yep, those docs are just wrong. I'm trying to think of a concise rewording. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18566 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16778] Logger.findCaller needs to be smarter
Nick Coghlan added the comment: My idea is to annotate the frames appropriately so they can be *displayed* differently when showing a traceback (either hiding them entirely or displaying additional information). This would be another use case - annotating the frame to say the logging module should skip over it when looking for the caller. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16778 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18310] itertools.tee() can't accept keyword arguments
Mark Lawrence added the comment: Why has this been closed? I've just run into exactly the same problem. It states here http://docs.python.org/3/library/itertools.html#itertools.tee itertools.tee(iterable, n=2) - Return n independent iterators from a single iterable. -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18310 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18310] itertools.tee() can't accept keyword arguments
Mark Lawrence added the comment: The docs for tee are the same going right back to its introduction in 2.4. The itertools count function takes start and step keywords, why can't tee take a keyword as it's documented to? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18310 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19771] runpy should check ImportError.name before wrapping it
Changes by Anthony Kong anthony.hw.k...@gmail.com: -- nosy: +Anthony.Kong ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19771 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18310] itertools.tee() can't accept keyword arguments
Mark Lawrence added the comment: It's just the docs that need changing to clarify the situation as (say) a,b,c = tee(range, 3) works perfectly. Sorry I didn't have the foresight to check this before :( -- components: +Documentation -Library (Lib) versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18310 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com