Re: [Tutor] working with strings in python3

2011-04-19 Thread Steven D'Aprano
Rance Hall wrote: Ok so I know what I am doing is deprecated (or at least poor form) but the replacement must be awkward cause I'm not getting it. [...] message = "Bah." if test: message = message + " Humbug!" It's not deprecated, nor is it poor form. However, it can be abused, or perhap

[Tutor] Type error: must be string or read-only character buffer, not seq

2011-04-19 Thread Kann Vearasilp
Dear all, I tried concatenating string variables with multiple strings and have the file handle write the statement into a file. I don't know why I always get the type error: must be string or read-only character buffer, not seq error. I tried casting the whole new concatenated string using str(),

Re: [Tutor] Type error: must be string or read-only character buffer, not seq

2011-04-19 Thread Luke Paireepinart
It's saying one of your variables is not a string. Is one of them a sequence? Perhaps Mir-seq? If so, you need to come up with a way to build a string from this object. You can call the str method and pass in your object or you can explicitly create a string from the data in the object. ---

[Tutor] Metaclass confusion...

2011-04-19 Thread Modulok
List, I've been messing with metaclasses. I thought I understood them until I ran into this. (See code below.) I was expecting the generated class, 'Foo' to have an 'x' class-level attribute, as forced upon it by the metaclass 'DracoMeta' at creation. Unfortunately, it doesn't and I don't know why

Re: [Tutor] working with strings in python3

2011-04-19 Thread Rance Hall
On Mon, Apr 18, 2011 at 9:50 PM, Marc Tompkins wrote: > On Mon, Apr 18, 2011 at 6:53 PM, Rance Hall wrote: > >> >> I'm going to go ahead and use this format even though it is deprecated >> and then later when we upgrade it I can fix it. >> > And there you have your answer. > >> A list might make

[Tutor] adding to PYTHONPATH

2011-04-19 Thread mes...@juno.com
How can I add a directory to PYTHONPATH? Using Ubuntu 10.04. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] adding to PYTHONPATH

2011-04-19 Thread Joel Goldstick
On Tue, Apr 19, 2011 at 9:49 AM, mes...@juno.com wrote: > How can I add a directory to PYTHONPATH? Using Ubuntu 10.04. > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listi

Re: [Tutor] working with strings in python3

2011-04-19 Thread Steve Willoughby
On 19-Apr-11 06:44, Rance Hall wrote: On Mon, Apr 18, 2011 at 9:50 PM, Marc Tompkins wrote: On Mon, Apr 18, 2011 at 6:53 PM, Rance Hall wrote: I think you misunderstood me, I simply meant that the print " ".join(message) has to parse through each word in order to get any output, I didn't me

Re: [Tutor] adding to PYTHONPATH

2011-04-19 Thread Steve Willoughby
On 19-Apr-11 06:49, mes...@juno.com wrote: How can I add a directory to PYTHONPATH? Using Ubuntu 10.04. That's an environment variable, so it depends on your shell. If PYTHONPATH already exists, you can add your directory to it (with colons between the names of directories). But you probab

[Tutor] win32com and python

2011-04-19 Thread Pierre Barthelemy
Hello, I would need to control a powerpoint file from python. I have installed the win32com library for python, then i used makepy to create a powerpoint-specific library. The things i need to do are pretty basic: open a file, create a new slide, place a picture and a comment to the picture. The

Re: [Tutor] Metaclass confusion...

2011-04-19 Thread Peter Otten
Modulok wrote: > List, > > I've been messing with metaclasses. I thought I understood them until I > ran into this. (See code below.) I was expecting the generated class, > 'Foo' to have an 'x' class-level attribute, as forced upon it by the > metaclass 'DracoMeta' at creation. Unfortunately, it

Re: [Tutor] Type error: must be string or read-only character buffer, not seq

2011-04-19 Thread Peter Otten
Kann Vearasilp wrote: > I tried concatenating string variables with multiple strings and have the > file handle write the statement into a file. I don't know why I always get > the type error: must be string or read-only character buffer, not seq > error. I tried casting the whole new concatenated

Re: [Tutor] win32com and python

2011-04-19 Thread Tim Golden
On 19/04/2011 15:53, Pierre Barthelemy wrote: The problem i have is that, often, while the script is running, the powerpoint file would already be open. In this case, my script would open it anew, and make the modifications in the newly opened file. To prevent that problem, i need to be able to l

Re: [Tutor] Type error: must be string or read-only character buffer, not seq

2011-04-19 Thread Kann Vearasilp
Thanks Peter, That just fixes my problem. : ) Kann On Tue, Apr 19, 2011 at 5:29 PM, Peter Otten <__pete...@web.de> wrote: > Kann Vearasilp wrote: > >> I tried concatenating string variables with multiple strings and have the >> file handle write the statement into a file. I don't know why I alwa

[Tutor] Fwd: working with strings in python3

