Re: Why did Quora choose Python for its development?

2011-05-24 Thread Octavian Rasnita

From: "Stefan Behnel" 

Beliavsky, 20.05.2011 18:39:

I thought this essay on why one startup chose Python was interesting.


Since everyone seems to be hot flaming at their pet languages in this 
thread, let me quickly say this:


Thanks for sharing the link.



Maybe I have missed a message, but if I didn't, please provide that link.
I am always interested to find the best solutions.

Thanks.

Octavian

--
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Chris Angelico
On Tue, May 24, 2011 at 6:10 PM, Octavian Rasnita  wrote:
> From: "Stefan Behnel" 
>>
>> Beliavsky, 20.05.2011 18:39:
>>>
>>> I thought this essay on why one startup chose Python was interesting.
>>
>> Since everyone seems to be hot flaming at their pet languages in this
>> thread, let me quickly say this:
>>
>> Thanks for sharing the link.
>
>
> Maybe I have missed a message, but if I didn't, please provide that link.
> I am always interested to find the best solutions.

At the beginning of the thread, three days and forty-odd messages ago,
this was posted:

http://www.quora.com/Why-did-Quora-choose-Python-for-its-development

It's the reason for the thread title, regardless of the current thread
content :)

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


NEED HELP- read file contents, while loop to accept user input, and enter to exit

2011-05-24 Thread Cathy James
dear mentor,

I need help with my code:
1) my program won't display file contents upon opening
2) my program is not writing to file
3) my program is not closing when user presses enter- gow do I do this with
a while loop?

please see my attempt below and help:

#1) open file and display current file contents:
f = open ('c:/testing.txt'', 'r')
f.readlines()
#2)  and 3) use while loop  to write user input to file, save to file, close
when press enter:
while True:
s = input ('enter name: ').strip()
f = open ('c:/testing.txt', 'a')
if f.writable():
f.write(s)
break
else:
f = open ('c:/testing.txt', 'r')
f.readlines()
for line in f:
print (line)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NEED HELP- read file contents, while loop to accept user input, and enter to exit

2011-05-24 Thread Tim Golden

On 24/05/2011 09:31, Cathy James wrote:

dear mentor,
I need help with my code:
1) my program won't display file contents upon opening



#1) open file and display current file contents:
f = open ('c:/testing.txt'', 'r')
f.readlines()


If you're running this in an interactive interpreter, I would
expect it to show a list of lines (assuming c:/testing.txt has
something in it...). If you're running it as a program, though,
it won't show anything: you need to actually output the result
of the expression f.readlines (). It only happens at the
interpreter as a development convenience:

f = open ("c:/testing.txt", "r")
print f.readlines ()
# or print (f.readlines ()) if you're in Python 3

TJG
--
http://mail.python.org/mailman/listinfo/python-list


Re: NEED HELP- read file contents, while loop to accept user input, and enter to exit

2011-05-24 Thread Chris Angelico
On Tue, May 24, 2011 at 6:31 PM, Cathy James  wrote:
>     s = input ('enter name: ').strip()

Are you using Python 2 or Python 3? If it's Python 2, this should be
raw_input().

>     f = open ('c:/testing.txt', 'a')
> ...
>     f = open ('c:/testing.txt', 'r')

You may be having trouble here as a result of not closing the file and
then trying to reopen it.

Also, at some point you have to check if 's' (the user's inputted
string) is empty. You can then leave the loop using the 'break'
statement.

Hope that helps! Best of luck with your homework.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I installed Python 3 on Fedora 14 By Downloading python3.2 bziped source tarball and install it according to the README, Now How shall I uninstalled python 3.2?

2011-05-24 Thread harrismh777

Varuna Seneviratna wrote:

Now How shall I uninstalled
python 3.2?



Now, how shall I remove Python 3.2 ?


...  very carefully.


It might be nice if there were a label in the Makefile so this would work:

   sudo make removeall

...  but alas,why do you want to un-install Python3.2 ?





--
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Daniel Kluev
On Tue, May 24, 2011 at 5:00 PM, Octavian Rasnita  wrote:
> And you are telling that in Perl should be used an even more complicated and
> ugly syntax just for beeing the same as in Python just for showing that I am
> wrong, but I was comparing just the shortness and cleraness of the code.
>
> So, again, in Perl is just:
>
> %d = @l;

Once again. Suppose we have array of key-value pairs (two-dimensional
array), `l`. In python, converting it to dict is as simple as d =
dict(l). In perl, %d = @l; produces meaningless value. Following your
logic, this means that perl has ugly syntax.

-- 
With best regards,
Daniel Kluev
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NEED HELP- read file contents, while loop to accept user input, and enter to exit

2011-05-24 Thread Chris Rebert
On Tue, May 24, 2011 at 1:31 AM, Cathy James  wrote:
> dear mentor,
>
> I need help with my code:


In addition to what others have already said...

> please see my attempt below and help:
>
> #1) open file and display current file contents:
> f = open ('c:/testing.txt'', 'r')
> f.readlines()
> #2)  and 3) use while loop  to write user input to file, save to file, close
> when press enter:
> while True:
>     s = input ('enter name: ').strip()
>     f = open ('c:/testing.txt', 'a')
>     if f.writable():

Since you *just* opened the file in append mode, this condition will
*always* be true (append mode implies writability), so your `else`
clause will *never* be executed.

>     f.write(s)
>     break
>     else:
>     f = open ('c:/testing.txt', 'r')
>     f.readlines()
>     for line in f:
>     print (line)

Similar beginner questions would be best directed to Python's Tutor
mailinglist: http://mail.python.org/mailman/listinfo/tutor

Cheers,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Savoynet] More 'vast heavin'

2011-05-24 Thread Chris Angelico
On Tue, May 24, 2011 at 7:03 PM, Larry Simons
 wrote:
> On Tue 24/05/2011 04:11, Libby Moyer wrote:
>>
>> And the rhymes in Mikado!
>
> Are you referring to ablutioner, diminutioner and “you shun her” all rhymed
> with executioner?
>

Can't deny that they're grin-worthy!

(Or groan-worthy, I always get those two mixed up.)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I installed Python 3 on Fedora 14 By Downloading python3.2 bziped source tarball and install it according to the README, Now How shall I uninstalled python 3.2?

2011-05-24 Thread harrismh777

Varuna Seneviratna wrote:

  Now How shall I uninstalled
python 3.2?


What --prefix did you use?  default?
--
http://mail.python.org/mailman/listinfo/python-list


Re: NEED HELP- read file contents, while loop to accept user input, and enter to exit

2011-05-24 Thread Jean-Michel Pichavant

Cathy James wrote:


f = open ('c:/testing.txt'', 'r')

replace the double quote by a single quote.

JM
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread D'Arcy J.M. Cain
On Tue, 24 May 2011 09:00:14 +0300
"Octavian Rasnita"  wrote:
> So, again, in Perl is just:
> 
> %d = @l;
> 
> Please tell me if Python has a syntax which is more clear than this for 
> doing this thing.

How is that clear?  "Shorter" != "clearer."  A Python programmer
looking at that sees line noise.  A Perl programmer looking at "d = dict
([a])" (or even "d = dict(a,)") sees something that has something to do
with creating a dictionary.  At least he would know in which section of
the manual to look for more information.

> And again, I am not trolling anything. I am just defending a language which 
> has a clearer syntax for doing some things, and a shorter code for other 

Are Perl programmers aware of some imminent worldwide shortage of
electrons that Python programmers are not?  Why is there this obsession
with shortness?

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread D'Arcy J.M. Cain
On Tue, 24 May 2011 00:17:55 -0500
John Bokma  wrote:
> > $d = @a;
> 
> That will give you the number of elements in @a. What you (probably)
> mean is %hash = @array;

If I was even considering using Perl, this one exchange would send me
screaming in the opposite direction.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


File access denied after subprocess completion on Windows platform

2011-05-24 Thread Claudiu Nicolaie CISMARU

Hello,

I have a program that uses pyside for an QT interface and a thread that 
downloads a lot of files. The thread is created with QThread object. But 
my problem I don't think it's QT related.

The thread retrieves with pycurl a file that contains a list of files 
and start to downloads them. The downloading is done as following:
- instantiate a Curl object
- open the file on local filesystem for write in binary mode (in a try 
block), with the name suffixed with .part.
- pass the description to the curl object for save.
- curl retrieve and save it. It has also a callback function that 
updates the interface, sending a QT signal to the interface.
(1) - use os.rename to rename the file with .part sufix to the final 
file.

On my interface I have 3 buttons. One of the buttons runs an .exe file. 
One button closes the interface and one is deactivated.

On the button that runs the exe I have a callback function that uses 
subprocess.Popen (for not waiting) for running a program (.exe) and 
returns. For now I configured to run calc.exe. The callback is not 
defined inside the downloader thread. It's defined globally (nor in 
QMainWindow object).

The problem appears when I close the called program (in our case 
calc.exe). The (1) part (the call of os.rename) raise an exception:


(32, 'The process cannot access the file because it is being used by 
another process')
[Error 32] The process cannot access the file because it is being used 
by another process

Question is why? And how to avoid this issue? The same program on Linux 
works very fine (that's because Linux doesn't has this violation 
access)! If I remove (1) part the program works fine. Somehow after 
closing the spawned process (calc.exe - you see, it has nothing to do 
with a open file somewhere else) the thread losses the acces to the 
current opened file by itself.

-- 
  Claudiu Nicolaie CISMARU
  GNU GPG Key: http://claudiu.targujiu.net/key.gpg
  T: +40 755 135455
  E: [email protected], [email protected]


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to get PID from subprocess library

2011-05-24 Thread Anssi Saari
TheSaint  writes:

> self.handle= \
> xmlrpclib.ServerProxy('http://localhost:%s/rpc' %int(self.numport))

Couldn't you just try to call something via this handle, like
self.handle.aria2.getVersion()? If there's an error, then start aria2
as a daemon and try again.

-- 
http://mail.python.org/mailman/listinfo/python-list


Python 3.2 Idle doesn't start. No error message.

2011-05-24 Thread markrrivet
Hello all. I have Python 2.71 installed on my Windows 7 laptop and it
runs fine. I was having a problem with Python 3.2, 32bit, not starting
with an error message saying this application has quit abnormally.
That was fixed when I took the PYTHONPATH statement out of my
environment variables. However, now when I try to start Idle, I can
see some hard drive activity, but Idle for Python 3.2 does not start;
nothing happens. Any clues as to the problem here?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: File access denied after subprocess completion on Windows platform

2011-05-24 Thread Tim Golden

On 24/05/2011 11:01, Claudiu Nicolaie CISMARU wrote:

The problem appears when I close the called program (in our case
calc.exe). The (1) part (the call of os.rename) raise an exception:


(32, 'The process cannot access the file because it is being used by
another process')
[Error 32] The process cannot access the file because it is being used
by another process


Try running procexp to see if it can see what's happening to the
handle. It's possible it's a virus checker / indexer, although
they'd tend to allow the file to be deleted out from under them.
It's not quite clear from your description above whether you
can be sure that the called subprocess has closed all its handles
by the time the os.rename runs.

TJG
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Teemu Likonen
* 2011-05-24T06:05:35-04:00 * D'Arcy J. M. Cain wrote:

> On Tue, 24 May 2011 09:00:14 +0300
> "Octavian Rasnita"  wrote:
>> %d = @l;
>> 
>> Please tell me if Python has a syntax which is more clear than this
>> for doing this thing.
>
> How is that clear? "Shorter" != "clearer." A Python programmer looking
> at that sees line noise.

I'm a Lisp programmer who sees (some) Python code as line noise.

>> I am just defending a language which has a clearer syntax for doing
>> some things, and a shorter code for other
>
> Are Perl programmers aware of some imminent worldwide shortage of
> electrons that Python programmers are not? Why is there this obsession
> with shortness?

I don't know but from the point of view of a Lisp programmer Python has
the same obsession. Not trolling, I just wanted to point out that these
are just point of views. I don't actually care that much about these
things.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to get PID from subprocess library

2011-05-24 Thread TheSaint
Anssi Saari wrote:

> Couldn't you just try to call something via this handle, like
> self.handle.aria2.getVersion()? If there's an error, then start aria2
> as a daemon and try again.
> 

Very good, you're right. Furthermore I should avoid to call that function 
several times. I think to join it with __init__ function
The program on exit must tell aria2c to quit.

-- 
goto /dev/null
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Kevin Walzer

On 5/22/11 3:44 AM, Octavian Rasnita wrote:

Somebody told that C# and Objective C are good languages. They might be good, 
but they are proprietary, and not only that they are proprietary, but they need 
to be ran under platforms that cannot be used freely, so from the freedom point 
of view, Perl, Ruby, Python and Java are the ways to go.


Proprietary?

Licensing options for C# in its Mono (Free Platform) implementation:

http://www.mono-project.com/Licensing

Licensing options for Objective-C in its GNUStep (Free Platform) 
implementaiton


http://www.gnustep.org/information/aboutGNUstep.html

It may be true that these languages are more widely used on their 
originating platforms (Windows, OS X) than on Linux, but these 
implementations are definitely open source.


--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: os.access giving incorrect results on Windows

2011-05-24 Thread Tim Golden

On 20/05/2011 12:26, Ayaskanta Swain wrote:
> Thanks for the reply and suggestions. I followed the patch provided by
> you in issue 2528, but the code looks very tricky to me.

OK, first a summary of the discussion on the python-dev thread.
Essentially it was felt that os.access was sufficiently shaky
and unuseful on Windows that it was better to deprecate it and
to discourage its use. So I'll be making that change when I
can get round to it.

As to your particular problem here...

Does my_dir already exist? If it does then os.open won't be able
to create it. If it doesn't then I can't see any reason why the
code should fail there. I just ran it myself and it fails, as
expected on an unpatched Python, on the assert on line 17 where
the check is made for the result of os.access for W_OK.

I don't have the time right now but if no-one else gets there
first I hope to be able to post back with a standalone example
of the AccessCheck API

TJG

Anyways I wrote
> my Test.py script & tried only the def test_access_w(self): test case
> which is defined under class FileTests(unittest.TestCase) by providing
> my own directory path to check the write permissions on it.
>
> I executed my But it failed with the following errors –
>
> *> python Test.py C:\temp\my_dir*
>
> test_access_w (__main__.FileTests) ... ERROR
>
> ==
>
> ERROR: test_access_w (__main__.FileTests)
>
> --
>
> Traceback (most recent call last):
>
> File "Test.py", line 14, in test_access_w
>
> f = os.open(dirpath, os.O_CREAT)
>
> OSError: [Errno 13] Permission denied: 'C:\\temp\\my_dir'
>
> --
>
> Ran 1 test in 0.000s
>
> FAILED (errors=1)
>
> Basically the os.open() function is failing to open a directory (In this
> case my_dir). The directory has write permissions for the user. Attached
> herewith is my Test script. Can you please suggest some simple python
> code which checks the write permissions of a directory in a straight
> forward way (Not by using unit tests)
>
> Thanks
>
> Ayaskant-
>
> Bangalore
>

--
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Chris Angelico
On Wed, May 25, 2011 at 12:09 AM, Kevin Walzer  wrote:
> Proprietary?
>
> Licensing options for C# in its Mono (Free Platform) implementation:
>
> http://www.mono-project.com/Licensing
>
> Licensing options for Objective-C in its GNUStep (Free Platform)
> implementaiton
>
> http://www.gnustep.org/information/aboutGNUstep.html

Just a side point: Are these *languages* free, or merely these
*implementations*?

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Kevin Walzer

On 5/24/11 2:23 AM, Stefan Behnel wrote:

Beliavsky, 20.05.2011 18:39:

I thought this essay on why one startup chose Python was interesting.


Since everyone seems to be hot flaming at their pet languages in this
thread, let me quickly say this:

Thanks for sharing the link.

Stefan



I kind of thought that other posters might also chime in on why they 
chose Python instead of . Since no one else 
has, I'll bite.


I've been programming for about seven years, and am basically 
self-taught. I got my first taste of writing code when trying do to some 
basic hacking on my (then) shiny new G3 iBook. (Even though it was a 
Mac, I was enthralled by its Unix underpinnings.) C was too hard for a 
programming newbie, and (at the time) I only understood shell to be a 
sequential series of commands. (cd ~/.Trash; ls; rm *)


My goal was to write desktop GUI apps, and looking around at the 
available languages, libraries, and toolkits for Unix and the Mac, I 
settled on Tk as the UI toolkit, since it seemed to be the simplest one 
out there, and on Tcl and Python as the programming languages. (A brief 
detour with AppleScript convinced me that it is a useful scripting 
language for hooking into various parts of OS X, but it is not very 
powerful.)


While Tcl doesn't get a lot of love or respect on this list, it is quite 
powerful in its way, and an understanding of Tcl is quite useful in 
particular for understanding Tk and its Python wrapper, Tkinter. After 
becoming productive with Tcl and writing a couple of applications in it, 
I turned to Python in earnest and set about learning its capabilities as 
well, and have since released a couple of Python desktop apps on the Mac 
(commercial apps, using Tk as the toolkit).


With that background, here are my reasons for keeping Python in my toolbox:

1. Its core libraries and third-party packages address nearly every 
imaginable need. The size of its community is a real asset here. Tcl is 
a more compact language, with a smaller core library and fewer 
third-party packages (no library comparable to Mark Pilgrim's 
feedparser, for instance), which means that for some use cases, using 
Tcl would mean more work.


2. Python has excellent tools for deployment of desktop apps. Since I 
only work on the Mac, I'm not that familiar with py2exe, but py2app and 
bundlebuilder have always allowed me to wrap up my apps with an embedded 
Python interpreter with a minimum of fuss. Tcl also excels in deployment 
of desktop apps; other languages, such as Perl and Ruby, seem to lag 
behind in this respect. (I could find no actively-maintained, 
open-source, Mac-viable desktop app bundling tools for either Ruby or 
Perl, which cooled my interest in them considerably.)


3. Python's binding to Tk makes writing GUI apps a straightforward 
process. Since I already knew Tk quite well, learning its Python 
bindings was much simpler than learning another GUI toolkit such as PyQt 
or wxPython. The strategies I learned from Tcl to develop sophisticated 
Tk-based UI's translate quite well to Python.


Python isn't perfect; for some instances, I find Tcl a more lightweight 
and accessible tool to use. I also spend a lot of time digging into Tcl 
and Tk's C API to extend their capabilities in certain ways; this also 
allows my Python apps to access such enhancements, via Tkinter. But all 
in all I'm a happy user of Python, and it will continue to have a 
primary place in my toolbox.


--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list


Codes do not run

2011-05-24 Thread SKHUMBUZO ZIKHALI
Hi: 

I am learning Python on my own using a " Guide to Programming with Python" 
book. Author of the book is Micheal Dawson and I am using version 2.3.5 of 
python.  When I try to run the code I do not get required results. The picture 
could not be loaded. I get trackback message regarding undefined module.The 
example from the book is as follows:

from liveswires import games

games.init(screen_width = 640, screen_height = 480, fps = 50)
wall_image = games.load_image("wall.jpg", transparent = False)
games.screen.background = wall_image

games.screen.mainloop() 

Can anyone please assist me. 

Thank you 

Sikhumbuzo-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Codes do not run

2011-05-24 Thread Chris Angelico
On Wed, May 25, 2011 at 1:17 AM, SKHUMBUZO ZIKHALI
 wrote:
> The example from the book is as follows:
>
> from liveswires import games

I think this might be meant to say "livewires". Presumably you did
install this package? If not, it won't work (but even if you have, it
won't work as "liveswires").

http://www.livewires.org.uk/python/package

Hope that helps!

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Obtaining a full path name from file

2011-05-24 Thread RVince
s = "C:\AciiCsv\Gravity_Test_data\A.csv"
f = open(s,"r")

How do I obtain the full pathname given the File, f? (which should
equal "C:\AciiCsv\Gravity_Test_data"). I've tried all sorts of stuff
and am just not finding it. Any help greatly appreciated !
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Codes do not run

2011-05-24 Thread Tim Johnson
* SKHUMBUZO ZIKHALI  [110524 07:26]:
> Hi: 
> 
> I am learning Python on my own using a " Guide to Programming with Python" 
> book. Author of the book is Micheal Dawson and I am using version 2.3.5 of 
> python.  When I try to run the code I do not get required results. The 
> picture 
> could not be loaded. I get trackback message regarding undefined module.The 
> example from the book is as follows:
> 
> from liveswires import games
> 
> games.init(screen_width = 640, screen_height = 480, fps = 50)
> wall_image = games.load_image("wall.jpg", transparent = False)
> games.screen.background = wall_image
> 
> games.screen.mainloop() 
> 
> Can anyone please assist me. 
 You should provide
 1)the traceback itself.
 2)Version of python
 3)Operating system
 4)All relevant code
 Also
 Do the following :
   import sys
   print(sys.path)
 Do you see the liveswires module in the path?

