[Tutor] Unexpected iterator

2009-11-12 Thread Jeff R. Allen
Hello, I am working my way through the tutorial, and I like trying variations, just to see what expected errors look like, and other ways things could be written. I tried a, b = 0, 0 and that worked. Then I tried this to (maybe) set both a and b to 0: >>> a, b = 0 Traceback (most recent call la

Re: [Tutor] moving directories into directories

2009-11-12 Thread Alan Gauld
"Christopher Spears" wrote I'm trying to move a bunch of files and directories into another directory. Unfortunately, I keep getting an error message: OSError: [Errno 17] File exists: './TAPE_ARCHIVES' The problem seems to happen when I try to move a directory into another directory: I

Re: [Tutor] Unexpected iterator

2009-11-12 Thread Patrick Sabin
Jeff R. Allen wrote: a, b = 0 Traceback (most recent call last): File "", line 1, in TypeError: 'int' object is not iterable I understand why it doesn't work, but I don't understand the wording of the exception. Could someone explain how I accidentally introduced iteration into the picture

[Tutor] How to call a method with a print statement?

2009-11-12 Thread Modulok
List, How do I get a print statement to call a class method? I'm using python 2.5. I did it long ago, but can't remember how, or even where I learned it from. Something like: class Foo(): def __init__(self): pass def ***part I can't remember goes here*** print "hello world!"

Re: [Tutor] os.environ question

2009-11-12 Thread Alan Plum
Ahoy! On Do, 2009-11-12 at 06:34 +0300, Khalid Al-Ghamdi wrote: > can anyone tell me why on python 2.6 i can enter os.environ and then > get all the items that that pertain to the os while on python 3 you > just get the following: > > with no items? Seems like os.environ has changed a little si

Re: [Tutor] Unexpected iterator

2009-11-12 Thread Sander Sweers
2009/11/12 Jeff R. Allen : > Then I tried this to (maybe) set both a and b to 0: > a, b = 0 > Traceback (most recent call last): >  File "", line 1, in > TypeError: 'int' object is not iterable I think you are looking for. >>> a = b = c = 300 Greets Sander _

Re: [Tutor] How to call a method with a print statement?

2009-11-12 Thread Kent Johnson
On Thu, Nov 12, 2009 at 5:31 AM, Modulok wrote: > List, > > How do I get a print statement to call a class method? I'm using > python 2.5. I did it long ago, but can't remember how, or even where I > learned it from. Something like: > > class Foo(): >   def __init__(self): >      pass > >   def  *

Re: [Tutor] How to call a method with a print statement?

2009-11-12 Thread Jeff R. Allen
You are looking for the __str__ method. See http://docs.python.org/reference/datamodel.html#object.__str__ class Foo():   def __init__(self):      pass   def  __str__(self)      return "hello world!" -jeff ___ Tutor maillist - Tutor@python.org To u

Re: [Tutor] How to call a method with a print statement?

2009-11-12 Thread Luke Paireepinart
On Thu, Nov 12, 2009 at 5:29 AM, Jeff R. Allen wrote: > You are looking for the __str__ method. See > http://docs.python.org/reference/datamodel.html#object.__str__ > > Can't you also implement __repr__? (bottom-posted for Dave) -Luke ___ Tutor maillis

Re: [Tutor] os.environ question

2009-11-12 Thread Kent Johnson
On Wed, Nov 11, 2009 at 10:34 PM, Khalid Al-Ghamdi wrote: > hi, > can anyone tell me why on python 2.6 i can enter os.environ and then get all > the items that that pertain to the os while on python 3 you just get the > following: > > with no items? I think this is perhaps an oversight in Python

Re: [Tutor] How to call a method with a print statement?

2009-11-12 Thread Kent Johnson
On Thu, Nov 12, 2009 at 6:35 AM, Luke Paireepinart wrote: > > > On Thu, Nov 12, 2009 at 5:29 AM, Jeff R. Allen wrote: >> >> You are looking for the __str__ method. See >> http://docs.python.org/reference/datamodel.html#object.__str__ >> > Can't you also implement __repr__? Yes, in fact if you ar

Re: [Tutor] How to call a method with a print statement?

2009-11-12 Thread Wayne Werner
On Thu, Nov 12, 2009 at 6:00 AM, Kent Johnson wrote: > > > Defining __repr__ will give the custom representation when you just > give the name of the object: > > In [5]: class Foo2(): > ...: def __repr__(self): > ...: return "I'm a Foo2" > ...: > ...: > > In [6]: f2=Foo2() >

[Tutor] importing variables

2009-11-12 Thread Stefan Lesicnik
Hi guys, Im trying to do something and hit a bit of a wall, potentially im going about this the wrong way. Essentially the problem is: features file contains rt='''text''' import features a = 'rt' print features.rt #this works print features.a #this fails I need to use features.a as i am ite

Re: [Tutor] importing variables

2009-11-12 Thread Alan Gauld
"Stefan Lesicnik" wrote features file contains rt='''text''' import features a = 'rt' print features.rt #this works print features.a #this fails Because you defined a in your current file. You need to define it in features. I need to use features.a as i am iterating through a list and

Re: [Tutor] importing variables

2009-11-12 Thread Stefan Lesicnik
On Thu, Nov 12, 2009 at 4:38 PM, Alan Gauld wrote: > > "Stefan Lesicnik" wrote > >> features file contains >> rt='''text''' >> >> import features >> >> a = 'rt' >> print features.rt  #this works >> print features.a  #this fails > > Because you defined a in your current file. > You need to define

Re: [Tutor] Unexpected iterator

2009-11-12 Thread Dave Angel
Jeff R. Allen wrote: Hello, I am working my way through the tutorial, and I like trying variations, just to see what expected errors look like, and other ways things could be written. I tried a, b = 0, 0 and that worked. Then I tried this to (maybe) set both a and b to 0: a, b = 0

Re: [Tutor] How to call a method with a print statement?

2009-11-12 Thread Dave Angel
Kent Johnson wrote: On Thu, Nov 12, 2009 at 6:35 AM, Luke Paireepinart wrote: On Thu, Nov 12, 2009 at 5:29 AM, Jeff R. Allen wrote: You are looking for the __str__ method. See http://docs.python.org/reference/datamodel.html#object.__str__ Can't you also implement __repr__?

Re: [Tutor] importing variables

2009-11-12 Thread bob gailer
Stefan Lesicnik wrote: Hi guys, Im trying to do something and hit a bit of a wall, potentially im going about this the wrong way. Essentially the problem is: features file contains rt='''text''' import features a = 'rt' print features.rt #this works print features.a #this fails I need to u

Re: [Tutor] importing variables

2009-11-12 Thread Stefan Lesicnik
On Thu, Nov 12, 2009 at 6:26 PM, bob gailer wrote: > Stefan Lesicnik wrote: >> >> Hi guys, >> >> Im trying to do something and hit a bit of a wall, potentially im >> going about this the wrong way. Essentially the problem is: >> >> features file contains >> rt='''text''' >> >> import features >> >

Re: [Tutor] django python Version 1.1.1 - Internacionalization

2009-11-12 Thread andré palma
On Thu, 2009-11-12 at 00:05 -0600, Wayne Werner wrote: > > > On Wed, Nov 11, 2009 at 10:10 PM, andré palma > wrote: > Hi all! > I'm developing a django web application but i'm having a > trouble with > the internationalization. > > > I don't know much about D

Re: [Tutor] importing variables

2009-11-12 Thread Alan Gauld
"bob gailer" wrote I need to use features.a as i am iterating through a list and a would be the different features i want to check if they exist, and then use the variable. I hope that makes sense, or if anyone has any suggestion on how properly to do this! Even though Alan missed your poin

Re: [Tutor] importing variables

2009-11-12 Thread Dave Angel
Stefan Lesicnik wrote: On Thu, Nov 12, 2009 at 6:26 PM, bob gailer wrote: Stefan Lesicnik wrote: Hi guys, Im trying to do something and hit a bit of a wall, potentially im going about this the wrong way. Essentially the problem is: features file contains rt='text''' import features

[Tutor] COM server: cannot assign property

2009-11-12 Thread Yashwin Kanchan
Hi Guys I am trying to create a simple test COM server , but am have trouble assigning any property value to it through excel VBA. Please point out where i am going wrong. #COM server class test(object): _reg_clsid_ = "{B5901450-F9A1-4F76-8FCF-2BFFA96ED210}" _reg_progid_ = "Python.Test

Re: [Tutor] COM server: cannot assign property

2009-11-12 Thread Alan Gauld
"Yashwin Kanchan" wrote I am trying to create a simple test COM server , but am have trouble assigning any property value to it through excel VBA. I've never tried using properties via COM. Does it work if you disable the property aspect and expose the set/get methods directly? Can you access