2011-04-19 Thread Marc Tompkins
Forgot to send to group. Grrr. -- Forwarded message -- From: Marc Tompkins Date: Tue, Apr 19, 2011 at 10:01 AM Subject: Re: [Tutor] working with strings in python3 To: Rance Hall On Tue, Apr 19, 2011 at 6:44 AM, Rance Hall wrote: > > Bottom line: Python is not BASIC. In BA

Re: [Tutor] working with strings in python3

2011-04-19 Thread Steven D'Aprano
Rance Hall wrote: On Mon, Apr 18, 2011 at 9:50 PM, Marc Tompkins wrote: On Mon, Apr 18, 2011 at 6:53 PM, Rance Hall wrote: I'm going to go ahead and use this format even though it is deprecated and then later when we upgrade it I can fix it. And there you have your answer. A list might m

[Tutor] Variables and constants [was Re: working with strings in python3]

2011-04-19 Thread Steven D'Aprano
Rance Hall wrote: Variables are variable, that's why we call them variable. Constants are constant, and that's why we call them constant. And Python has neither variables nor constants in the sense that (say) Pascal, C or Fortran have, even though we often use the same words. The difference

[Tutor] wxPython parent classes

2011-04-19 Thread Eric Stevens
I've been noticing that in all the example codes I have seen, when someone creates container, x, inside of a frame or other container class, y, they always seem to create an instance of wx.Panel first and then use that instance as the parent class of container x. I have been just placing 'self' in

Re: [Tutor] wxPython parent classes

2011-04-19 Thread Mark Weil
wx.Panel provides better cross-platform reliability, so it's fairly standard practice to go with a Panel in a Frame, and place the buttons, etc. on the panel. On Tue, Apr 19, 2011 at 11:59 AM, Eric Stevens wrote: > I've been noticing that in all the example codes I have seen, when someone > cre

Re: [Tutor] Variables and constants [was Re: working with strings inpython3]

2011-04-19 Thread bodsda
And presumably cleans up the leftover object with the value of 42 when it changes to point at the 43 object? Or does it leave all changes in memory until the program exits? Bodsda. Sorry for top posting, my phone won't let me change it Sent from my BlackBerry® wireless device -Original Me

Re: [Tutor] Variables and constants [was Re: working with strings inpython3]

2011-04-19 Thread Joel Goldstick
On Tue, Apr 19, 2011 at 3:32 PM, wrote: > And presumably cleans up the leftover object with the value of 42 when it > changes to point at the 43 object? > > Or does it leave all changes in memory until the program exits? > > Bodsda. > Sorry for top posting, my phone won't let me change it > Sent

Re: [Tutor] working with strings in python3

2011-04-19 Thread Alan Gauld
"Rance Hall" wrote Ok so I know what I am doing is deprecated I'm not aware of string concatenation being deprecated. Ols string formatting is deprecated in the sense that the new string format() method will replace it, but I don't even expect to see that any time soon - too much old code use

Re: [Tutor] Variables and constants [was Re: working with strings inpython3]

2011-04-19 Thread Marc Tompkins
On Tue, Apr 19, 2011 at 2:37 PM, Joel Goldstick wrote: > > On Tue, Apr 19, 2011 at 3:32 PM, wrote: > >> And presumably cleans up the leftover object with the value of 42 when it >> changes to point at the 43 object? >> >> Or does it leave all changes in memory until the program exits? >> > > If a

Re: [Tutor] working with strings in python3

2011-04-19 Thread Alan Gauld
"Rance Hall" wrote String formatting doesn't work for me in this case as the message is sort of dynamic. I don;t understand that, string formatting is probably the most dynamic way of constructing strings there is, its designed for dynamic data! If your data is really dynamic the only two wa

Re: [Tutor] working with strings in python3

2011-04-19 Thread Alan Gauld
"Rance Hall" wrote Variables are variable, that's why we call them variable. Yes, but Programming variables(*) are variable in the sense that they can represent different values over time. That is not the same as requiring the values themselves to change. The idea of immutable strings var

Re: [Tutor] wxPython parent classes

2011-04-19 Thread Alan Gauld
"Eric Stevens" wrote I've been noticing that in all the example codes I have seen, when someone creates container, x, inside of a frame or other container class, y, they always seem to create an instance of wx.Panel first You got an answer this time, but you will probably get better result

Re: [Tutor] Variables and constants [was Re: working with strings inpython3]

2011-04-19 Thread Steven D'Aprano
Joel Goldstick wrote: If a value has no name bound to it, python figures that out and destroys it Not quite... if there is no name, or any other reference, then the garbage collector will destroy it. But it doesn't have to be a name: anonymous objects can live inside lists, or dicts, or sets

Re: [Tutor] Variables and constants [was Re: working with strings inpython3]

2011-04-19 Thread Steven D'Aprano
bod...@googlemail.com wrote: And presumably cleans up the leftover object with the value of 42 when it changes to point at the 43 object? In principle, yes, the garbage collector will destroy the no-longer used object 42 once nothing is pointing to it any more. But in practice, Python cache