-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Obtaining a full path name from file

2011-05-24 Thread Tim Golden

On 24/05/2011 16:36, RVince wrote:

s = "C:\AciiCsv\Gravity_Test_data\A.csv"
f = open(s,"r")

How do I obtain the full pathname given the File, f? (which should
equal "C:\AciiCsv\Gravity_Test_data"). I've tried all sorts of stuff
and am just not finding it. Any help greatly appreciated !


You're going to kick yourself:

f.name

TJG
--
http://mail.python.org/mailman/listinfo/python-list


Re: Obtaining a full path name from file

2011-05-24 Thread RVince
Ha! You;re right -- but is there a way to get it without the filename
appended at the end?

On May 24, 11:52 am, Tim Golden  wrote:
> On 24/05/2011 16:36, RVince wrote:
>
> > s = "C:\AciiCsv\Gravity_Test_data\A.csv"
> > f = open(s,"r")
>
> > How do I obtain the full pathname given the File, f? (which should
> > equal "C:\AciiCsv\Gravity_Test_data"). I've tried all sorts of stuff
> > and am just not finding it. Any help greatly appreciated !
>
> You're going to kick yourself:
>
> f.name
>
> TJG

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Obtaining a full path name from file

2011-05-24 Thread Mel
Tim Golden wrote:

> On 24/05/2011 16:36, RVince wrote:
>> s = "C:\AciiCsv\Gravity_Test_data\A.csv"
>> f = open(s,"r")
>>
>> How do I obtain the full pathname given the File, f? (which should
>> equal "C:\AciiCsv\Gravity_Test_data"). I've tried all sorts of stuff
>> and am just not finding it. Any help greatly appreciated !
> 
> You're going to kick yourself:
> 
> f.name

There's trouble there, though:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open ('xyzzy.txt')
>>> f.name
'xyzzy.txt'
>>> import os
>>> os.getcwd()
'/home/mwilson'
>>> os.chdir('sandbox')
>>> f.name
'xyzzy.txt'


If you open a file and don't get a full path from os.path.abspath right 
away, the name in the file instance can get out-of-date.

Mel.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Obtaining a full path name from file

2011-05-24 Thread Chris Angelico
On Wed, May 25, 2011 at 2:04 AM, RVince  wrote:
> Ha! You;re right -- but is there a way to get it without the filename
> appended at the end?

Parse the file name with the os.path functions:

http://docs.python.org/library/os.path.html

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Obtaining a full path name from file

2011-05-24 Thread Tim Golden

On 24/05/2011 17:04, RVince wrote:

