Re: [Tutor] Strange IndexError
Hi Danny, I've posted the bug at the pyro ML. However the old IndexError annoys me more and more. Although I have encapsulated it with try/except blocks and that works ok for what I want, I really want to understand how an exception like Traceback (most recent call last): File "NeedBrain.py", line 257, in update assert type(self.STAY_MIN_DIST)==type(1.0), str(self.STAY_MIN_DIST)+"is not float" IndexError: tuple assignment index out of range is thrown. I mean, this line of code must be some Python related stuff. The only alternativ would be that self has some __getattr__ methods that were invoked. But then, the exception would have bin in that method, wouldn't it? The only place where STAY_MIN_DIST is set is as a class variable: class ApproachMarkerAction(State): STAY_MIN_DIST = 2.0 def __init__(self, markerType=None, status = 0, name = ''): ... Thanks for any clarification, wr Am Dienstag, 14. Juni 2005 01:03 schrieb Danny Yoo: > On Mon, 13 Jun 2005, Willi Richert wrote: > > I used the same Pyro code, but this time with the release versions of > > player and stage. This time python crashed with a segfault: > > Hi Willi, > > If you see a segfault like this, it's almost definitely a bug in a > third-party module. It is possible that the bug is in Python itself, but > since the Python core has been so well-tested, this is unlikely. > > > Bring this up to the Pyro folks so they can trace what looks like an > incorrect refcount problem somewhere in their C code or SWIG bindings. I > don't think there's much else that you can do at this point, unless you > have written your code to use some substitute to Pyro. > > If I had time, I'd be willing to look at the Pyro code and see what's > going on. But the Pyro folks are probably the people to pester about > this, since this looks like a problem in their extension code. > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] is this a bug global i ???
I have code like this: class A: def __init__(self,j): self.j = j def something(self): print self.j print i# PROBLEM is here there is no var i in class A but it works ??? if __name__ == '__main__': i = 10 a = A(5) a.something() I don't define global i but it will takes var i from outside of class A. Can somebody explain this ??? pujo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Passing command line argument in function
Gary Taylor wrote: > I'm trying to pass the name of a file as the first argument > to the ftp.storbinary function(?) below. The only thing I > can get to work is the real file name hard coded as the > argument. I've tried parenthesis, single quotes, double > quotes, and many combinations of the previous. I've tried > passing sys.argv[1] directly as well, although with fewer > experiments. > > I invoke this as below and the output is what I would > expect, but the file name on the ftp server is never > correct. > > > What is the correct way to do this? > > > $ ./garyftp.py align.ps > align.ps > > > > --- > Python 2.3.4 on Linux. > > > --- > #!/usr/bin/python > import sys > from ftplib import FTP > > file_to_transfer = sys.argv[1] > > ftp = FTP() > ftp.connect("myserver") > ftp.login("myusername", "mypasswd") > > > ftp.storbinary(stor file_to_transfer, open(file_to_transfer,"r")) You need to create the command as a string: ftp.storbinary("stor " + file_to_transfer, open(file_to_transfer,"r")) Kent > > print file_to_transfer > ftp.quit() > -- > > Thanks, > Gary > > [EMAIL PROTECTED] > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] is this a bug global i ???
Pujo Aji wrote: > I have code like this: > > class A: > def __init__(self,j): > self.j = j > > def something(self): > print self.j > print i# PROBLEM is here there is no var i in class A > but it works ??? > > if __name__ == '__main__': > i = 10 > a = A(5) > a.something() > > I don't define global i but it will takes var i from outside of class A. This is normal behavior. When Python needs to resolve a bare name it looks it up first in the local scope (the current function), then in any enclosing lexical scopes (for nested functions), then the global scope and finally the builtins. In this case the binding for i is found in the global scope. Note that *assigning* to a name always happens in the local scope unless the name is declared global. There is no (clean) way to assign to a name in an enclosing lexical scope or the builtins. These might help a little: http://docs.python.org/tut/node11.html#SECTION001120 http://docs.python.org/ref/naming.html Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Passing command line argument in function
>> >> >> ftp.storbinary(stor file_to_transfer, open(file_to_transfer,"r")) >> > >You need to create the command as a string: >ftp.storbinary("stor " + file_to_transfer, >open(file_to_transfer,"r")) > >Kent That worked perfectly, I was way off. Thank-you! Gary p.s. sorry for the out of thread message, my mail seems to be having problems. -- [EMAIL PROTECTED] SDF Public Access UNIX System - http://sdf.lonestar.org ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Which Popen For Win32?
I am using the Winzip 9.0 Command Line Add-on to archive very large files ( 1GB and over ) that are too large to be handled by Zipfile( this bug has been reported but not resolved ). I tried calling the external program using os.system(), but something about the output crashes my IDE ( Eclipse ), so I started looking for a way to run the external application without capturing the output, as I only care about the exit code ( 0 is good, anything else is bad ). Here is what I have to far: myCmd = os.popen( "%s %s %s %s" % ( zipCommand, zipParameters, archive,fpath ), 'w' ) return myCmd.close() Currently, I have no idea what is being returned by the "close()" method, it doesn't appear to be the exit code, so perhaps it is the output of the command. If so, how can I capture and return the exit code? Thank You, John A. Gooch Systems Administrator IT - Tools EchoStar Satellite L.L.C. 9601 S. Meridian Blvd. Englewood, CO 80112 Desk: 720-514-5708 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gary Taylor Sent: Tuesday, June 14, 2005 8:15 AM To: tutor@python.org Subject: Re: [Tutor] Passing command line argument in function >> >> >> ftp.storbinary(stor file_to_transfer, open(file_to_transfer,"r")) >> > >You need to create the command as a string: ftp.storbinary("stor " + >file_to_transfer, >open(file_to_transfer,"r")) > >Kent That worked perfectly, I was way off. Thank-you! Gary p.s. sorry for the out of thread message, my mail seems to be having problems. -- [EMAIL PROTECTED] SDF Public Access UNIX System - http://sdf.lonestar.org ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] is this a bug global i ???
On Tue, 14 Jun 2005, Pujo Aji wrote: > I have code like this: > > class A: > def __init__(self,j): > self.j = j > > def something(self): > print self.j > print i# PROBLEM is here there is no var i in class A > but it works ??? > > if __name__ == '__main__': > i = 10 > a = A(5) > a.something() > > I don't define global i but it will takes var i from outside of class A. > > Can somebody explain this ??? The i is 'global' by placement so it can be read. But you can't assign it in a.something(). If you do: class A: def __init__(self,j): self.j = j def something(self): print self.j i = 11 # makes a new local i in something print i if __name__ == '__main__': i = 10 a = A(5) a.something() print 'i = ', i # prints the same old global i = 10 You'll find you made a new i in something and your i = 10 remains the same. But, if you want to change the global i, in something, then it's time for the global declaration: def something(self): global i print self.j i = 11# changes the global i print i Hope this helps. I had the same confusion long ago and this list helped me. Marilyn Davis > > pujo > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Trying Ruby...
My original question: > I vaguely recall a post a few months ago, I don't know if it was in this > forum, where someone had a problem in Python, and it turns out it was > because a Ruby install messed with some setting, perhaps in the Windows > registry Anyway, I'd like to install Ruby, but want to make very > sure I don't impair my Python environment. On Tue, 7 Jun 2005, Premshree Pillai wrote: > I have Python and Ruby -- not ActiveState -- installed on an XP box. No > issues. On Tue, 7 Jun 2005, Christian Wyglendowski wrote: > If I remember correctly, it had to do with Tk getting messed up. But > that's all I recall :-) Sorry for the late acknowledgement. My computer fried not long after I posted the message, and I haven't been reading much email since. Thanks to you both. I found the problem I recalled; Ruby sets some environment variables assuming that it's the only user of Tk, and hoses the Python usage: https://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=824756 https://sourceforge.net/tracker/?func=detail&atid=105470&aid=922914&group_id=5470 or http://makeashorterlink.com/?G4DC1624B and http://makeashorterlink.com/?T1EC2124B I'll just be careful when I install Ruby and take corrective action if needed. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] is this a bug global i ???
class A: def __init__(self,j): self.j = j def something(self): print self.j print i# PROBLEM is here there is no var i in class A but it works ??? if __name__ == '__main__': i = 10 a = A(5) a.something() > I don't define global i but it will takes var i from outside of class A. > Can somebody explain this ??? You only need to declare global if you are modifying data if you only read it there is no need for explicit global statements. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] can't see emacs timer in action
Hello, I tried this code in emacs. for i in range(3): time.sleep(1) print i It shows the result but total result not second per second. Any one experiance this problem pujo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] can't see emacs timer in action
On Jun 14, 2005, at 22:56, Pujo Aji wrote: > Hello, > > I tried this code in emacs. > for i in range(3): > time.sleep(1) > print i > > It shows the result but total result not second per second. > > Any one experiance this problem > > pujo Works for me... How do you run it? Do you use a separate terminal window, or do you use some kind of "run with Python" command in emacs? (not sure how it's done, I'm a vim user myself) Did you make sure you import time before that code is run? -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 "Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine?" ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] can't see emacs timer in action
On Jun 14, 2005, at 23:17, Pujo Aji wrote: > I just use Ctrl+C Ctrl+C to run the code. > The code wait for 3 second and show all i all together. > > I can't feel every second pass. > > pujo Try running your script from a terminal (outside of emacs, that is). -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 "Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine?" ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] can't see emacs timer in action
On Tue, 14 Jun 2005, Pujo Aji wrote: > I tried this code in emacs. > for i in range(3): > time.sleep(1) > print i > > It shows the result but total result not second per second. Hi Pujo, In Emacs, you may want to first start up a Python subprocess by using the keystroke: C-c ! and then run Python buffers with: C-c C-c Best of wishes! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] can't see emacs timer in action
On Wed, 15 Jun 2005, Pujo Aji wrote: > Thanks Danny, > > Btw, I use xemacs now does it has folding class and method capabilities? Hi Pujo, [Note: in replies, please make sure to put tutor@python.org in CC.] According to: http://groups.google.ca/group/comp.lang.python/msg/956f1c2d37f93995?q=emacs+folding+python&hl=en&lr=&ie=UTF-8&oe=UTF-8&rnum=2 Yes. *grin* ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Controlling Where My Program Ends
Never mind. I found it - sys.exit() Sorry to have wasted the bandwidth/time. -- DC Parris Matheteuo Christian Fellowship [EMAIL PROTECTED] http://matheteuo.org/ Free software is like God's love - you can share it with anyone anywhere anytime! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Controlling Where My Program Ends
On Wed, 15 Jun 2005 00:59:24 - "DC Parris" <[EMAIL PROTECTED]> wrote: > Never mind. I found it - sys.exit() > > Sorry to have wasted the bandwidth/time. > -- This was in reference to a post about exiting from a program. I couldn't figure out why my program wouldn't let me exit from within a sub-menu of the console interface. Since my webmail client goofed up the "from" header, it never showed up, and I've cancelled it to avoid wasting everyone's time further. I found sys.exit() in the library reference, which allows me to do what I want. Don -- evangelinuxGNU Evangelist http://matheteuo.org/ http://chaddb.sourceforge.net/ "Free software is like God's love - you can share it with anyone anytime anywhere." ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor