Re: Why doesn't os.remove work on directories?

2015-12-24 Thread Laurent Delacroix
On 23/12/15 05:29, Random832 wrote: > > This is surprising to anyone accustomed to the POSIX C remove > function, which can remove either files or directories. Is there > any known rationale for this decision? > Hello, in POSIX C the remove() function is actually rmdir() when called on a

Re: Why doesn't os.remove work on directories?

2015-12-23 Thread eryk sun
On Tue, Dec 22, 2015 at 10:29 PM, Random832 wrote: > > This is surprising to anyone accustomed to the POSIX C remove > function, which can remove either files or directories. Is there > any known rationale for this decision? Guido added os.remove as a synonym for

Why doesn't os.remove work on directories?

2015-12-22 Thread Random832
This is surprising to anyone accustomed to the POSIX C remove function, which can remove either files or directories. Is there any known rationale for this decision? -- https://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't os.remove work on directories?

2015-12-22 Thread Ben Finney
Random832 writes: > This is surprising to anyone accustomed to the POSIX C remove > function, which can remove either files or directories. Is there > any known rationale for this decision? No, I don't know a rationale for implementing it this way. I expect the

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

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

Re: Why doesn't this work

2014-09-02 Thread Chris Angelico
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 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 --

Re: Why doesn't this work

2014-09-02 Thread Skip Montanaro
On Tue, Sep 2, 2014 at 3:13 PM, Seymore4Head Seymore4Head@hotmail.invalid 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:

Re: Why doesn't this work

2014-09-02 Thread Seymore4Head
On Tue, 02 Sep 2014 16:13:39 -0400, Seymore4Head Seymore4Head@Hotmail.invalid 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 --

.pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread Philipp Hagemeister
Where is the fault in my reasoning here? 1) According to http://docs.python.org/dev/install/, The most convenient way is to add a path configuration file to a directory that’s already on Python’s path, (...). 2) Path configuration files have an extension of .pth, (...) 12 = 3) A file test.pth

Re: .pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread David Lyon
On Mon, 18 May 2009 11:49:15 +0200, Philipp Hagemeister phi...@phihag.de wrote: 1) According to http://docs.python.org/dev/install/, The most convenient way is to add a path configuration file to a directory that’s already on Python’s path, (...). It's true... 2) Path configuration files

Re: .pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread Christian Heimes
Philipp Hagemeister schrieb: Where is the fault in my reasoning here? Python processes .pth files only in some directories. The directories are * the global site-packages directory * the user site-packages directory (starting with Python 2.6) * and any directory that is added by a .pth file

Re: .pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread Philipp Hagemeister
David Lyon wrote: (...) 12 = 3) A file test.pth with the content /example/ should result in sys.path containing /example/. No. Python, once finding the .pth will process it. Yes, but that processing will add /example/ to sys.path, right? 4) (the current directory) is the first element

Re: .pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread David Lyon
On Mon, 18 May 2009 14:34:33 +0200, Philipp Hagemeister phi...@phihag.de wrote: Yes, but that processing will add /example/ to sys.path, right? It actually works the other way around. The directories listed in sys.path are scanned for .pth files. You can add packages by listing them inside a

Re: .pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread Tim Golden
David Lyon wrote: On Mon, 18 May 2009 14:34:33 +0200, Philipp Hagemeister phi...@phihag.de wrote: Yes, but that processing will add /example/ to sys.path, right? It actually works the other way around. The directories listed in sys.path are scanned for .pth files. You can add packages by

Re: .pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread Philipp Hagemeister
David Lyon wrote: On Mon, 18 May 2009 14:34:33 +0200, Philipp Hagemeister phi...@phihag.de wrote: Yes, but that processing will add /example/ to sys.path, right? It actually works the other way around. The directories listed in sys.path are scanned for .pth files. No, they are not. That's

Re: .pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread David Lyon
On Mon, 18 May 2009 14:05:50 +0100, Tim Golden m...@timgolden.me.uk wrote: According to http://docs.python.org/install/index.html and my own reasonably long experience of them, they're just a way of getting extra paths into sys.path. Well, fair enough... The docs referred to above do

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 r...@rfk.id.au 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

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: snip # run through the cycle and calculate the temperature and pressure at each

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.

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

2009-03-19 Thread Benjamin Peterson
Linuxguy123 linuxguy123 at 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. --

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

2009-03-19 Thread Aahz
In article mailman.2240.1237501716.11746.python-l...@python.org, Linuxguy123 linuxguy...@gmail.com 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

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

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 linuxguy...@gmail.com 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:

Re: Why doesn't import work?