Ha! You;re right -- but is there a way to get it without the filename
appended at the end?


Well, just use the functions in os.path, specifically os.path.dirname...

TJG
--
http://mail.python.org/mailman/listinfo/python-list


Re: Obtaining a full path name from file

2011-05-24 Thread Jean-Michel Pichavant

RVince wrote:

Ha! You;re right -- but is there a way to get it without the filename
appended at the end?

On May 24, 11:52 am, Tim Golden  wrote:
  

On 24/05/2011 16:36, RVince wrote:



s = "C:\AciiCsv\Gravity_Test_data\A.csv"
f = open(s,"r")
  
How do I obtain the full pathname given the File, f? (which should

equal "C:\AciiCsv\Gravity_Test_data"). I've tried all sorts of stuff
and am just not finding it. Any help greatly appreciated !
  

You're going to kick yourself:

f.name

TJG



  

path, fileName = os.path.split(os.path.abspath(f.name))

JM
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Octavian Rasnita
From: "D'Arcy J.M. Cain" 
> On Tue, 24 May 2011 09:00:14 +0300
> "Octavian Rasnita"  wrote:
>> So, again, in Perl is just:
>> 
>> %d = @l;
>> 
>> Please tell me if Python has a syntax which is more clear than this for 
>> doing this thing.
> 
> How is that clear?  "Shorter" != "clearer."  A Python programmer
> looking at that sees line noise.  A Perl programmer looking at "d = dict
> ([a])" (or even "d = dict(a,)") sees something that has something to do
> with creating a dictionary.  At least he would know in which section of
> the manual to look for more information.


The Perl programmers usually don't need to look in the dictionary when they are 
creating programs.
Perl is harder to learn, but it is easier to use.

> Are Perl programmers aware of some imminent worldwide shortage of
> electrons that Python programmers are not?  Why is there this obsession
> with shortness?


A shorter code can be typed faster, obviously, and there are fewer possibility 
of appearing errors, but the shortage is not the most important thing.

The most important thing is that the chars @, $, or % are the same in all 
languages, while the English words used by the languages that use many such 
words are harder to remember especially for the non-native English speakers. 
Python is not a very bad language from this perspective like Java is though. :-)

In Perl the programmers can also use English words for some things, like 
$OUTPUT_AUTOFLUSH, but personally I never liked those things. Using $| instead 
is much shorter and clear, because I don't need to remember the English words 
like autoflush, or maybe it was just flush, or it was autoflush_output, or 
output_flush... something like $| can't be forgotten.

Yes, I know that the guys from Google would never like that since these chars 
are not "Googleable" :-)

Octavian

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Octavian Rasnita
From: "D'Arcy J.M. Cain" 

> On Tue, 24 May 2011 00:17:55 -0500
> John Bokma  wrote:
>> > $d = @a;
>> 
>> That will give you the number of elements in @a. What you (probably)
>> mean is %hash = @array;
> 
> If I was even considering using Perl, this one exchange would send me
> screaming in the opposite direction.


If you didn't consider to change the language you prefer it means that you are 
closed minded and use to fell in love with the tools you use.
Don't make me tell here how many things I don't like in Perl.
I use to tell those things on Perl mailing lists and make upset their members. 
:-)

Similarly, if you don't like something in Perl, why don't you tell them what 
you don't like to the Perl programmers community and not just have the guts to 
tell that in a group where the majority share your preferences.
I came here on the list to find good things about Python and to learn some 
things and use its good parts, and not to hear bashing about other programming 
languages.

Octavian

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Octavian Rasnita
From: "Daniel Kluev" 
> On Tue, May 24, 2011 at 5:00 PM, Octavian Rasnita  wrote:
>> And you are telling that in Perl should be used an even more complicated and
>> ugly syntax just for beeing the same as in Python just for showing that I am
>> wrong, but I was comparing just the shortness and cleraness of the code.
>>
>> So, again, in Perl is just:
>>
>> %d = @l;
> 
> Once again. Suppose we have array of key-value pairs (two-dimensional
> array),

This is a forced example to fit the way Python can do it with a clean syntax, 
but I don't think there are cases in which somebody wants to create 
hashes/dictionaries where the key is not a plain string but an array.

This is not a rare case, but a case that probably nobody needs, ever.

Octavian

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Octavian Rasnita
From: "Kevin Walzer" 

> On 5/22/11 3:44 AM, Octavian Rasnita wrote:
>> Somebody told that C# and Objective C are good languages. They might be 
>> good, but they are proprietary, and not only that they are proprietary, but 
>> they need to be ran under platforms that cannot be used freely, so from the 
>> freedom point of view, Perl, Ruby, Python and Java are the ways to go.
> 
> Proprietary?
> 
> Licensing options for C# in its Mono (Free Platform) implementation:
> 
> http://www.mono-project.com/Licensing
> 
> Licensing options for Objective-C in its GNUStep (Free Platform) 
> implementaiton
> 
> http://www.gnustep.org/information/aboutGNUstep.html
> 
> It may be true that these languages are more widely used on their 
> originating platforms (Windows, OS X) than on Linux, but these 
> implementations are definitely open source.


Exactly, this is why I said that it matters only the distributions used by the 
most users.

Octavian


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Octavian Rasnita
Subject: Re: Why did Quora choose Python for its development?
> I've been programming for about seven years, and am basically 
> self-taught. I got my first taste of writing code when trying do to some 
> basic hacking on my (then) shiny new G3 iBook. (Even though it was a 
> Mac, I was enthralled by its Unix underpinnings.) C was too hard for a 
> programming newbie, and (at the time) I only understood shell to be a 
> sequential series of commands. (cd ~/.Trash; ls; rm *)
> 
> My goal was to write desktop GUI apps, and looking around at the 
> available languages, libraries, and toolkits for Unix and the Mac, I 
> settled on Tk as the UI toolkit, since it seemed to be the simplest one 
> out there, and on Tcl and Python as the programming languages. (A brief 
> detour with AppleScript convinced me that it is a useful scripting 
> language for hooking into various parts of OS X, but it is not very 
> powerful.)
> 
> While Tcl doesn't get a lot of love or respect on this list, it is quite 
> powerful in its way, and an understanding of Tcl is quite useful in 
> particular for understanding Tk and its Python wrapper, Tkinter. After 
> becoming productive with Tcl and writing a couple of applications in it, 
> I turned to Python in earnest and set about learning its capabilities as 
> well, and have since released a couple of Python desktop apps on the Mac 
> (commercial apps, using Tk as the toolkit).
> 
> With that background, here are my reasons for keeping Python in my toolbox:
> 
> 1. Its core libraries and third-party packages address nearly every 
> imaginable need. The size of its community is a real asset here. Tcl is 
> a more compact language, with a smaller core library and fewer 
> third-party packages (no library comparable to Mark Pilgrim's 
> feedparser, for instance), which means that for some use cases, using 
> Tcl would mean more work.
> 
> 2. Python has excellent tools for deployment of desktop apps. Since I 
> only work on the Mac, I'm not that familiar with py2exe, but py2app and 
> bundlebuilder have always allowed me to wrap up my apps with an embedded 
> Python interpreter with a minimum of fuss. Tcl also excels in deployment 
> of desktop apps; other languages, such as Perl and Ruby, seem to lag 
> behind in this respect. (I could find no actively-maintained, 
> open-source, Mac-viable desktop app bundling tools for either Ruby or 
> Perl, which cooled my interest in them considerably.)
> 
> 3. Python's binding to Tk makes writing GUI apps a straightforward 
> process. Since I already knew Tk quite well, learning its Python 
> bindings was much simpler than learning another GUI toolkit such as PyQt 
> or wxPython. The strategies I learned from Tcl to develop sophisticated 
> Tk-based UI's translate quite well to Python.
> 
> Python isn't perfect; for some instances, I find Tcl a more lightweight 
> and accessible tool to use. I also spend a lot of time digging into Tcl 
> and Tk's C API to extend their capabilities in certain ways; this also 
> allows my Python apps to access such enhancements, via Tkinter. But all 
> in all I'm a happy user of Python, and it will continue to have a 
> primary place in my toolbox.
> 
> --Kevin


Hi Kevin,

Thanks for your message. It is helpful to know why some programmers prefer a 
certain OS, programming language, module or program, because this way the 
newbies can find its benefits rapidly.

Yes there are packiging solutions for Perl under Mac, but I haven't tried them 
because I never used a Mac, however, I agree that python is better than Perl 
for creating desktop apps, because the modules which are used for creating GUIs 
are better developed.

Too bad that you prefer Tk-based GUIs, because they are simple to use, I agree, 
but they create and promote discrimination because they are not accessible at 
all for the screen readers used by the blind.

The standard Win32 GUIS/MFC or the libs that use those GUIs like Java SWT and 
wxWIDGETS used by WxPerl, WxPython... are much better accessible. Somebody told 
that he will try to make Tk accessible, but just as I expected, I haven't heard 
anything until now about any kind of success of that project.

Octavian

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.2 Idle doesn't start. No error message.

2011-05-24 Thread Terry Reedy

On 5/24/2011 8:01 AM, [email protected] wrote:

Hello all. I have Python 2.71 installed on my Windows 7 laptop and it
runs fine. I was having a problem with Python 3.2, 32bit, not starting
with an error message saying this application has quit abnormally.
That was fixed when I took the PYTHONPATH statement out of my
environment variables. However, now when I try to start Idle, I can
see some hard drive activity, but Idle for Python 3.2 does not start;
nothing happens. Any clues as to the problem here?


How do you try to start it?

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread John Bokma
Teemu Likonen  writes:

> * 2011-05-24T06:05:35-04:00 * D'Arcy J. M. Cain wrote:
>
>> On Tue, 24 May 2011 09:00:14 +0300
>> "Octavian Rasnita"  wrote:
>>> %d = @l;
>>> 
>>> Please tell me if Python has a syntax which is more clear than this
>>> for doing this thing.
>>
>> How is that clear? "Shorter" != "clearer." A Python programmer looking
>> at that sees line noise.
>
> I'm a Lisp programmer who sees (some) Python code as line noise.

Exactly, and glad to see there are also non-extremists in this group.

I have been programming Perl for well over 17 years. I've been trying to
switch to Python /several times/ but yet, with all its shortcomings Perl
somehow still suits me better. To D'Arcy and other Pythonistas --
doesn't that sound like an extermistic organization or what -- it might
look like a cat had an accident involving a keyboard but to me, and all
those other people who do enjoy coding Perl it's beauty.

The whole Python is so beatiful & perfect sounds to me like people who
have embraced the latin alphabet calling Devanagari unreadable chicken
scratches made by backwards and poor people. To me it's a writing system
of beauty.

> I don't know but from the point of view of a Lisp programmer Python has
> the same obsession. Not trolling, I just wanted to point out that these
> are just point of views. I don't actually care that much about these
> things.

Wise words. And I agree. To me Python vs. Perl has nothing to do with
being a fanboy (unlike many other posters here). I like both languages,
I have invested a lot of time in learning Python and I am really not
dense. Yet, even though I can program in Python sufficient enough very
often I just pick Perl. Now why is that?

-- 
John Bokma   j3b

Blog: http://johnbokma.com/Perl Consultancy: http://castleamber.com/
Perl for books:http://johnbokma.com/perl/help-in-exchange-for-books.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread John Bokma
"D'Arcy J.M. Cain"  writes:

> On Tue, 24 May 2011 00:17:55 -0500
> John Bokma  wrote:
>> > $d = @a;
>> 
>> That will give you the number of elements in @a. What you (probably)
>> mean is %hash = @array;
>
> If I was even considering using Perl, this one exchange would send me
> screaming in the opposite direction.

To me as silly as all those people who give Python a wide berth because
of significant whitespace. I am glad that I am not so limited in that
respect. To me programming languages are like writing systems used by
humans; each has its short comings and each has its beauty.

