Re: Why doesn't this work

2014-09-02 Thread Seymore4Head
On Tue, 02 Sep 2014 16:13:39 -0400, Seymore4Head wrote: >I still can't get the syntax >test='Hey buddy get away from my car' >if test[0].alpha(): >return True I have a huge head cold right now. Never mind the question. Sorry -- https://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't this work

2014-09-02 Thread Skip Montanaro
On Tue, Sep 2, 2014 at 3:13 PM, Seymore4Head wrote: > I still can't get the syntax > test='Hey buddy get away from my car' > if test[0].alpha(): > return True > My guess is you meant isalpha(), as Mark indicated. Here's a cheap way to see what an object can do: >>> test='Hey buddy get away

Re: Why doesn't this work

2014-09-02 Thread Mark Lawrence
On 02/09/2014 21:13, Seymore4Head wrote: I still can't get the syntax test='Hey buddy get away from my car' if test[0].alpha(): return True isalpha? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.p

Re: Why doesn't this work

2014-09-02 Thread Chris Angelico
ou. As to the actual check, that's isalpha(), not alpha(), as you can see from the docs. Suggestion: Choose subject lines that reflect the subject matter being discussed. "Why doesn't this work" isn't very helpful. :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't this work

2014-09-02 Thread Ned Batchelder
On 9/2/14 4:13 PM, Seymore4Head wrote: I still can't get the syntax test='Hey buddy get away from my car' if test[0].alpha(): return True A really good skill to learn early on is how to ask for help. You need to tell us what you expected it to do, and also what it did that displeased y

Why doesn't this work

2014-09-02 Thread Seymore4Head
I still can't get the syntax test='Hey buddy get away from my car' if test[0].alpha(): return True -- https://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't this work ? For loop variable scoping ?

2009-03-20 Thread Gabriel Genellina
En Thu, 19 Mar 2009 19:33:36 -0300, Ryan Kelly escribió: newCylinderTempertature = newCylinderTemperature + deltaTemp Take a careful look at the variable name here: "Tempertature". Python's dynamic nature provides a lot of wonderful benefits, but you've just hit one of the drawbacks

Re: Why doesn't this work ? For loop variable scoping ?

2009-03-19 Thread Aahz
In article , Linuxguy123 wrote: > >I've got a small piece of code that I don't understand. Basically, a >variable inside an if statement inside a for loop doesn't seem to be >updating. Is this a scope issue ? Nope, it's a spelling issue. I suggest you change your code to a more readable: new

Re: Why doesn't this work ? For loop variable scoping ?

2009-03-19 Thread Benjamin Peterson
Linuxguy123 gmail.com> writes: > > > Hi people. > > I've got a small piece of code that I don't understand. Basically, a > variable inside an if statement inside a for loop doesn't seem to be > updating. Is this a scope issue ? No, it's because you mispelled the variables. -- http://ma

Re: Why doesn't this work ? For loop variable scoping ?

2009-03-19 Thread Ryan Kelly
> newCylinderTempertature = newCylinderTemperature + deltaTemp Take a careful look at the variable name here: "Tempertature". Python's dynamic nature provides a lot of wonderful benefits, but you've just hit one of the drawbacks - you don't get any protection from typos in variable names.

Why doesn't this work ? For loop variable scoping ?

2009-03-19 Thread Linuxguy123
Hi people. I've got a small piece of code that I don't understand. Basically, a variable inside an if statement inside a for loop doesn't seem to be updating. Is this a scope issue ? Thanks Code segment: # run through the cycle and calculate the temperature and pressure at each position,

Re: Why doesn't this work in Eclipse ? (Simple pexpect code that works in bash)

2009-01-30 Thread Gary Duzan
On Jan 30, 11:03 am, Linuxguy123 wrote: > I'm trying to build a small Python app in Eclipse under Fedora 10. > > I have the following code: > > import os > import sys > import pexpect > > child = pexpect.spawn('/bin/bash') > child.interact() > > When I run it in Eclipse, I get: > > Traceback (most

Why doesn't this work in Eclipse ? (Simple pexpect code that works in bash)

2009-01-30 Thread Linuxguy123
I'm trying to build a small Python app in Eclipse under Fedora 10. I have the following code: import os import sys import pexpect child = pexpect.spawn('/bin/bash') child.interact() When I run it in Eclipse, I get: Traceback (most recent call last): File "/home/xxx/workspace/FixPermissions/s

Re: Newbie: Why doesn't this work