2008-08-06 Thread alex23
On Aug 5, 8:34 am, ssecorp [EMAIL PROTECTED] wrote: I have in Lib/site-packages a module named pdfminer. when I do import pdfminer it complains: so I apparently can't import a directory pdfminer. In the directory pdfminer there are 3 other directoriees and inside them python-files. Are the 3

Re: Why doesn't import work?

2008-08-05 Thread Alan Franzoni
ssecorp was kind enough to say: I have in Lib/site-packages a module named pdfminer. when I do import pdfminer it complains: import pdfminer If you've got a directory, that's not a module - it's a package. In order to import a directory as a package, you must create a (possibly empty)

Why doesn't import work?

2008-08-04 Thread ssecorp
I have in Lib/site-packages a module named pdfminer. when I do import pdfminer it complains: import pdfminer Traceback (most recent call last): File pyshell#3, line 1, in module import pdfminer ImportError: No module named pdfminer I created a file pdfminer.py and put it in

Re: Why doesn't import work?

2008-08-04 Thread Sean DiZazzo
On Aug 4, 3:34 pm, ssecorp [EMAIL PROTECTED] wrote: I have in Lib/site-packages a module named pdfminer. when I do import pdfminer it complains: import pdfminer Traceback (most recent call last):   File pyshell#3, line 1, in module     import pdfminer ImportError: No module named

Re: Why doesn't import work?

2008-08-04 Thread Timothy Grant
On Mon, Aug 4, 2008 at 3:34 PM, ssecorp [EMAIL PROTECTED] wrote: I have in Lib/site-packages a module named pdfminer. when I do import pdfminer it complains: import pdfminer Traceback (most recent call last): File pyshell#3, line 1, in module import pdfminer ImportError: No module

Re: Why doesn't import work?

2008-08-04 Thread Benjamin Kaplan
On Mon, Aug 4, 2008 at 6:40 PM, Sean DiZazzo [EMAIL PROTECTED] wrote: On Aug 4, 3:34 pm, ssecorp [EMAIL PROTECTED] wrote: I have in Lib/site-packages a module named pdfminer. when I do import pdfminer it complains: import pdfminer Traceback (most recent call last): File

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

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
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 question, I

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 concrete case...?

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 generator object will return values from 0 to 9 and finaly an Exception. class GenExample(object): def

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 generator object will return values from 0 to 9 and finaly an Exception. class

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

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 more

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 would

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 def

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 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'

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 was

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 recent call last):

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

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++. This isn't

Re: why doesn't is work?a script to backup a directory

2006-04-02 Thread Fredrik Lundh
I wrote: WindowsError: [Errno 3] : 'O:/eb/mb/S/*.*' shutil.rmtree() expects a directory name, not a file pattern. if you leave out the *.* part at the end, it should do what you want. postscript: typically enough, I stumbled upon the same error message myself, a day later. looks like it's

Re: why doesn't is work?a script to backup a directory

2006-04-01 Thread Steven D'Aprano
On Fri, 31 Mar 2006 18:37:11 -0800, obeeker wrote: there is threee directories,one of these is used for the base directory,decided by the user, default is d0 [snip code] It doesn't work? Have you tried running it to see what it does? When you do, please post a description of what it does,

Re: why doesn't is work?a script to backup a directory

2006-04-01 Thread obeeker
thank you for your suggestion and apologize for my mistake. if i run it and answer the raw_input with Enter i get sth is wrong press Return i comment the try-except and run it and answer the raw_input with Enter and get message following: Traceback (most recent call last): File

Re: why doesn't is work?a script to backup a directory

2006-04-01 Thread obeeker
please don't read the prevous post ,please read this one: thank you for your suggestion and apologize for my mistake. if i run it and answer the raw_input with Enter i get sth is wrong press Return i comment the try-except and run it and answer the raw_input with Enter and get message

Re: why doesn't is work?a script to backup a directory

2006-04-01 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: please don't read the prevous post ,please read this one: thank you for your suggestion and apologize for my mistake. if i run it and answer the raw_input with Enter i get sth is wrong press Return i comment the try-except and run it and answer the raw_input with

Re: why doesn't is work?a script to backup a directory

2006-04-01 Thread obeeker
i am very sorry . the erroer was from my Portable Hard Disk because its disk sign has changed from o to h ,from p to i i'm very sorry -- http://mail.python.org/mailman/listinfo/python-list

why doesn't is work?a script to backup a directory

2006-03-31 Thread obeeker
there is threee directories,one of these is used for the base directory,decided by the user, default is d0 import shutil #the three directories d0='D:/Program Files/eb/mb/S' d1='O:/eb/mb/S' d2='P:/S/eb/mb/S' #to backup def update(base): l=[d0,d1,d2] l.remove(base) for

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--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 answers.

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

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

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

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 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

(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

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 directory

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 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

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 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=' which works

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' in