-- 
John Bokma   j3b

Blog: http://johnbokma.com/Perl Consultancy: http://castleamber.com/
Perl for books:http://johnbokma.com/perl/help-in-exchange-for-books.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: File access denied after subprocess completion on Windows platform

2011-05-24 Thread Claudiu Nicolaie CISMARU

I'm quoting a message that I received on personal address and wasn't 
sent to list:
> 
> try adding argument close_fds=True to subprocess.Popen
> 
> harish
> 

And Tim's message:
> It's not quite clear from your description above whether you
> can be sure that the called subprocess has closed all its handles
> by the time the os.rename runs.

Seems that close_fds did the trick. Anyway, I read that description on 
the documentation last night but I think I was so tired that I 
understood that in Windows has no effect... :)

Thank you, all.
-- 
  Claudiu Nicolaie CISMARU
  GNU GPG Key: http://claudiu.targujiu.net/key.gpg
  T: +40 755 135455
  E: [email protected], [email protected]


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread D'Arcy J.M. Cain
On Tue, 24 May 2011 19:10:56 +0300
"Octavian Rasnita"  wrote:
> > If I was even considering using Perl, this one exchange would send me
> > screaming in the opposite direction.
> 
> If you didn't consider to change the language you prefer it means
> that you are closed minded and use to fell in love with the tools you

Now you are just bordering on rudeness.  I never made any disparaging
remarks about you.  I only talked about a tool that you seem to like
and I don't.  In fact, I did consider and investigate Perl many years
ago along with may other languages before I settled on Python.  I
didn't like it then and I don't like it now.  However, I have never
called someone "close minded" for preferring a different tool to me.

> Don't make me tell here how many things I don't like in Perl.

Trust me, there is no need.  

> I use to tell those things on Perl mailing lists and make upset their

Good for you.  I also have talked about things in Python that I don't
like on this list.  No one has ever accused me of being afraid to speak
my mind.  That facet of my personality has got me in a lot of trouble
in my life from parents, teachers, bosses and I have even been known to
speak out against the police while they were holding automatic rifles to
my head.  I doubt that there will ever be enough peer pressure on a
mailing list to trump that.

> Similarly, if you don't like something in Perl, why don't you tell
> them what you don't like to the Perl programmers community and not just
> have the guts to tell that in a group where the majority share your
> preferences.

Because I am not a missionary.  Someone came to my house and told me
why their way was better so I spoke up.  Same thing when the JW come to
my front door but I have no interest in going to their Kingdom Hall to
tell them why they are wrong.

> I came here on the list to find good things about Python and to learn
> some things and use its good parts, and not to hear bashing about other
> programming languages.