2008-01-01 Thread Gabriel Genellina
En Wed, 02 Jan 2008 01:11:12 -0300, <[EMAIL PROTECTED]> escribió: > I am trying to experiment a little bit with new-style class and I am > confused why following example always returns 0 (zero). I was > expecting will return values from 0 to 9 and finaly > an Exception. > > class GenExample(objec

Re: Newbie: Why doesn't this work

2008-01-01 Thread petr . jakes . tpc
Steven, thanks for a nice explanation. I am trying to experiment a little bit with new-style class and I am confused why following example always returns 0 (zero). I was expecting will return values from 0 to 9 and finaly an Exception. class GenExample(object): def getInfo(self): fo

Re: Newbie: Why doesn't this work

2008-01-01 Thread Steven D'Aprano
On Tue, 01 Jan 2008 13:01:24 -0800, petr.jakes.tpc wrote: >> > My question is: is it possible to set the "property" for any >> > attribute when I do not know what will be the name of the attribute >> > in the future? >> >> Uhm... I don't understand the question. Perhaps if you think of a >> concre

Re: Newbie: Why doesn't this work

2008-01-01 Thread petr . jakes . tpc
> > My question is: is it possible to set the "property" for any attribute > > when I do not know what will be the name of the attribute in the > > future? > > Uhm... I don't understand the question. Perhaps if you think of a concrete > case...? Thanks for reply, few minutes after i posted my que

Re: Newbie: Why doesn't this work

2008-01-01 Thread Gabriel Genellina
En Tue, 01 Jan 2008 16:57:41 -0200, <[EMAIL PROTECTED]> escribi�: > Gabriel, if I understand it properly, it is necessary to define get/ > set/del/doc methods for each attribute for which I want to set the > "property" data descriptor (which triggers get/set/del/doc function > calls upon access to

Re: Newbie: Why doesn't this work

2008-01-01 Thread petr . jakes . tpc
Hi all, I am trying to understand new-style classes in Python and I have found your postings here. Gabriel, if I understand it properly, it is necessary to define get/ set/del/doc methods for each attribute for which I want to set the "property" data descriptor (which triggers get/set/del/doc fun

Re: Newbie: Why doesn't this work

2007-12-31 Thread Gabriel Genellina
En Mon, 31 Dec 2007 16:01:38 -0200, <[EMAIL PROTECTED]> escribi�: > Thanks you Gabriel and Timm for your thoughtful responses. I am very > appreciative. > > I had heard about the properties function, but wanted to understand > the old syntax first before I tried that. Thanks to your responses, I

Re: Newbie: Why doesn't this work

2007-12-31 Thread Jeff McNeil
I didn't actually answer your question, my apologies! The reason you're failing is due to your use of the __setattr__ call. Remember, when you override __setattr__, you need to handle *all* of the logic behind setting object attributes. You're only attempting to do so when handling the 'name' pro

Re: Newbie: Why doesn't this work

2007-12-31 Thread ct60
Thanks you Gabriel and Timm for your thoughtful responses. I am very appreciative. I had heard about the properties function, but wanted to understand the old syntax first before I tried that. Thanks to your responses, I was able to see what the problem was. Here is a solution I came up with:

Re: Newbie: Why doesn't this work

2007-12-31 Thread Tim Chase
A couple items of note: > class Person: This should be "class Person(object)" to take advantage of some of the features that new-style classes offer...particularly in this case. > def __init__(self, fName="", lName=""): > self.__fName = fName > self.__lName = lName > > d

Re: Newbie: Why doesn't this work

2007-12-31 Thread Gabriel Genellina
En Mon, 31 Dec 2007 14:56:02 -0200, <[EMAIL PROTECTED]> escribi�: > Hi Python Community: > > Despite my new-ness to Python I have alreadhy been able to do some (I > think) amazing things. It is a truly elegant and smart language. > > Yet, I can not seem to get a handle on something simple. > > I

Re: Newbie: Why doesn't this work

2007-12-31 Thread Jeff McNeil
Perhaps you'd be better off using a standard property? Within your Person class, you can define a property 'name' to handle what you're trying to do: Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type "copyright", "credits" or "license()" for

Newbie: Why doesn't this work

2007-12-31 Thread ct60
Hi Python Community: Despite my new-ness to Python I have alreadhy been able to do some (I think) amazing things. It is a truly elegant and smart language. Yet, I can not seem to get a handle on something simple. I would like to make a class which has private varaiables fName and lName. It sh

Re: Why doesn't this work?

2006-10-21 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Larry Bates <[EMAIL PROTECTED]> wrote: > Because datetime is a new-style class: Ah. > The Constructor __new__ > > If you are like me, then you probably always thought of the __init__ method > as > the Python equivalent of what is called a constructor in C++. Th

Re: Why doesn't this work?

2006-10-21 Thread Larry Bates
Because datetime is a new-style class: The Constructor __new__ If you are like me, then you probably always thought of the __init__ method as the Python equivalent of what is called a constructor in C++. This isn't the whole story. When an instance of a class is created, Python first calls the _

Why doesn't this work?

2006-10-21 Thread Ron Garret
Python 2.3.5 (#1, Jan 30 2006, 13:30:29) [GCC 3.3 20030304 (Apple Computer, Inc. build 1819)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from datetime import datetime >>> class ts(datetime): ... def __init__(self): pass ... >>> ts() Traceback (most rece

Re: Why doesn't this work--Extending Python--?

2006-01-04 Thread jeremito
Well what do you know, that worked! It's one of those errors that you can't see yourself, but someone else can see it instantly. Thanks, Jeremy -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't this work--Extending Python--?

2006-01-04 Thread Todd
jeremito wrote: > I have written a simple C++ program in my efforts to learn how to > extend Python. It is shown below. Everything compiles and installs > correctly, but I get strange answers. I know the function "Pi" is > correct because when I call it from a C++ code it gives the correct > ans

Why doesn't this work--Extending Python--?

2006-01-04 Thread jeremito
I have written a simple C++ program in my efforts to learn how to extend Python. It is shown below. Everything compiles and installs correctly, but I get strange answers. I know the function "Pi" is correct because when I call it from a C++ code it gives the correct answers. This is what I get

Re: Why doesn't this work? :)

2005-10-28 Thread Alex Martelli
Jeremy Moles <[EMAIL PROTECTED]> wrote: > Am I misunderstanding something fundamental about the builtin __* > functions? Can they not be "static?" They can and must be static when their specification say they are (e.g., __new__) and they cannot and must not be static when their specification says

Re: Why doesn't this work? :)

2005-10-28 Thread Jeremy Moles
On Fri, 2005-10-28 at 14:50 -0400, Chris Lambacher wrote: > I think what you really want is: > > try: > # this will fail and be caught > # below, w > import foobar > > except ImportError, error: > class foobarclass: > def __getattr__(*args, **kargs): >

Re: Why doesn't this work? :)

2005-10-28 Thread Chris Lambacher
I think what you really want is: try: # this will fail and be caught # below, w import foobar except ImportError, error: class foobarclass: def __getattr__(*args, **kargs): return None foobar = foobarclass() print fo

Why doesn't this work? :)

2005-10-28 Thread Jeremy Moles
Jumping right into the code (which should speak for itself): # --- try: # this will fail and be caught # below, w import foobar except ImportError, error: class foobar: @staticmethod def __getattr

Re: (noob alert) why doesn't this work?

2005-03-22 Thread Stephen Thorne
On Tue, 22 Mar 2005 12:10:50 +0100, Bouke Woudstra <[EMAIL PROTECTED]> wrote: > for flac in flacfiles: > cmd = 'metaflac --export-tags=- "%s"' % flac > for line in os.popen(cmd).readlines(): > if 'Artist

Re: (noob alert) why doesn't this work?

2005-03-22 Thread Bengt Richter
On Tue, 22 Mar 2005 09:21:49 -0800, Scott David Daniels <[EMAIL PROTECTED]> wrote: >Bouke Woudstra wrote: >> It turned out that some flac files have tags like Artist=artistname and >> others >> have artist=artistname. Therefore it couldn't find the artist! So now I just >> look for 'rtist=' wh

Re: (noob alert) why doesn't this work?

2005-03-22 Thread Scott David Daniels
Bouke Woudstra wrote: It turned out that some flac files have tags like Artist=artistname and others have artist=artistname. Therefore it couldn't find the artist! So now I just look for 'rtist=' which works great. You might want try using something like this: wanted = set('artist album date

Re: (noob alert) why doesn't this work?

2005-03-22 Thread Bouke Woudstra
Thanks for all suggestions. Your first point I knew, but was too lazy to type it. It made no difference for the test files had all tags. Knowing that it was not a asynchrous thing helped me a lot though. There had to be something wrong with the command line for metaflac. It turned out that som

Re: (noob alert) why doesn't this work?

2005-03-22 Thread Diez B. Roggisch
> > The error thrown is: UnboundLocalError: local variable 'title' referenced > before assignment That should be pretty obvious: The UnboundLocalError comes up when you try to access a variable that hasn't been assigned a value before. E.g try this in an interactive python session: foo = "hello"

Re: (noob alert) why doesn't this work?

2005-03-22 Thread Simon Brunning
On Tue, 22 Mar 2005 12:10:50 +0100, Bouke Woudstra <[EMAIL PROTECTED]> wrote: > Hi, > > I'm a bit stuck with this python script. It's aim is to encode all flac files > to wav and then to mp3. The only problem I have is to preserve the tags. The > code works when there's just one flac file in a dir

(noob alert) why doesn't this work?

2005-03-22 Thread Bouke Woudstra
Hi, I'm a bit stuck with this python script. It's aim is to encode all flac files to wav and then to mp3. The only problem I have is to preserve the tags. The code works when there's just one flac file in a directory but fails for more. I can't see why the for loop fails here (flactags). The