Same here but someone (I don't even know who started it) felt that it
was necessary to tell us all why their language was better.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Chris Angelico
On Wed, May 25, 2011 at 2:50 AM, John Bokma  wrote:
> Wise words. And I agree. To me Python vs. Perl has nothing to do with
> being a fanboy (unlike many other posters here). I like both languages,
> I have invested a lot of time in learning Python and I am really not
> dense. Yet, even though I can program in Python sufficient enough very
> often I just pick Perl. Now why is that?

To me, a language is a tool. The more tools you have competence with,
the easier it will be to select the right one for any job. There are
very few tools that have no use whatsoever; even Ook might be useful
(although I have yet to be asked to port any code to OrangutanOS).
This differs from the notion of having ten paradigms in one language,
in that most source files will identify themselves fairly early on
(possibly even out-of-band, such as filename extensions).

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread D'Arcy J.M. Cain
On Tue, 24 May 2011 11:52:39 -0500
John Bokma  wrote:
> >> > $d = @a;
> >> 
> >> That will give you the number of elements in @a. What you (probably)
> >> mean is %hash = @array;
> >
> > If I was even considering using Perl, this one exchange would send me
> > screaming in the opposite direction.
> 
> To me as silly as all those people who give Python a wide berth because
> of significant whitespace. I am glad that I am not so limited in that
> respect. To me programming languages are like writing systems used by
> humans; each has its short comings and each has its beauty.

My point was that even proponents of the language can make a
significant error based on the way the variable is named.  It's like
the old Fortran IV that I first learned where the name of the variable
determined whether it was an integer or a floating point.

One of my favorite quotes (not sure if it was about Perl or APL) is "I
refuse to use a programming language where the proponents of it stick
snippets under each other's nose and say 'I bet you can't guess what
this does.'"

When I first looked at Perl it looked like line noise.  When I first
looked at Python it looked like pseudo-code.

Look, I couldn't care less what other people use.  I just don't see any
reason for someone to come into a Python group and start proselytizing
about why their tool is better than ours any more than I would feel any
need to go to a Perl group and start trying to convert them.

Bottom line - they did a study once (sorry, can't point to it any more)
to determine the best tool for development.  Turns out that the most
productive tool was generally the one that the user believed was the
most productive.  In hindsight I think that that was rather obvious.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: English Idiom in Unix: Directory Recursively

2011-05-24 Thread Xah Lee
On May 23, 9:28 pm, Chris Angelico  wrote:
> On Tue, May 24, 2011 at 2:20 PM, Xah Lee  wrote:
> > why don't you file a bug report? In GNU Emacs 23.2, it's under the
> > Help menu. I suppose it's the same in other emacs distro.
>
> Because I do not consider its behaviour to be errant. And I suspect
> its main developers won't either. That's why I suggested you grab the
> sources and make The Perfect Emacs.

why don't you try http://ergoemacs.org/ ?

 Xah

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread John Bokma
Chris Angelico  writes:

> On Wed, May 25, 2011 at 2:50 AM, John Bokma  wrote:
>> Wise words. And I agree. To me Python vs. Perl has nothing to do with
>> being a fanboy (unlike many other posters here). I like both languages,
>> I have invested a lot of time in learning Python and I am really not
>> dense. Yet, even though I can program in Python sufficient enough very
>> often I just pick Perl. Now why is that?
>
> To me, a language is a tool.

To me, and to a lot of Perl programmers it's not different.

> The more tools you have competence with, the easier it will be to
> select the right one for any job. There are very few tools that have
> no use whatsoever; even Ook might be useful (although I have yet to be
> asked to port any code to OrangutanOS).  This differs from the notion
> of having ten paradigms in one language,

If this is referring to Perl: the myths surrounding "there is more than
one way" are even more crazy than "there is only one way", maybe because
"more than one" makes it so much easier to make those myths up?

On top of that: how many paradigms does Python support?  And which
paradigms does Perl support and Python doesn't?

Roughly there are two dialects of Perl [1]: what people who never took the
time to learn it write, and the rest. Also, having more than one way to
code something doesn't mean that there are no preferrences. Python has
also several ways to do certain things; yet most skilled programmers
have a preference for one way. It's not that different with Perl; in my
experience exactly the same even.

Of course one can say a lot about Perl; I can. But I have never had a
rough time reading someone else's code, unless the person had no clue
about programming to begin with [2].

If Perl is really such a disaster, why are people using it? Or are they
all short-sighted idiots who don't know better? Several Perl programmers
I know, including myself, are fully aware of Python and other
programming languages. Yet, somehow they still program in Perl...

[1] http://www.bofh.org.uk/2010/07/25/a-tale-of-two-languages
[2] I once had to port a piece of Pascal code and after some studying it
turned out that the 100+ lines or so did some variant of bubble sort 
and near the end reversed the order in a separate loop.

-- 
John Bokma   j3b

Blog: http://johnbokma.com/Perl Consultancy: http://castleamber.com/
Perl for books:http://johnbokma.com/perl/help-in-exchange-for-books.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread John Bokma
"D'Arcy J.M. Cain"  writes:

> On Tue, 24 May 2011 11:52:39 -0500
> John Bokma  wrote:
>> >> > $d = @a;
>> >> 
>> >> That will give you the number of elements in @a. What you (probably)
>> >> mean is %hash = @array;
>> >
>> > If I was even considering using Perl, this one exchange would send me
>> > screaming in the opposite direction.
>> 
>> To me as silly as all those people who give Python a wide berth because
>> of significant whitespace. I am glad that I am not so limited in that
>> respect. To me programming languages are like writing systems used by
>> humans; each has its short comings and each has its beauty.
>
> My point was that even proponents of the language can make a
> significant error based on the way the variable is named.

And someone can't misspell dict, for example? Are we now going to judge
a language on a typo someone just made?

> When I first looked at Perl it looked like line noise.  When I first
> looked at Python it looked like pseudo-code.

When people who are used to a latin alpabeth look at Devanagari they
probably see scratches make by chickens. I saw beauty (and still see
it). To someone fluent in Devanagari the latin alpabeth might look like
Perl ;-).

Anyway, I have been exposed to pseudo-code a lot before I picked up
Perl, and yet, Perl somehow stuck with me. I learned about Python a
little later (IIRC), and have tried to pick it up several times over the
years that followed. Last year I have been more serious about picking it
up; and I even did some paid for work in it. I /can/ program in Python,
I do /like/ Python, but somehow I like Perl more; even when I am fully
aware of its shortcommings each time I use it.

As for line noise: very often it turns out that people mean the regular
expressions by this. But a similar dialect is used by many other
programming languages that I know of. The difference is that Perl has
dedicated operators for it.

A Perl programmer will call this line noise:

double_word_re = re.compile(r"\b(?P\w+)\s+(?P=word)(?!\w)",
re.IGNORECASE)
for match in double_word_re.finditer(text):
print ("{0} is duplicated".format(match.group("word"))

(p500 of Programming in Python 3, 2nd edition, any typos by me).

> Look, I couldn't care less what other people use.

In that case you're an exception here. Or maybe the weekly Perl bashers
are way more vocal here and drown people like you out. One thing I hate
about comp.lang.perl.misc is the ivory tower attitude there. One thing I
hate about comp.lang.python is the weekly Perl bashing; to me it makes
those people look like extremists (Pythonistas, what's in a word), and
to be honest, it does affect how I view Python.

> I just don't see any reason for someone to come into a Python group
> and start proselytizing about why their tool is better than ours any
> more than I would feel any need to go to a Perl group and start trying
> to convert them.

Yet it seems to be accepted behavoir here to weekly bash Perl...

> Bottom line - they did a study once (sorry, can't point to it any more)
> to determine the best tool for development.  Turns out that the most
> productive tool was generally the one that the user believed was the
> most productive.  In hindsight I think that that was rather obvious.

Doesn't surprise me. I did switch to Emacs a few years back (used
Textpad for many years) but I don't think I now produce more code /
hour. But I am able to do some things way easier compared to using
Textpad, and that gives me pleasure.

-- 
John Bokma   j3b

Blog: http://johnbokma.com/Perl Consultancy: http://castleamber.com/
Perl for books:http://johnbokma.com/perl/help-in-exchange-for-books.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NEED HELP- read file contents, while loop to accept user

2011-05-24 Thread Cathy James
TJG- that solved the printing issue!! Many thanks:)

Thanks to Chris and Jean Michel for your hints.

On Tue, May 24, 2011 at 4:07 AM,  wrote:

> Send Python-list mailing list submissions to
>[email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>[email protected]
>
> You can reach the person managing the list at
>[email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
>
> Today's Topics:
>
>   1. Re: Why did Quora choose Python for its development?
>  (Stefan Behnel)
>   2. Re: Why did Quora choose Python for its development?
>  (Octavian Rasnita)
>   3. Re: Why did Quora choose Python for its development?
>  (Chris Angelico)
>   4. NEED HELP- read file contents, while loop to accept user
>  input, andenter to exit (Cathy James)
>   5. Re: NEED HELP- read file contents, while loop to accept user
>  input,and enter to exit (Tim Golden)
>   6. Re: NEED HELP- read file contents, while loop to accept user
>  input,and enter to exit (Chris Angelico)
>   7. Re: I installed Python 3 on Fedora 14 By Downloading
>  python3.2 bziped  source tarball and install it according to the
>  README,   Now How shall I uninstalled python 3.2? (harrismh777)
>   8. Re: Why did Quora choose Python for its development?
>  (Daniel Kluev)
>   9. Re: NEED HELP- read file contents, while loop to accept user
>  input,and enter to exit (Chris Rebert)
>  10. Re: [Savoynet] More 'vast heavin' (Chris Angelico)
>
>
> -- Forwarded message --
> From: Stefan Behnel 
> To: [email protected]
> Date: Tue, 24 May 2011 08:23:55 +0200
> Subject: Re: Why did Quora choose Python for its development?
> Beliavsky, 20.05.2011 18:39:
>
>> I thought this essay on why one startup chose Python was interesting.
>>
>
> Since everyone seems to be hot flaming at their pet languages in this
> thread, let me quickly say this:
>
> Thanks for sharing the link.
>
> Stefan
>
>
>
>
> -- Forwarded message --
> From: "Octavian Rasnita" 
> To: 
> Date: Tue, 24 May 2011 11:10:36 +0300
> Subject: Re: Why did Quora choose Python for its development?
> From: "Stefan Behnel" 
>
>> Beliavsky, 20.05.2011 18:39:
>>
>>> I thought this essay on why one startup chose Python was interesting.
>>>
>>
>> Since everyone seems to be hot flaming at their pet languages in this
>> thread, let me quickly say this:
>>
>> Thanks for sharing the link.
>>
>
>
> Maybe I have missed a message, but if I didn't, please provide that link.
> I am always interested to find the best solutions.
>
> Thanks.
>
> Octavian
>
>
>
>
> -- Forwarded message --
> From: Chris Angelico 
> To: [email protected]
> Date: Tue, 24 May 2011 18:20:44 +1000
> Subject: Re: Why did Quora choose Python for its development?
> On Tue, May 24, 2011 at 6:10 PM, Octavian Rasnita 
> wrote:
> > From: "Stefan Behnel" 
> >>
> >> Beliavsky, 20.05.2011 18:39:
> >>>
> >>> I thought this essay on why one startup chose Python was interesting.
> >>
> >> Since everyone seems to be hot flaming at their pet languages in this
> >> thread, let me quickly say this:
> >>
> >> Thanks for sharing the link.
> >
> >
> > Maybe I have missed a message, but if I didn't, please provide that link.
> > I am always interested to find the best solutions.
>
> At the beginning of the thread, three days and forty-odd messages ago,
> this was posted:
>
> http://www.quora.com/Why-did-Quora-choose-Python-for-its-development
>
> It's the reason for the thread title, regardless of the current thread
> content :)
>
> Chris Angelico
>
>
>
> -- Forwarded message --
> From: Cathy James 
> To: [email protected]
> Date: Tue, 24 May 2011 03:31:37 -0500
> Subject: NEED HELP- read file contents, while loop to accept user input,
> and enter to exit
> dear mentor,
>
> I need help with my code:
> 1) my program won't display file contents upon opening
> 2) my program is not writing to file
> 3) my program is not closing when user presses enter- gow do I do this with
> a while loop?
>
> please see my attempt below and help:
>
> #1) open file and display current file contents:
> f = open ('c:/testing.txt'', 'r')
> f.readlines()
> #2)  and 3) use while loop  to write user input to file, save to file,
> close when press enter:
> while True:
> s = input ('enter name: ').strip()
> f = open ('c:/testing.txt', 'a')
> if f.writable():
> f.write(s)
> break
> else:
> f = open ('c:/testing.txt', 'r')
> f.readlines()
> for line in f:
> print (line)
>
>
> -- Forwarded message --
> From: Tim Golden 
> To:
> Date: Tue, 24 May 2011 09:46:11 +0100
> Subject: Re: NEED HELP- read file contents, whi

subscribef

2011-05-24 Thread Jim Syyap

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Obtaining a full path name from file

2011-05-24 Thread Michael Kent
If a filename does not contain a path component, os.path.abspath will prepend 
the current directory path onto it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Octavian Rasnita

From: "John Bokma" 


"Octavian Rasnita"  writes:


From: "Daniel Kluev" 
a = [1,2]
dict([a])

Yes, but

d = dict([a])

is not so nice as

$d = @a;


That will give you the number of elements in @a. What you (probably)
mean is %hash = @array;



Of course. Thank you for correction.

Octavian

--
http://mail.python.org/mailman/listinfo/python-list


Code Review

2011-05-24 Thread ad
Hello all,

Please review the code pasted below. I am wondering what other ways
there are of performing the same tasks. This was typed using version
3.2. The script is designed to clean up a directory (FTP, Logs, etc.)
Basically you pass two arguments. The first argument is an number of
days old to delete. The second argument is the directory where the
files and folders should be deleted. I imagine one enhancement would
be to create a function out of some of this.

### BEGIN ###

import os

import time

import shutil

import argparse



CurrentTime = time.time()

epocDay = 86400   # seconds





parser = argparse.ArgumentParser(description = "Delete files and
folders in a directory N days old", add_help=False,
prog='directorycleaner', usage='%(prog)s 7 c:\\temp')

parser.add_argument('days', type=int, help="Numeric value: delete
files and folders older then N days")

parser.add_argument('directory', help="delete files and folders in
this directory")

parser.print_help()

args = parser.parse_args()



dictKeys = (vars(args))



HowManyDays = dictKeys['days']

WhatDirectory = dictKeys['directory']

print (HowManyDays)

print (WhatDirectory)



DaysToDelete = HowManyDays * epocDay





dirExists = os.path.exists(WhatDirectory)



if dirExists == False: print ("The directory is missing")



DirListing = os.listdir(WhatDirectory)



for files in DirListing:

# Get the absolute path of the file name

abspath = (os.path.join(WhatDirectory, files))

# Get the current creation time of the file in epoc format
(midnight 1/1/1970)

FileCreationTime = (os.path.getctime(abspath))

# time.ctime converts epoch to a normal date

#print (time.ctime(CurrentTime))

# Get the date from seven days ago

WeekOldFileDate = CurrentTime - DaysToDelete

#print (CurrentTime)

#print (FileCreationTime)

#print (WeekOldFileDate)



#If the file is older than seve days doe something

if FileCreationTime < WeekOldFileDate:

#check if the object is a file

if os.path.isfile(abspath): os.remove(abspath)

# It is not a file it is a directory

elif os.path.isdir(abspath): shutil.rmtree(abspath)



# END 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.2 Idle doesn't start. No error message.

2011-05-24 Thread markrrivet
On Tue, 24 May 2011 12:50:47 -0400, Terry Reedy 
wrote:

>On 5/24/2011 8:01 AM, [email protected] wrote:
>> Hello all. I have Python 2.71 installed on my Windows 7 laptop and it
>> runs fine. I was having a problem with Python 3.2, 32bit, not starting
>> with an error message saying this application has quit abnormally.
>> That was fixed when I took the PYTHONPATH statement out of my
>> environment variables. However, now when I try to start Idle, I can
>> see some hard drive activity, but Idle for Python 3.2 does not start;
>> nothing happens. Any clues as to the problem here?
>
>How do you try to start it?

>From start|programs|python and clicking on the idle icon.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: File access denied after subprocess completion on Windows platform

2011-05-24 Thread Claudiu Nicolaie CISMARU
> Seems that close_fds did the trick. Anyway, I read that description on 
> the documentation last night but I think I was so tired that I 
> understood that in Windows has no effect... :)

Now. There is one more issue. Seems that on faster computers and/or 
Windows 7 (the Win32 thing I have tested on a HVM Xen machine with 
Windows XP) the os.rename is too fast after fp.close() and generates the 
same Exception. The code follows:

curl.close()
fp.close()
os.rename(tfile, actualfile)

Where, tfile is the .part file, actual file is the real destination, fp 
was opened with open(..., "wb") and the descriptor passed to curl.

I have solved the issue with self.msleep(10) - msleep is a method of 
QThread. But I don't think it's an elegant and normal solution. Did 
fp.close() is delayed, or? I mean, I don't want to rely on a "sleep" in 
order to workaround the access issue.

On this issue there is no more process spawn, nothing, just the 
downloader thread and the main window. And the access denied appears at 
random time.

-- 
  Claudiu Nicolaie CISMARU
  GNU GPG Key: http://claudiu.targujiu.net/key.gpg
  T: +40 755 135455
  E: [email protected], [email protected]


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list


Odp: Re: Strange behaviour of input() function (Python 3.2)

2011-05-24 Thread sunrrrise
Ok, another time I'd like to thank you for your help. I gave up, I'm going to 
get used to IDLE GUI... at least this one works!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Functional Programing: stop using recursion, cons. Use map & vectors

2011-05-24 Thread asandroq
On May 24, 12:27 am, Deeyana  wrote:
>
> Classic unsubstantiated and erroneous claim. Scheme does not come OOTB
> with any suitable libraries for host interop and though it can make calls
> to C libraries, doing so is awkward and involves difficulties with the
> impedance mismatch between Scheme's data structures and C's char *, void
> *, int, double, array, etc. types. To top it off, C lacks automatic
> memory management, which means you'll have to concern yourself with
> manually disposing of allocated data structures used in interop. (Or,
> worse, things will get garbage collected by the Scheme runtime that the
> Scheme code no longer references, but the C library is still using, and
> bam! SIGSEGV.)
>

Classic unsubstantiated and erroneous claim.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Chris Angelico
On Wed, May 25, 2011 at 3:56 AM, John Bokma  wrote:
> Chris Angelico  writes:
>> To me, a language is a tool.
>
> To me, and to a lot of Perl programmers it's not different.
>
>> The more tools you have competence with, the easier it will be to
>> select the right one for any job. There are very few tools that have
>> no use whatsoever; even Ook might be useful (although I have yet to be
>> asked to port any code to OrangutanOS).  This differs from the notion
>> of having ten paradigms in one language,
>
> If this is referring to Perl: the myths surrounding "there is more than
> one way" are even more crazy than "there is only one way", maybe because
> "more than one" makes it so much easier to make those myths up?
>
> On top of that: how many paradigms does Python support?  And which
> paradigms does Perl support and Python doesn't?

You miss my point. To me, BOTH Perl AND Python are tools; there is a
time and a place for each. Also in my toolkit are C, C++, Pike, REXX,
&c, &c, &c. Even Java and ActionScript/Flash (both of which I detest
for several reasons) have their place - browser-based applications
that aren't limited to HTTP (try writing an in-browser MUD client in
Javascript). Every language has its downsides; every language has its
unique feature that makes it special. And every language I've ever
used has taught me something.

Know both. Bash both (if you feel so inclined). Use both.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.2 Idle doesn't start. No error message.

2011-05-24 Thread Terry Reedy

On 5/24/2011 4:12 PM, [email protected] wrote:

On Tue, 24 May 2011 12:50:47 -0400, Terry Reedy

How do you try to start it?



From start|programs|python and clicking on the idle icon.


OK. Works fine for me on winxp desktop and win7 laptop.
3.2.1 will be out soon. Whether or not you find a fix before that, 
download it, install, and try again. I think I would uninstall 3.2.0 
first. You could, of course, try re-installing.


I just tried
C:\Documents and Settings\Terry>set PYTHONPATH
Environment variable PYTHONPATH not defined

so undefining that should not be the problem.

The icon properties are not helpful as to how it starts IDLE.
Perhaps is uses ../python32/Lib/idlelib/idle.bat

@echo off
rem Start IDLE using the appropriate Python interpreter
set CURRDIR=%~dp0
start "%CURRDIR%..\..\pythonw.exe" "%CURRDIR%idle.pyw" %1 %2 %3 %4 %5 %6 
%7 %8 %9


In a command prompt window you could directly try something like
C:\Programs\Python32>pythonw Lib\idlelib\idle.pyw
which works for me. Make sure idlelib and idle.pyw are present.
Also check tcl/ and Lib/tkinter/

idle.pyw has
===
try:
import idlelib.PyShell
except ImportError:
# IDLE is not installed, but maybe PyShell is on sys.path:
try:
from . import PyShell
except ImportError:
raise
else:
import os
idledir = os.path.dirname(os.path.abspath(PyShell.__file__))
if idledir != os.getcwd():
# We're not in the IDLE directory, help the subprocess find 
run.py

pypath = os.environ.get('PYTHONPATH', '')
if pypath:
os.environ['PYTHONPATH'] = pypath + ':' + idledir
else:
os.environ['PYTHONPATH'] = idledir
PyShell.main()
else:
idlelib.PyShell.main()
==

PYTHONPATH does come into play if but only if two imports fail.
You could make a copy of that and add prints to see what does and does 
not execute.


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Chris Angelico
On Wed, May 25, 2011 at 3:39 AM, D'Arcy J.M. Cain  wrote:
> My point was that even proponents of the language can make a
> significant error based on the way the variable is named.  It's like
> the old Fortran IV that I first learned where the name of the variable
> determined whether it was an integer or a floating point.

I believe that's the origin of one of the proofs that God is real
(unless declared integer). And hey, I can't hate something that gave
us the classic use of i, j, k as loop indices!

> One of my favorite quotes (not sure if it was about Perl or APL) is "I
> refuse to use a programming language where the proponents of it stick
> snippets under each other's nose and say 'I bet you can't guess what
> this does.'"

Yes, I believe that was Perl. And an amusing quote. But most of the
point of it comes from the fact that Perl uses punctuation for most of
its keywords, whereas (say) Python uses English words; it's a lot more
fun to crunch something down when you can use $| and friends than when
you have to put "x and y", complete with spaces, for a simple boolean.
But that says nothing about which language is actually better for
working with... beyond the fact that Perl can get more mileage out of
an 80-character line!

> When I first looked at Perl it looked like line noise.  When I first
> looked at Python it looked like pseudo-code.

When I first looked at assembly language it looked like random junk
left behind in memory. When I first looked at COBOL it looked like ...
COBOL. Doesn't make either of them better or worse.

Pseudo-code is not a viable language for a computer to parse, but it's
a good language for scribbling down comments in. That doesn't
necessarily mean that a programming language that's "closer to"
pseudo-code is good. And verbosity doesn't necessarily equate to
quality; for instance, when I'm working in both Python and PHP, I find
it FAR tidier to use Python's {1:2,3:4] notation than PHP's
array(1=>2,3=>4) - but on the flip side, I would prefer to have
program structure defined by keywords like "if" and "while" than
obscure random line noise. (Fortunately, most sane languages do indeed
use keywords there.)

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: File access denied after subprocess completion on Windows platform

2011-05-24 Thread Terry Reedy

On 5/24/2011 4:18 PM, Claudiu Nicolaie CISMARU wrote:

Seems that close_fds did the trick. Anyway, I read that description on
the documentation last night but I think I was so tired that I
understood that in Windows has no effect... :)


Now. There is one more issue. Seems that on faster computers and/or
Windows 7 (the Win32 thing I have tested on a HVM Xen machine with
Windows XP) the os.rename is too fast after fp.close() and generates the
same Exception. The code follows:

curl.close()
fp.close()
os.rename(tfile, actualfile)

Where, tfile is the .part file, actual file is the real destination, fp
was opened with open(..., "wb") and the descriptor passed to curl.

I have solved the issue with self.msleep(10) - msleep is a method of
QThread. But I don't think it's an elegant and normal solution. Did
fp.close() is delayed, or? I mean, I don't want to rely on a "sleep" in
order to workaround the access issue.

On this issue there is no more process spawn, nothing, just the
downloader thread and the main window. And the access denied appears at
random time.


I would go with what works. In my experience, mysterious and seemingly 
buggy error messages, including Access Denied are not unusual on Windows.


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread John Bokma
Chris Angelico  writes:

> On Wed, May 25, 2011 at 3:56 AM, John Bokma  wrote:
>> Chris Angelico  writes:
>>> To me, a language is a tool.
>>
>> To me, and to a lot of Perl programmers it's not different.
>>
>>> The more tools you have competence with, the easier it will be to
>>> select the right one for any job. There are very few tools that have
>>> no use whatsoever; even Ook might be useful (although I have yet to be
>>> asked to port any code to OrangutanOS).  This differs from the notion
>>> of having ten paradigms in one language,
>>
>> If this is referring to Perl: the myths surrounding "there is more than
>> one way" are even more crazy than "there is only one way", maybe because
>> "more than one" makes it so much easier to make those myths up?
>>
>> On top of that: how many paradigms does Python support?  And which
>> paradigms does Perl support and Python doesn't?
>
> You miss my point.

Could be, English is my second language. But to me "ten paradigms in one
language" smelled of Perl bashing (or maybe Falcon bashing). My
apologies if that was not the intent.

> To me, BOTH Perl AND Python are tools; there is a time and a place for
> each. Also in my toolkit are C, C++, Pike, REXX, &c, &c, &c. Even Java
> and ActionScript/Flash (both of which I detest for several reasons)
> have their place - browser-based applications that aren't limited to
> HTTP (try writing an in-browser MUD client in Javascript). Every
> language has its downsides; every language has its unique feature that
> makes it special. And every language I've ever used has taught me
> something.
>
> Know both. Bash both (if you feel so inclined). Use both.

Can't agree more with you, thanks for the clarification.

-- 
John Bokma   j3b

Blog: http://johnbokma.com/Perl Consultancy: http://castleamber.com/
Perl for books:http://johnbokma.com/perl/help-in-exchange-for-books.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.2 Idle doesn't start. No error message.

2011-05-24 Thread markrrivet
On Tue, 24 May 2011 17:53:53 -0400, Terry Reedy 
wrote:

>On 5/24/2011 4:12 PM, [email protected] wrote:
>> On Tue, 24 May 2011 12:50:47 -0400, Terry Reedy
>>> How do you try to start it?
>>
>>> From start|programs|python and clicking on the idle icon.
>
>OK. Works fine for me on winxp desktop and win7 laptop.
>3.2.1 will be out soon. Whether or not you find a fix before that, 
>download it, install, and try again. I think I would uninstall 3.2.0 
>first. You could, of course, try re-installing.
>
>I just tried
>C:\Documents and Settings\Terry>set PYTHONPATH
>Environment variable PYTHONPATH not defined
>
>so undefining that should not be the problem.
>
>The icon properties are not helpful as to how it starts IDLE.
>Perhaps is uses ../python32/Lib/idlelib/idle.bat
>
>@echo off
>rem Start IDLE using the appropriate Python interpreter
>set CURRDIR=%~dp0
>start "%CURRDIR%..\..\pythonw.exe" "%CURRDIR%idle.pyw" %1 %2 %3 %4 %5 %6 
>%7 %8 %9
>
>In a command prompt window you could directly try something like
>C:\Programs\Python32>pythonw Lib\idlelib\idle.pyw
>which works for me. Make sure idlelib and idle.pyw are present.
>Also check tcl/ and Lib/tkinter/
>
>idle.pyw has
>===
>try:
> import idlelib.PyShell
>except ImportError:
> # IDLE is not installed, but maybe PyShell is on sys.path:
> try:
> from . import PyShell
> except ImportError:
> raise
> else:
> import os
> idledir = os.path.dirname(os.path.abspath(PyShell.__file__))
> if idledir != os.getcwd():
> # We're not in the IDLE directory, help the subprocess find 
>run.py
> pypath = os.environ.get('PYTHONPATH', '')
> if pypath:
> os.environ['PYTHONPATH'] = pypath + ':' + idledir
> else:
> os.environ['PYTHONPATH'] = idledir
> PyShell.main()
>else:
> idlelib.PyShell.main()
>==
>
>PYTHONPATH does come into play if but only if two imports fail.
>You could make a copy of that and add prints to see what does and does 
>not execute.

Thanks Terry, I will do what I can. I'll let you know how it works
out. But thanks again. Every little bit helps me get closer to the
solution.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: English Idiom in Unix: Directory Recursively

2011-05-24 Thread Chris Angelico
On Wed, May 25, 2011 at 3:40 AM, Xah Lee  wrote:
> On May 23, 9:28 pm, Chris Angelico  wrote:
>> Because I do not consider its behaviour to be errant. And I suspect
>> its main developers won't either. That's why I suggested you grab the
>> sources and make The Perfect Emacs.
>
> why don't you try http://ergoemacs.org/ ?

You miss my point. I am not desiring of a different emacs; you were
the one complaining about its shortcomings.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Beginner needs advice

2011-05-24 Thread Lew Schwartz
Here's my background:

I'm a Windows based Visual FoxPro developer, and I want to start programming
in Python. I'll be sticking to Windows (XP & 7) and my immediate needs are
to manage & display large groups of jpg's, tiff's etc... so I need form
based & graphics capable libraries (in addition to basic programming skills,
of course).

So Python 2 or 3? Add on packages/libraries? Tutorials?

Thanks!

-Lew
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Functional Programing: stop using recursion, cons. Use map & vectors

2011-05-24 Thread Chris Angelico
On Tue, May 24, 2011 at 8:27 AM, Deeyana  wrote:
> Classic unsubstantiated and erroneous claim. Scheme does not come OOTB
> with any suitable libraries for host interop and though it can make calls
> to C libraries, doing so is awkward and involves difficulties with the
> impedance mismatch between Scheme's data structures and C's char *, void
> *, int, double, array, etc. types. To top it off, C lacks automatic
> memory management, which means you'll have to concern yourself with
> manually disposing of allocated data structures used in interop. (Or,
> worse, things will get garbage collected by the Scheme runtime that the
> Scheme code no longer references, but the C library is still using, and
> bam! SIGSEGV.)

How is this fundamentally different from Python calling into C?

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread John Bokma
Chris Angelico  writes:

> On Wed, May 25, 2011 at 3:39 AM, D'Arcy J.M. Cain  wrote:
>> My point was that even proponents of the language can make a
>> significant error based on the way the variable is named.  It's like
>> the old Fortran IV that I first learned where the name of the variable
>> determined whether it was an integer or a floating point.
>
> I believe that's the origin of one of the proofs that God is real
> (unless declared integer). And hey, I can't hate something that gave
> us the classic use of i, j, k as loop indices!
>
>> One of my favorite quotes (not sure if it was about Perl or APL) is "I
>> refuse to use a programming language where the proponents of it stick
>> snippets under each other's nose and say 'I bet you can't guess what
>> this does.'"
>
> Yes, I believe that was Perl. And an amusing quote. But most of the
> point of it comes from the fact that Perl uses punctuation for most of
> its keywords,

For example?

> whereas (say) Python uses English words; it's a lot more
> fun to crunch something down when you can use $|

That's not a keyword but a special (global) variable. On top of that,
you don't have to use it [1] and most people most likely encounter this in
(badly) written CGI scripts originating in the last century.

Yes, Perl is fantastic for writing hard to read obfuscated code. And
yes, newbies are great at writing this from the very start, especially
since they seem to copy paste examples written by other newbies (often
written in the previous century...). But Perl doesn't force one to write
unreadable code. If Perl was really so unreadable, why haven't I /still/
not switched to Python? What keeps me going back to Perl?

> and friends than when you have to put "x and y", complete with spaces,
> for a simple boolean.

Perl has also the and logical operator. This is legal Perl:

if ( $x and $y ) {
  print "yes\n";
}

[1] You can use $OUTPUT_AUTOFLUSH (use English;), or use IO::Handle and
use the autoflush method [2].

[2] In Perl 5.14 IO::File is now loaded on demand:

http://search.cpan.org/dist/perl/pod/perldelta.pod#Filehandle_method_calls_load_IO::File_on_demand

-- 
John Bokma   j3b

Blog: http://johnbokma.com/Perl Consultancy: http://castleamber.com/
Perl for books:http://johnbokma.com/perl/help-in-exchange-for-books.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread Chris Angelico
On Wed, May 25, 2011 at 9:16 AM, John Bokma  wrote:
> Chris Angelico  writes:
>
>> Yes, I believe that was Perl. And an amusing quote. But most of the
>> point of it comes from the fact that Perl uses punctuation for most of
>> its keywords,
>
> For example?
>
>> whereas (say) Python uses English words; it's a lot more
>> fun to crunch something down when you can use $|
>
> That's not a keyword but a special (global) variable. On top of that,
> you don't have to use it [1] and most people most likely encounter this in
> (badly) written CGI scripts originating in the last century.

Okay, poor example. But there's a lot of Perl that uses concise
notation for things that in Python are keyworded; for instance,
regular expressions. I'm insufficiently fluent in Perl to quote good
examples; mainly what I'm referring to is the notion of operators that
are separators, as opposed to keywords that get blank-delimited. I
generally prefer syntactic elements to be punctuation (eg { } rather
than BEGIN and END (or DO and END)). It does also make things easier
to crunch, for better or for worse.

>> and friends than when you have to put "x and y", complete with spaces,
>> for a simple boolean.
>
> Perl has also the and logical operator. This is legal Perl:
>
> if ( $x and $y ) {
>  print "yes\n";
> }

That's at a completely different precedence level, isn't it? For
operators up where you expect them to be, there's && and ||. A bit of
digging (why isn't this sort of thing always the first hit for " operator precedence" in Google?) brought up:

http://perldoc.perl.org/perlop.html

For instance:

$a = $b && $c ? $e : $f;
# versus
$a = $b and $c ? $e : $f;

The first one is an assignment to $a, conditional on two variables.
The second is an unconditional assignment to $a, and then based on
that, evaluates either $e or $f and does nothing with it.

Python:
a = e if b and c else f

It's pretty similar, actually (although, coming from a C background, I
do prefer to have the condition first); but I could crunch the first
one down a lot, while the last one is almost as tight as it can be.

$a=$b&&$c?$e:$f;
a=e if b and c else f

It's that crunched appearance that makes Perl look like line noise,
and the open keyworded appearance that makes Python look like
pseudocode. But that's not necessarily a good thing; a courteous
programmer can space out Perl to keep it readable, and he then has the
option of crunching pieces that are 'logically one' and spacing out
the parts that aren't:

$a= $b&&$c ? $e : $f;

Silly, contrived example, but in production code I've often had
situations where it makes sense to space out one part of an expression
and crunch another. And when everything's an English word, that's not
an available option.

Oh, and that's ignoring the issue that not everyone is fluent in English.

That said, though, I do find Python a lot easier for reading other
people's code in. A LOT easier.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Faster Recursive Fibonacci Numbers

2011-05-24 Thread Raymond Hettinger
On May 17, 8:50 am, RJB  wrote:
> I noticed some discussion of recursion. the trick is to find a
> formula where the arguments are divided, not decremented.
> I've had a "divide-and-conquer" recursion for the Fibonacci numbers
> for a couple of years in C++ but just for fun rewrote it
> in Python.  It was easy.  Enjoy.  And tell me how I can improve it!
>
> def fibo(n):
>         """A Faster recursive Fibonaci function
> Use a formula from Knuth Vol 1 page 80, section 1.2.8:
>            If F[n] is the n'th Fibonaci number then
>                    F[n+m] = F[m]*F[n+1] + F[m-1]*F[n].
>   First set m = n+1
>    F[ 2*n+1 ] = F[n+1]**2 + F[n]*2.
>
>   Then put m = n in Knuth's formula,
>            F[ 2*n ] = F[n]*F[n+1] + F[n-1]* F[n],
>    and replace F[n+1] by F[n]+F[n-1],
>            F[ 2*n ] = F[n]*(F[n] + 2*F[n-1]).
> """
>         if n<=0:
>                 return 0
>         elif n<=2:
>                 return 1
>         elif n%2==0:
>                 half=n//2
>                 f1=fibo(half)
>                 f2=fibo(half-1)
>                 return f1*(f1+2*f2)
>         else:
>                 nearhalf=(n-1)//2
>                 f1=fibo(nearhalf+1)
>                 f2=fibo(nearhalf)
>                 return f1*f1 + f2*f2
>
> RJB the Lurkerhttp://www.csci.csusb.edu/dick/cs320/lab/10.html

There are many ways to write this function.  The one I like shows-off
a general purpose dynamic programming technique while staying *very*
close to a common textbook definition of a fibonacci number:

@functools.lru_cache()
def fibo(n):
return 1 if n < 2 else fibo(n-1) + fibo(n-2)

Raymond
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: English Idiom in Unix: Directory Recursively

2011-05-24 Thread Rikishi42
On 2011-05-24, Steven D'Aprano  wrote:
>>> I think that is a patronizing remark that under-estimates the
>>> intelligence of lay people and over-estimates the difficulty of
>>> understanding recursion.
>> 
>> Why would you presume this to be related to intelligence? The point was
>> not about being *able* to understand, but about *needing* to understand
>> in order to use.
>
> Maybe they don't "need" to understand recursion. So what?

I think you should read the earlier posts again, this is drifting so far
from what I intended.

What I mean is: I'm certain that over the years I've had more than one
person come to me and ask what 'Do you wish to delete this directory
recursively?' meant. BAut never have I been asked to explain what 'Do you
wish to delete this directory and it's subdirs/with all it's contents?'
meant. Never.
 

> Recursion is a perfectly good English word, no more technical than 
> "accelerate" or "incinerate" or "dissolve" or "combustion". Do people 
> need to know the word "combustion" when they could say "burn" instead? 

It wasn't about the word, but about the nature of the function. Besides, if
the chance exists of a confusion between a recursive job and the fact the
job is done using a recursive function... I would try staying away from the
expression.  

Why not use 'delete a directory'. It's obvious the content gets binned, too.


Do you know many people who incinerate leaves and branches in their garden? 
I burn them.


> Do they need to know the words "microwave oven" when they could be saying
> "invisible rays cooking thing"?

The word oven has existed for ages, microwave is just a name for the type of
oven. Not even a description, just a name.


> I wonder whether physicists insist that cars should have a "go faster 
> pedal" because ordinary people don't need to understand Newton's Laws of 
> Motion in order to drive cars?

Gas pedal. Pedal was allraedy known when the car was invented. The simple
addition of gas solved that need. Oh, and it's break pedal, not
descellarator. (sp?)


> Who are you to say that people shouldn't be exposed to words you deem 
> that they don't need to know?

I'm one of the 'people'. You say exposed to, I say bothered/bored with.

I have nothing against the use of a proper, precise term. And that word can
be a complex one with many, many sylables (seems to add value, somehow).

But I'm not an academic, so I don't admire the pedantic use of terms that
need to be explained to 'lay' people. Especially if there is a widespread,
usually shorter and much simpler one for it. A pointless effort if
pointless, even when comming from a physicist.  :-)


-- 
When in doubt, use brute force.
-- Ken Thompson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Functional Programing: stop using recursion, cons. Use map & vectors

2011-05-24 Thread Deeyana
On Tue, 24 May 2011 13:39:15 -0700, asandroq wrote:

> On May 24, 12:27 am, Deeyana  wrote:
>>
>> Classic unsubstantiated and erroneous claim. Scheme does not come OOTB
>> with any suitable libraries for host interop and though it can make
>> calls to C libraries, doing so is awkward and involves difficulties
>> with the impedance mismatch between Scheme's data structures and C's
>> char *, void *, int, double, array, etc. types. To top it off, C lacks
>> automatic memory management, which means you'll have to concern
>> yourself with manually disposing of allocated data structures used in
>> interop. (Or, worse, things will get garbage collected by the Scheme
>> runtime that the Scheme code no longer references, but the C library is
>> still using, and bam! SIGSEGV.)
>
> Classic unsubstantiated and erroneous claim.

On your part, asandroq.
-- 
http://mail.python.org/mailman/listinfo/python-list


Link errors embedding Python 3.2

2011-05-24 Thread Chris Angelico
I'm starting to feel incredibly stupid here. Hopefully someone can
point out a really obvious thing that I've missed, thus enabling me to
move forward!

Up until now, I've been embedding Python 2.6.6 in my C++ program, by
compiling with "-I/usr/include/python2.6 -lpython2.6", and all has
been well. The Python I use was installed as part of Ubuntu's setup,
and is managed by apt-get. Now, I'm trying to switch to using Python
3. so I downloaded the 3.2 sources and did the usual './configure;
make; sudo make install', then snooped to see where it had put things.
I'm now compiling with "-I/usr/local/include/python3.2m -lpython3.2m",
and it's compiling successfully (now that I've changed the function
names eg PyString --> PyBytes), but the link fails with heaps of
undefined references - as far as I can tell, every single Py*
reference is failing.

There is a libpython3.2m.a accessible, and poking around with ar and
nm shows that it does contain object files with the necessary symbols.
If I deliberately misspell the -lpython3.2m option, the link bombs
immediately, so presumably it IS finding the library. Explicitly
naming the library as ~/Python-3.2/libpython3.2m.a (or using ar to
extract them and then linking against the whole directoryful of .o
files, which does the same thing) cures the undefined references to
Py* functions, but brings in undefined refs to dlsym and openpty and
family.

Is/are there additional library/ies that I need to be linking against
for Python 3? And why is the usual -lpython3.2m not working as normal?
Is there a problem with C++ and Python? (I tried surrounding #include
"Python.h" with extern "C" { }, but to no avail.)

Hoping that someone has already done this!

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Subject: mrjob v0.2.6 released

2011-05-24 Thread Jimmy Retzlaff
What is mrjob?
-
mrjob is a Python package that helps you write and run Hadoop Streaming jobs.

mrjob fully supports Amazon's Elastic MapReduce (EMR) service, which
allows you to buy time on a Hadoop cluster on an hourly basis. It also
works with your own Hadoop cluster.

Some important features:

 * Run jobs on EMR, your own Hadoop cluster, or locally (for testing).
 * Write multi-step jobs (one map-reduce step feeds into the next)
 * Duplicate your production environment inside Hadoop
   * Upload your source tree and put it in your job's $PYTHONPATH
   * Run make and other setup scripts
   * Set environment variables (e.g. $TZ)
   * Easily install python packages from tarballs (EMR only)
   * Setup handled transparently by mrjob.conf config file
 * Automatically interpret error logs from EMR
 * SSH tunnel to hadoop job tracker on EMR
 * Minimal setup
   * To run on EMR, set $AWS_ACCESS_KEY_ID and $AWS_SECRET_ACCESS_KEY
   * To run on your Hadoop cluster, install simplejson and make sure
$HADOOP_HOME is set.

More info:

 * Install mrjob: python setup.py install
 * Documentation: http://packages.python.org/mrjob/
 * PyPI: http://pypi.python.org/pypi/mrjob
 * Development is hosted at github: http://github.com/Yelp/mrjob


What's new?
-
v0.2.6, 2011-05-24 -- fix bootstrapping mrjob
 * Set Hadoop to run on EMR with --hadoop-version (Issue #71).
   * Default is still 0.18, but will change to 0.20 in mrjob v0.3.0.
 * New inline runner, for testing locally with a debugger
 * New --strict-protocols option, to catch unencodable data (Issue #76)
 * Added steps_python_bin option (for use with virtualenv)
 * mrjob no longer chokes when asked to run on an EMR job flow running
Hadoop 0.20 (Issue #110)
 * mrjob no longer chokes on job flows with no LogUri (Issue #112)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner needs advice

2011-05-24 Thread memilanuk

On 05/24/2011 03:17 PM, Lew Schwartz wrote:

Here's my background:

I'm a Windows based Visual FoxPro developer, and I want to start
programming in Python. I'll be sticking to Windows (XP & 7) and my
immediate needs are to manage & display large groups of jpg's, tiff's
etc... so I need form based & graphics capable libraries (in addition to
basic programming skills, of course).

So Python 2 or 3? Add on packages/libraries? Tutorials?

Thanks!

-Lew





If Visual Foxpro is your thing, maybe Dabo (www.dabodev.com) would be of 
interest to you.  The developers are former Visual Foxpro programmers...


--
http://mail.python.org/mailman/listinfo/python-list


Re: English Idiom in Unix: Directory Recursively

2011-05-24 Thread Chris Angelico
On Wed, May 25, 2011 at 8:06 AM, Rikishi42  wrote:
> On 2011-05-24, Steven D'Aprano  wrote:
> Why not use 'delete a directory'. It's obvious the content gets binned, too.

Which is why I raised the issue with regard to other operations.
Manipulating files matching a glob can be done recursively or
nonrecursively, and both make perfect sense.

> Do you know many people who incinerate leaves and branches in their garden?
> I burn them.

We used to incinerate ours (until we stopped using rapid exothermic
oxidation as a means of DECREFfing our garden waste). It's a cultural
thing, I guess.

>> Do they need to know the words "microwave oven" when they could be saying
>> "invisible rays cooking thing"?
>
> The word oven has existed for ages, microwave is just a name for the type of
> oven. Not even a description, just a name.

It's funny how a single piece of jargon can go incredibly mainstream.
"Microwave" (with or without "oven" after it) is well known, but
plenty else remains obscure.

>> I wonder whether physicists insist that cars should have a "go faster
>> pedal" because ordinary people don't need to understand Newton's Laws of
>> Motion in order to drive cars?
>
> Gas pedal. Pedal was allraedy known when the car was invented. The simple
> addition of gas solved that need. Oh, and it's break pedal, not
> descellarator. (sp?)

Americans might call it a gas pedal. We call it an accelerator. You
don't have a "decelerator pedal" though, because it's more accurately
called a "brake pedal" because it controls the brakes.

Personally, I'm of the opinion that people *should* have some basic
understanding of Newton's laws before they take charge of a ton of
high-powered machinery. At very least, some basic comprehension of
kinetic energy, and the way a high speed train has a *LOT* of it.
Might result in drivers with a little more respect for trains and
trucks.

>> Who are you to say that people shouldn't be exposed to words you deem
>> that they don't need to know?
>
> I'm one of the 'people'. You say exposed to, I say bothered/bored with.
>
> I have nothing against the use of a proper, precise term. And that word can
> be a complex one with many, many sylables (seems to add value, somehow).
>
> But I'm not an academic, so I don't admire the pedantic use of terms that
> need to be explained to 'lay' people. Especially if there is a widespread,
> usually shorter and much simpler one for it. A pointless effort if
> pointless, even when comming from a physicist.  :-)

In any industry, you can find jargon in several different categories:

1) Terms that describe unique objects/effects/etc, where you would be
using a lengthy phrase otherwise (eg "URL")

2) Terms that are clearer or more precise than the less-jargonny
equivalents, but where you could get away with dodging jargon if you
wanted to (eg "recursive operation")

3) Words and phrases that have little value to an end user, but can be
used to show off your skill (eg "Network Destabilisation from Low
Voltage Fluorescent Lamp Spikes").

I would never apologise for using terms in the first category. Just
explain them (in a footnote if necessary) and expect people to be
accurate. The third category is mainly used for invoking Dummy Mode
(if you don't know what that is, google my example - it's vintage
BOFH), and should be avoided. It's the middle lot that are harder. Do
you use it and risk people not understanding, or avoid it and risk
people misunderstanding? Tough choice, especially since those who
misunderstand often won't know why.

If we forever aim to the stupidest of humans, the human race will get
stupider. If we forever aim way above people's heads, they won't
bother to communicate. An eternal dilemma.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-24 Thread John Bokma
Chris Angelico  writes:

> On Wed, May 25, 2011 at 9:16 AM, John Bokma  wrote:
>> Chris Angelico  writes:
>>
>>> Yes, I believe that was Perl. And an amusing quote. But most of the
>>> point of it comes from the fact that Perl uses punctuation for most of
>>> its keywords,
>>
>> For example?
>>
>>> whereas (say) Python uses English words; it's a lot more
>>> fun to crunch something down when you can use $|
>>
>> That's not a keyword but a special (global) variable. On top of that,
>> you don't have to use it [1] and most people most likely encounter this in
>> (badly) written CGI scripts originating in the last century.
>
> Okay, poor example. But there's a lot of Perl that uses concise
> notation for things that in Python are keyworded; for instance,
> regular expressions.

Perl does have indeed operators for matching and substitution. It's:

( my $foo = $bar ) =~ s/ ... / ... /;

versus

foo = re.sub(r" ... ", " ... ", bar )

and:

my $foo = qr/

...

/xi;

versus:

foo = re.compile(r"""

...

""", re.IGNORECASE|re.VERBOSE)

It's just a matter of taste IMO. The regular expression noise stays the
same ;-).

>>> and friends than when you have to put "x and y", complete with spaces,
>>> for a simple boolean.
>>
>> Perl has also the and logical operator. This is legal Perl:
>>
>> if ( $x and $y ) {
>>  print "yes\n";
>> }
>
> That's at a completely different precedence level, isn't it? 

Yes, /but/ in this case it doesn't matter. Of course there are cases
that it /does/ matter:

> For instance:
>
> $a = $b && $c ? $e : $f;
> # versus
> $a = $b and $c ? $e : $f;
>
> The first one is an assignment to $a, conditional on two variables.
> The second is an unconditional assignment to $a, and then based on
> that, evaluates either $e or $f and does nothing with it.
>
> Python:
> a = e if b and c else f

Yes, "recently" added to the language, before that you had to and or
your way out of it (or use lambdas).

> It's pretty similar, actually (although, coming from a C background, I
> do prefer to have the condition first); but I could crunch the first
> one down a lot, while the last one is almost as tight as it can be.
>
> $a=$b&&$c?$e:$f;
> a=e if b and c else f
>
> It's that crunched appearance that makes Perl look like line noise,

So you just agree with what I earlier wrote: one /can/ write harder to
read in Perl, like you can jump off a cliff. And I have seen a lot of
extremely badly written Perl code, but never seen a disaster like the
one above ;-).

> and the open keyworded appearance that makes Python look like
> pseudocode. But that's not necessarily a good thing; a courteous
> programmer can space out Perl to keep it readable, and he then has the
> option of crunching pieces that are 'logically one' and spacing out
> the parts that aren't:
>
> $a= $b&&$c ? $e : $f;
>
> Silly, contrived example, but in production code I've often had
> situations where it makes sense to space out one part of an expression
> and crunch another. And when everything's an English word, that's not
> an available option.

I would write it like

$a = ( $b and $c ) ? $e : $f;

> That said, though, I do find Python a lot easier for reading other
> people's code in. A LOT easier.

Like I wrote earlier: I find Perl easier to read. And honestly, I don't
know why. Partially it might have a lot to do with having been exposed
to it much more. But many years back, when I could pick between several
languages, Perl was the one that stuck with me. And that was before
everybody and his mom was hacking CGI scripts in Perl (badly).

And while I do want to switch to Python (or use it more often), for one
reason or another it's hard. Maybe it's for similar reasons that one
loves Spanish but hates German as a second language (or vice versa)?

Both Perl and Python are evolving. Perl has a lot of bagage from the
beginning, and more so since a lot got slapped on later on. Things are
changing, but you just can't make major changes since people, like me I
guess, are used to how things are right now.

I now and then have peeks at Perl 6 and each time my first reaction is:
this is Perl only in name; it's very, very different. On the other hand
it still shares what I consider warts with Perl 5.

-- 
John Bokma   j3b

Blog: http://johnbokma.com/Perl Consultancy: http://castleamber.com/
Perl for books:http://johnbokma.com/perl/help-in-exchange-for-books.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Abandoning Python

2011-05-24 Thread Paul Rubin
John Lee  writes:
> In this thread, I'm asking about the views of Python programmers on
> languages other than Python.  

I sympathize with what you're looking for but I don't think there's
a really good answer at this time.  Things IMO are converging in the
direction of functional languages like Haskell but it seems to
me that there is a big gap between the current academic ideas and
what makes sense for working programmers.  The academics aren't
all that concerned with practicality, but good solutions really
have to incorporate their ideas since the rest of us are rather
badly behind the times.

Haskell probably has the most vibrant development community at
the moment but its learning curve is quite steep, and it has
various shortcomings some of which are being worked on but others
of which may be insurmountable.

If you like the Java ecosystem but not the Java language, check
out Scala.

You could look for the article "The Next Mainstream Programming
Languages" by Tim Sweeney.  It discusses similar issues to what I
think you are facing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: English Idiom in Unix: Directory Recursively

2011-05-24 Thread Xah Lee
On May 24, 3:06 pm, Rikishi42  wrote:
> On 2011-05-24, Steven D'Aprano  wrote:
>
> >>> I think that is a patronizing remark that under-estimates the
> >>> intelligence of lay people and over-estimates the difficulty of
> >>> understanding recursion.
>
> >> Why would you presume this to be related to intelligence? The point was
> >> not about being *able* to understand, but about *needing* to understand
> >> in order to use.
>
> > Maybe they don't "need" to understand recursion. So what?
>
> I think you should read the earlier posts again, this is drifting so far
> from what I intended.
>
> What I mean is: I'm certain that over the years I've had more than one
> person come to me and ask what 'Do you wish to delete this directory
> recursively?' meant. BAut never have I been asked to explain what 'Do you
> wish to delete this directory and it's subdirs/with all it's contents?'
> meant. Never.
>
> > Recursion is a perfectly good English word, no more technical than
> > "accelerate" or "incinerate" or "dissolve" or "combustion". Do people
> > need to know the word "combustion" when they could say "burn" instead?
>
> It wasn't about the word, but about the nature of the function. Besides, if
> the chance exists of a confusion between a recursive job and the fact the
> job is done using a recursive function... I would try staying away from the
> expression.  
>
> Why not use 'delete a directory'. It's obvious the content gets binned, too.
>
> Do you know many people who incinerate leaves and branches in their garden?
> I burn them.
>
> > Do they need to know the words "microwave oven" when they could be saying
> > "invisible rays cooking thing"?
>
> The word oven has existed for ages, microwave is just a name for the type of
> oven. Not even a description, just a name.
>
> > I wonder whether physicists insist that cars should have a "go faster
> > pedal" because ordinary people don't need to understand Newton's Laws of
> > Motion in order to drive cars?
>
> Gas pedal. Pedal was allraedy known when the car was invented. The simple
> addition of gas solved that need. Oh, and it's break pedal, not
> descellarator. (sp?)
>
> > Who are you to say that people shouldn't be exposed to words you deem
> > that they don't need to know?
>
> I'm one of the 'people'. You say exposed to, I say bothered/bored with.
>
> I have nothing against the use of a proper, precise term. And that word can
> be a complex one with many, many sylables (seems to add value, somehow).
>
> But I'm not an academic, so I don't admire the pedantic use of terms that
> need to be explained to 'lay' people. Especially if there is a widespread,
> usually shorter and much simpler one for it. A pointless effort if
> pointless, even when comming from a physicist.  :-)

very well said, Rikishi42.

this one is probably the most intelligent post in this thread.

 Xah
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner needs advice

2011-05-24 Thread Lew Schwartz
So, if I read between the lines correctly, you recommend Python 3? Does the
windows version install with a development environment?
-- 
http://mail.python.org/mailman/listinfo/python-list