Re: count strangeness

2011-05-22 Thread Chris Rebert
On Sat, May 21, 2011 at 11:32 PM, James Stroud  wrote:
> Chris Rebert wrote:
>>>
>>> WTF?
>>
>> Assuming your question is "Why is 1024 there twice?", the answer is
>
> The question is "Why is 1024 there at all?" It should be 10.

Ah. This is why it's better to be more explicit about what your
question is than a mere "WTF?".

In that case, I believe you meant to write:
count += c.doit()
rather than:
count += c.doit(count)

Recall that count is continually increasing as you go through your loop.

Although you'll then get 11, not 10, but the cause of that is obvious
(`count += 1`).

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


Re: count strangeness

2011-05-22 Thread James Stroud

Peter Otten wrote:

James Stroud wrote:

WTF?


Put the code into a file, run it -- and be enlightened ;)


Compare the follower to the last.

tal 77% cat eraseme.py
#! /usr/bin/env python

class C:
  def __init__(self):
self.data = []
  def doit(self, count=[0]):
for c in self.data:
  c.doit()
count[0] += 1
print count[0]

c = C()
c.data.extend([C() for i in xrange(10)])
c.doit()
tal 78% python2.7 eraseme.py
1
2
3
4
5
6
7
8
9
10
11

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


Re: count strangeness

2011-05-22 Thread James Stroud

Chris Rebert wrote:

On Sat, May 21, 2011 at 11:32 PM, James Stroud  wrote:

Chris Rebert wrote:

WTF?

Assuming your question is "Why is 1024 there twice?", the answer is

The question is "Why is 1024 there at all?" It should be 10.


Ah. This is why it's better to be more explicit about what your
question is than a mere "WTF?".

In that case, I believe you meant to write:
count += c.doit()
rather than:
count += c.doit(count)


I get it. Thank you.

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


Re: count strangeness

2011-05-22 Thread Peter Otten
James Stroud wrote:

> Peter Otten wrote:
>> James Stroud wrote:
>>> WTF?
>> 
>> Put the code into a file, run it -- and be enlightened ;)
> 
> 
> tal 72% python2.7 eraseme.py
> 1
> 2
> 4
> 8tal 73% cat eraseme.py
> #! /usr/bin/env python
> 
> class C:
>def __init__(self):
>  self.data = []
>def doit(self, count=0):
>  for c in self.data:
>count += c.doit(count)
>  count += 1
>  print count
>  return count
> 
> c = C()
> c.data.extend([C() for i in xrange(10)])
> c.doit()
> tal 74% python2.7 eraseme.py
> 1
> 2
> 4
> 8
> 16
> 32
> 64
> 128
> 256
> 512
> 1024
> 
> 
> Hmmm. It's still 1024.
> 
> What am I missing?
> 
> James

Like Chris I assumed that you wondered why 1024 appeared twice. It turns out 
WTF is not a got a good problem description.

Now for a complete run-through, the inner c.doit() has len(c.data) == 0, so 
count += c.doit(count) just adds count + 1 and you get 10 iterations:

(1) count=0, print 1, add 1
(2) count=1, print 2, add 2
(3) count=3, print 4, add 4
(4) count=7, print 8, add 8
(5) you get the idea

Another way to look at it: in your special case the inner loop can be 
rewritten as

for c in self.data:
print count + 1
count += count + 1

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


Re: Why did Quora choose Python for its development?

2011-05-22 Thread Octavian Rasnita
From: "Hansmeet Singh" 

>i think we should end our butchering of perl on a light note (you may have
> already read this):
> EXTERIOR: DAGOBAH -- DAY
> With Yoda strapped to his back, Luke climbs up one of
> the many thick vines that grow in the swamp until he
> reaches the Dagobah statistics lab. Panting heavily, he
> continues his exercises -- grepping, installing new
> packages, logging in as root, and writing replacements for
> two-year-old shell scripts in Python.
> 
> YODA: Code!  Yes.  A programmer's strength flows from code
>  maintainability.  But beware of Perl.  Terse syntax... more
>  than one way to do it...  default variables.  The dark side
>  of code maintainability are they.  Easily they flow, quick
>  to join you when code you write.  If once you start down the
>  dark path, forever will it dominate your destiny, consume
>  you it will.
> 
> LUKE: Is Perl better than Python?
> 
> YODA: No... no... no.  Quicker, easier, more seductive.
> 
> LUKE: But how will I know why Python is better than Perl?
> 
> YODA: You will know.  When your code you try to read six months
>  from now.
> 


I've noticed that on many Perl mailing lists the list members talk very rarely 
about Python, but only on this Python mailing list I read many discussions 
about Perl, in which most of the participants use to agree that yes, Python is 
better, as it shouldn't be obvious that most of the list members prefer Python.

If Python would be so great, you wouldn't talk so much about how bad are other 
languages, or if these discussions are not initiated by envy, you would be also 
talking about how bad is Visual Basic, or Pascal, or Delphi, or who knows other 
languages.

A few months ago I have asked how can I create a dictionary from a list, and 
there were so many techniques that I think that it is just a buzzword that in 
Perl there are many ways to do it, while in Python there is a single way. In 
Python I found from the messages I received on this mailing list that there are 
a lot of ways, without even beeing a "recommended" way, while in Perl there is 
a single way, of course much shorter and clearer.

A bad program can be written in any language, no matter if it is so strict and 
forces the programmer to use spaces as a way of defining the blocks of code, so 
the fact that Perl is very flexible is an advantage for the programmer who 
writes the code.

Perl offers the module Perl::Critic which offers a command line that checks the 
code for different levels of syntax errors which don't respect the good 
practices (which are also published in a book) so if the program has to be used 
by more programmers, it is very simple to bring it to a very standard syntax.

Perl also has Perl::Tidy that offers another command line which re-arrange the 
code to a standard way, including the indentation type, the placement of 
parenthesis, spacing and other things, so the programs can look visually the 
same.

And these are advantages for those that need to read the code by others also.

Because of its flexibility, Perl offers more advanced modules and libraries 
which are not available for Python. For example, Catalyst web framework is much 
powerful and flexible than any other Python framework, because it can be used 
with any ORM, with any templating system, with any form processor, with any 
type of configuration files (Apache style, ini, JSON, XML, perl data 
structures, yaml), and it can run with its own web server, or with mod_perl, 
FastCGI, cgi, psgi without any change, and it has a very clean and flexible URL 
dispatcher that doesn't need to do (and maintain) the URL mapping in a distinct 
module made only for this.
A Catalyst based application is very easy to maintain because it has a very 
clean structure and the command lines that can be used to automaticly generate 
the base for controllers, models or views also generate the base test files and 
also create a few basic tests for the created modules, beeing very easy to add 
new tests.

And DBIx::Class ORM is a very powerful ORM and Template-Toolkit a great 
templating system, and Moose can be used to create a very powerful object 
model, and there are a lot of other very good modules which are not available 
for other languages.

It can be hard to find the good quality Perl code while you don't know where to 
look for though. This is right, because the web is full of old-style Perl code 
since the era of Matt's Perl script archive, and the web is also full of 
pirated books about using CGI, but talking about that bad style code shows just 
that you are talking about something you don't know.

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.

Octavian

-- 
http://mail.python.org/mailman/listi

more than just ipython broken in windows

2011-05-22 Thread rusi
Earlier I asked about a problem with ipython in windows which does not
seem to be there in linux.

Now I find that a similar problem surfaces with turtle -- so it
seemingly is not so much an ipython problem.  The problem can be seen
thus:

Lets say I want to try out some turtle commands such as:

from turtle import *
forward(100)
left(90)
forward(200)
-

Run from a file there's no issue.
Likewise I can run these commands one after the other from an
interactive prompt in a shell and they work as expected.

But if I run these commands one after another at the interactive
prompt inside emacs,
it hangs after the first forward(100)

ie the canvas and a line and arrow come up but control does not seem
to return to the prompt.

More general question: When a question was asked: "Which IDE you use
for python development?", 'emacs' was a frequent response.  Are any of
you emacs+python users on windows? [Or am I a dinosaur?]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-22 Thread Daniel Kluev
On Sun, May 22, 2011 at 6:44 PM, Octavian Rasnita  wrote:
> Because of its flexibility, Perl offers more advanced modules and libraries 
> which are not available for Python.

What 'flexibility' are you talking about? This seem to be very biased
statement, based on lack of according python experience.

There are many python web frameworks which allow you to use w/e
interfaces, template languages and ORMs you want - Pyramid/Pylons is
good example.
'Very powerful' and 'great' are 'very useless' descriptions of these
modules. Please, show us what exactly is so 'advanced' about them
which cannot be done in python.

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


Re: checking if a list is empty

2011-05-22 Thread Ian

On 12/05/2011 04:51, Chris Angelico wrote:

On Thu, May 12, 2011 at 7:02 AM, Ian  wrote:

In the "real world"  lists of zero items do not exist.
You don't go shopping with a shopping list of zero items.

Actually, yes you do. You maintain your shopping list between trips;
whenever you need something, you put it on the list immediately. Then
when you go shopping, you just take the list with you (if you're
lucky, you don't need to move or copy it at all, you just get another
reference to it). Once you're done, you empty the list - you now have
a shopping list with zero items (until you get home and realize you
forgot something).

Chris Angelico

He He.

I didn't claim an empty list was not useful!   If you maintain it 
between trips, then

yes, you arrive back with an empty list.

Ian



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


Re: how to get PID from subprocess library

2011-05-22 Thread Kushal Kumaran
On Sat, May 21, 2011 at 6:20 PM, TheSaint  wrote:
> Kushal Kumaran wrote:
>
>> That's how it is able to give you the status.  So, if you
>> are using getstatusoutput, you will have only one instance of your
>> command running.
>
> My intent is to launch only one program instance, which will goes as daemon.
> To avoid a second call I'd like rather to use Python than
> ==code=
>    def start(self):
>        '''try to start aria2c as a daemon and return its handle to where it
> can
>        proceed to issue commands'''
>
>        # aria2c is running, then don't try it again
>        if (chkout('ps -A |grep aria2c')[0] > 0):
>            try:
>                chkout(self.ARIA_CMD)
>            except:
>                raise SystemExit('aria2c is not working as deamon')
>        elif self.handle: return self.handle
>        # everything is good, it will return an handle
>        self.handle= \
>        xmlrpclib.ServerProxy('http://localhost:%s/rpc' %int(self.numport))
>        return self.handle
> ==code=
>
> Here I've named subprocess.getstatusoutput as chkout, I'm calling 2 more
> programs to find whether there's a running instance of aria2c. I think it's
> not nice, python libraries should get the matter done.
>

Unfortunately, because of the way daemons work, you will not be able
to do this (there's some trickery with ptrace and similar tools, but
surely there must be simpler ways for you).

Here's a very simplified view of a typical daemon's startup:

- your process (let's call it pid1) starts a program which says it
will daemonize (let's call it pid2).

- pid2 forks an additional process (pid3), then pid2 exits

- pid1 gets the exit status of its own child (pid2)

Accordingly, even if you get a PID, it will only be pid2, which is not
the PID of the daemon process.  You will need some other way of
getting at the daemon's PID.

You could look for a way to make aria2c not become a daemon and use
subprocess.Popen to start it.  That gives you the PID and ways to see
if the process is still running.

-- 
regards,
kushal
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-22 Thread Octavian Rasnita
From: "Daniel Kluev" 

> On Sun, May 22, 2011 at 6:44 PM, Octavian Rasnita  wrote:
>> Because of its flexibility, Perl offers more advanced modules and libraries 
>> which are not available for Python.
> 
> What 'flexibility' are you talking about? This seem to be very biased
> statement, based on lack of according python experience.

I am talking about that flexibility which was criticized in the previous 
messages telling that this flexibility allows any programmer to use his own way.
Perl doesn't force anyone to indent the code, don't force the programmer to 
define a hash element before using it, allow the programmer to interpret the 
variables in strings directly. These things should be not used always, but if 
in some cases if the programmer wants to use them, he can use them with no 
problems. And this means flexibility.

> There are many python web frameworks which allow you to use w/e
> interfaces, template languages and ORMs you want - Pyramid/Pylons is
> good example.
> 'Very powerful' and 'great' are 'very useless' descriptions of these
> modules. Please, show us what exactly is so 'advanced' about them
> which cannot be done in python.


Every language can do almost anything, so this is not important, because the 
Python programmers didn't chose Python because it can do what other languages 
cannot do.

It is important how easy is to create an app with it, and while Python offers 
helpful features for creating desktop apps, for creating web apps Perl is 
better.

Here is a text from the documentation of Pyramid/Pylons:

"We finally need to add some routing elements to our application configuration 
if we want our view functions to be matched to application URLs.
... 
# routes setup 
config.add_route('list', '/') 
config.add_route('new', '/new') 
config.add_route('close', '/close/{id}') 
"
...

First, this is a bad style of mapping urls, because this list must be 
maintained every time the programmer changes something in a controller that 
makes the app need to use other urls.
Catalyst don't need this overhead and don't need to specify the url mapping in 
a separate module. If the controllers change, then the url dispatching also 
changes.

Second, this way of url dispatching is not so flexible, because it doesn't 
allow as many types of url mappings.
Catalyst allows to dispatch the urls to actions based on controllers and 
subroutines names, globally or locally (based on the current controller), it 
allows dispatching based on regular expressions, it allows a chained dispatch 
where more actions are executed in a certain order on a single request, and all 
these without typing code outside of the subroutines that do the actions.

The module DBIx::Class which is used usually as an ORM can create the class 
files for all the tables from a database (MySQL, Oracle, PostgreSQL, SQLite, MS 
SQL, etc), and it can be used to search using unions, sub-selects, can define 
views at ORM level, can accept to insert different types of objects like 
DateTime objects and can also return those type of objects, and many other 
things, and most of the things it can do can be done without using SQL code at 
all, but only standard Perl code and Perl data structures.

HTML::FormFu form processor is one of the most used form processors in Catalyst 
applications and it can generate and parse forms created directly in the code 
of the application, or as external configuration files defined using JSON, or 
YAML, or Apache configuration style, or Perl data structures, or XML...
The forms defined are very easy to create and the elements from those forms, 
for example the list of elements in a combo box can be taken directly from a 
database by specifying just a few configuration elements. The results of a form 
submit can be also inserted in a database using a connector with DBIx::Class 
without specifying any database table column name in the programming code, and 
for doing this are required just a few lines of code that checks if the 
$form->submitted_and_valid() and that does the redirection after the submit, 
the insertion in the database requiring just:

$form->model->create;
or
$form->model->update( $db_record );

...after that record was defined using just something like:

my $db_record = $c->model( 'DB::TableName' )->find( $record_id );

And HTML::FormFu can do filtering based on many conditions, impose the 
specified constraints, specify different inflators/deflators from the inserted 
strings to their corresponding object types, do a validation eventualy based on 
a database query that checks for duplicates or other things, transform the data 
automaticly after the form was processed, can use I18N for displaying the field 
labels or values translated in the active language, have its own rendering 
engine or can render custom form fields made using Template-Toolkit, etc.

Yes, for web apps I have seen more things which can be done much better in 
Perl, much easier and clear, with less code, and not because the 

Re: count strangeness

2011-05-22 Thread Roy Smith
In article ,
 James Stroud  wrote:

> tal 65% python2.7
> Python 2.7.1 (r271:86832, May 21 2011, 22:52:14)
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> py> class C(object):
> ...   def __init__(self):
> ... self.data = []
> ...   def doit(self, count=0):
> ... for c in self.data:
> ...   count += c.doit(count)
> ... count += 1
> ... print count
> ... return count
> ...
> py> c = C()
> py> c.data.extend([C() for i in xrange(10)])
> py> c.doit()

I have no idea what this is *supposed* to be doing, so let me toss out 
some general debugging ideas;

1) What do you expect [C() for i in xrange(10)] to return?  Does it?  
Run that part in isolation and see if it does.

2) What do you expect c.data.extend([...]) to return?  Does it?

3) What do you expect c.doit() to return for trivial inputs?  Does it?  
Try calling it with a count of 0, 1, and 2, and see if you get the 
result you expect.

In other words, break the problem down into smaller pieces and make sure 
each piece works in isolation.  When you find some little piece which 
isn't doing what you expect, it'll be much easier to debug than trying 
to debug the whole thing at once.
-- 
http://mail.python.org/mailman/listinfo/python-list


Hotshoting recursive function

2011-05-22 Thread Selvam
Hi,

I am using  hotshot module to profile my python function.

I used the details from (
http://code.activestate.com/recipes/576656-quick-python-profiling-with-hotshot/
).

The function I profile is a recursive one and I am getting the following
error,

"ProfilerError: profiler already active"

I guess this is due to the recursive call to the profiling function.

I would like to get some suggestions.

-- 
Regards,
S.Selvam
SG E-ndicus Infotech Pvt Ltd.
http://e-ndicus.com/

 " I am because we are "
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to get PID from subprocess library

2011-05-22 Thread TheSaint
Kushal Kumaran wrote:

> You could look for a way to make aria2c not become a daemon and use
> subprocess.Popen to start it.  That gives you the PID and ways to see
> if the process is still running

I see. It's a step that I've to get on my account. Unfortunately I'll have 
to study it some more.

BTW. I removed grep from the command. Python does it with the *in* statement 
:)


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


Re: TK program problem

2011-05-22 Thread rantingrick
On May 21, 7:03 pm, bvdp  wrote:
> IIRC, I used the class method since it nicely encapsulates a set of
> operations:
>
>    - create/raise a window
>    - list a set of configurable options
>    - have  and  buttons, both of which destroy the
> window.

Ok NOW we are getting somewhere! It is amazing how helpful people can
be when you explain your problem in "plain English". What you are
describing here is a dialog (be it modal or not). However your earlier
description of...

 """Yes, the class is instantiated when the button is clicked. Then,
the user stays in the class and uses its methods until he hits 
in the class. """

... was about as effective as the "orb of confusion" on Patrick...
*drool*

> Having a function as the callback certainly works as well. Not sure
> which is the best method in the long run ... I'm trying to use classes
> more in my programming since it's nice to wrap a bunch of functions up
> like this.

Yes you ABSOLUTELY SHOULD encapsulate the dialog code in a class! THEN
create an instance of the class inside a "easy to call" function.

class MyDialog(blah):
   blah,blah,blah

def show_dialog(*args):
d = MyDialog(*args)
return d.result

result = show_dialog()

...and they all lived happily ever after ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TK program problem

2011-05-22 Thread Chris Angelico
On Mon, May 23, 2011 at 12:03 AM, rantingrick  wrote:
> ... was about as effective as the "orb of confusion" on Patrick...
> *drool*
>

That sounds like a Dungeons and Dragons artifact item... invoking the
orb of confusion is a standard action that does not provoke an Attack
of Opportunity.

> class MyDialog(blah):
>   blah,blah,blah
>
> def show_dialog(*args):
>d = MyDialog(*args)
>return d.result
>
> result = show_dialog()

I don't really see why it shouldn't be valid to use the class itself
in this way. Once the constructor returns, the object IS the return
value.

But then, my opinion may not be valid. I've done weird things in C++
where, for instance, the invocation of a modeless dialog is:

new FoobarDialog(params);

And somewhere it has an event (eg when the window is destroyed) that executes:

delete this;

I'm a little mad and generally silly, so my opinion doesn't matter
(matter matter matter matter). But it did work, and the code was nice
and clean!

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


Re: List of WindowsError error codes and meanings

2011-05-22 Thread Andrew Berg
On 2011.05.21 06:46 AM, John J Lee wrote:
> Since Python 2.5, the errno attribute maps the Windows error to error
> codes that match the attributes of module errno.
I was able to whip up a nifty little function that takes the output of
sys.exc_info() after a WindowsError and return the error code. I was
mistaken in my earlier post about sys.exc_info()[1][0] - I hadn't
noticed the 'WindowsError' bit before the opening parenthesis and
mistook it for a tuple (it's a WindowsError object). Anyway:

> def find_win_error_no(error_msg):
> """
> error_msg is a string with the error message - typically
> sys.exc_info()[1] from a WindowsError exception
> Returns the number as a string, not an int
> """
> win_error_re = re.compile('\[Error \d{1,5}\]')
> win_error_num_re = re.compile('\d{1,5}')
> win_error = win_error_re.findall(error_msg)[0]
> return win_error_num_re.findall(win_error)[0]
I call it here:
> def make_prog_dir(dir):
> try:
> os.mkdir(dir)
> except WindowsError:
> error_info = str(sys.exc_info()[1])
> num = find_win_error_no(error_msg=error_info)
> if num == '183': # Error 183 = 'Cannot create a file when that
> file already exists'
> logger.debug(dir + ' exists.') # Ignore the error, but
> make a note
> elif num == '5': # Error 5 = 'Access is denied'
> logger.critical('Could not create', dir, '\(access denied\).')
> else:
> logger.critical('Could not create', dir, '-', error_info)
Errors 183 and 5 are going to be the most common, but I'll look at the
lists on MSDN to see if there's anything else worth adding (and
familiarize myself with any more common errors).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to get PID from subprocess library

2011-05-22 Thread GMail Felipe


On 22/05/2011, at 10:41, TheSaint  wrote:

> Kushal Kumaran wrote:
> 
>> You could look for a way to make aria2c not become a daemon and use
>> subprocess.Popen to start it.  That gives you the PID and ways to see
>> if the process is still running
> 
> I see. It's a step that I've to get on my account. Unfortunately I'll have 
> to study it some more.
> 
> BTW. I removed grep from the command. Python does it with the *in* statement 
> :)
> 
> 
> -- 
> goto /dev/null
> -- 
> http://mail.python.org/mailman/listinfo/python-list

Hi, 

For the "ps" command, have you seen the psuti module?

The link to it is: http://code.google.com/p/psutil/

Regards,
Felipe.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Abandoning Python

2011-05-22 Thread John J Lee
Daniel Kluev  writes:

> On Sun, May 22, 2011 at 2:49 AM, John J Lee  wrote:
>> Here's my wishlist (not really in any order):
>
> How come pony is not listed there? Language cannot be better than
> python without pony!

Pony, absolutely.  I took that as read.


>>  * An even larger user base, contributing more and better free and
>>   commercial software.
[...]
> As there is rather heavy inertia in software development community,
> expecting some language to acquire "even larger user base" is
> hopeless.

I did say I was prepared to compromise on that one.  After all, when I
started using Python it was a lot smaller that it is now.  If a language
is good enough to tempt me away from Python, probably the same is true
for other people too -- as it was with Python a decade or so ago.


> Also, most of these complaints could be solved by using correct python
> dialect for particular task - RPython, Cython and so on.

Different topic.


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


Re: Abandoning Python

2011-05-22 Thread John Lee
Bill Allen  gmail.com> writes:
 
> You have ideas, a text editor, and a computer - best get to coding.
> What's stopping you?  You largely want Python, with modifications.
> Join the development team and help implement those changes, or fork
> your own flavor and do what you wish.  Right?  You imagine it's an
> easy task, so get after it.
[...]

Is it possible that my calling it an easy task was a joke?

Honestly, I'd thought it safe with that one to leave out the smiley -- but then 
I've been away from newsgroups for quite a while!


John


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


Re: Abandoning Python

2011-05-22 Thread John Lee
Dan Stromberg  gmail.com> writes:

> On Sat, May 21, 2011 at 8:49 AM, John J Lee  pobox.com> wrote:
> 
> I still like Python after using it for over a decade, but there are
> things I don't like.
> What are your favourite up-and-coming languages of the moment?
> Here's my wishlist (not really in any order):
>  * A widely used standard for (optional) interface declaration -- or
>    something better.  I want it to be easier to know what interface an
>    object has when reading code, and which objects provide that
>    interface.
> 
> 
> I do miss this sometimes, but pylint takes things far enough for me. 

Pylint?  Does it provide some kind of guessed-at-type that has been integrated 
with IDEs?

[...]
> And here I thought Python had pretty good functional programming facilities.
> What do you miss?AFAIK, DBC in terms of "if condition: raise AssertionError"
> (or assert).What _is_ the "etc"?
[...more of the same...]

You tell me: I'm here to fish for interesting pointers rather than to 
evangelize.  I mention those specific things as examples because I know they 
have often been both the focus of research (well, perhaps not integration of 
queries), and pain points in software development.  It's not plausible to me 
that there is not room for major improvement, but in any case the only way to 
know is to try.


>  * Better refactoring tools, better code analysis tools (lint, search,
>    etc.).
> 
> I find pylint excellent.  My idea of a refactoring tool is vim's n.n.n.,  but 
have you looked at PyCharm? 

In this thread, I'm asking about the views of Python programmers on languages 
other than Python.  Thanks for the link, though (does PyCharm provide reliable 
refactoring tools that are useable from emacs?).


>  * An even larger user base, contributing more and better free and
>    commercial software.
> 
> Gee, you want a scripting language with a larger userbase? 

I don't want a scripting language, necessarily.


John


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


Re: List of WindowsError error codes and meanings

2011-05-22 Thread John Lee
Genstein  invalid.invalid> writes:

> 
> > Andrew Berg gmail.com>  writes:
> > Since Python 2.5, the errno attribute maps the Windows error to error
> > codes that match the attributes of module errno.
> 
> Good point, I completely misread that. At least the Windows error code 
> is still available as the winerror attribute.
> 
> As an aside - call me stupid, but I don't quite follow the purpose of 
> that errno mapping. Surely if the error number can be mapped 
> successfully then the error isn't Windows specific and an OSError should 
> logically be thrown instead? And if it can't be mapped successfully then 
> errno will never be valid so the mapping is pointless?

Since WindowsError is a subclass of OSError, .errno has to be there (and it 
must 
contain the UNIXy error code).  You could then ask why it's a subclass in the 
first place.  I think part of the answer is that the docs are wrong -- 
presumably actual usage is that WindowsError is raised when a Windows API call 
is made that *may* result in an exception that has no corresponding errno value 
("presumably" because I'm writing on Linux & sourceforge is too slow for me 
today to grab pywin32).  In other words, code that raises WindowsError doesn't 
try to test the error code so that it can raise OSError instead some of the 
time.  I don't think there would be any benefit in doing that, and it would 
have 
the disadvantage that with those calls, you'd have to deal with a mixture of 
Windows and UNIXy error codes.

The presence of .errno, aside from being required (to satisfy LSP), does mean 
you don't have to deal with the Windows codes if you're only interested in 
cases 
covered by module errno.


John


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


Re: Abandoning Python

2011-05-22 Thread Stefan Behnel

John J Lee, 22.05.2011 17:58:

Daniel Kluev writes:

Also, most of these complaints could be solved by using correct python
dialect for particular task - RPython, Cython and so on.


Different topic.


Why?

Stefan

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


Re: Abandoning Python

2011-05-22 Thread John Lee
Stefan Behnel  behnel.de> writes:

> 
> John J Lee, 22.05.2011 17:58:
> > Daniel Kluev writes:
> >> Also, most of these complaints could be solved by using correct python
> >> dialect for particular task - RPython, Cython and so on.
> >
> > Different topic.
> 
> Why?

The intended focus was "things other than Python".  RPython and Cython are 
languages other than Python, but I regard them as part of the Python, er, 
ecosystem.  They have advantages and drawbacks that a lot of us are already 
familiar with (even though in your position I imagine you notice the 
misconceptions more than the correct ones).  The thought behind my question was 
to get Pythonista's opinions about things outside of that.


John


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


Dealing with name clashes in pypi

2011-05-22 Thread Patrick Sabin
I wanted to register my project (epdb) in pypi. Unfortunately there 
already exists a project with the same name. It is not possible for me 
to change the name of the project, because I used it in multiple 
writings. Any ideas how I can deal with the situation? Is it possible to 
register a project under a different name in pypi than the actual 
project name?


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


and becomes or and or becomes and

2011-05-22 Thread Stef Mientki
hello,

must of us will not use single bits these days,
but at first sight, this looks funny :

>>> a=2
>>> b=6
>>> a and b
6
>>> a & b
2
>>> a or b
2
>>> a | b
6

cheers,
Stef
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Abandoning Python

2011-05-22 Thread Ed Keith
Have you looked at Falcon (http://www.falconpl.org/)? It seems to have a lot of 
what you are looking for. I do not have much experience with it but I like what 
I've seen so far, except that there are not any third party tools or libraries 
libraries. Which is where Python shines.

   -EdK

Ed Keith
[email protected]

Blog: edkeith.blogspot.com

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


Tkinter FileDialog

2011-05-22 Thread Alex van der Spek
Trying to bring up a simple File or Directory chooser using Tkinter. Right 
now I use pywin32  as Mark Hammond's extensions are somewhat more familiar 
to an (ex)VB programmer who started way back with Fortran.


On Windows Vista with Python 2.7. The examples from Mark Lutz' book 
"Programming Python" do not immediately apply. The book describes Python 3.x 
only.


This is what I do (in IDLE):

import tkFileDialog as tk
file2open=tk.Open().show()

This works. But it also brings up a persistent Tk window. Killing this 
window forces a restart in IDLE, which is not desirable. There does not 
appear to be a way to multiselect files?


I am probably missing a whole lot. Please point me to a simple example of 
GUI file manipulations. I can save myself with os.path.walk and os.listdir 
but the users I try to serve cannot.


Regards,
Alex van der Spek 


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


Re: English Idiom in Unix: Directory Recursively

2011-05-22 Thread Xah Lee
Xah wrote:
«In the emacs case: “Recursive delete of xx? (y or n) ”, what could it
possibly mean by the word “recursive” there? Like, it might delete the
directory but not delete all files in it?
»

Jonathan de Boyne Pollard wrote:
> It might *try* to delete the directory but not any of its contents,
> yes.

you mean theoretically you see a possibility if the dir is implement
as stilted as unix, but never in your life you find yourself might
want to do it?

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


Re: Abandoning Python

2011-05-22 Thread Dan Stromberg
On Sun, May 22, 2011 at 10:33 AM, John Lee  wrote:

> Dan Stromberg  gmail.com> writes:
>
> > On Sat, May 21, 2011 at 8:49 AM, John J Lee  pobox.com> wrote:
> > 
> > I still like Python after using it for over a decade, but there are
> > things I don't like.
> > What are your favourite up-and-coming languages of the moment?
> > Here's my wishlist (not really in any order):
> >  * A widely used standard for (optional) interface declaration -- or
> >something better.  I want it to be easier to know what interface an
> >object has when reading code, and which objects provide that
> >interface.
> >
> >
> > I do miss this sometimes, but pylint takes things far enough for me.
>
> Pylint?  Does it provide some kind of guessed-at-type that has been
> integrated
> with IDEs?
>

Pylint does type inferencing - I find it very valuable on large projects,
and even some not-so-large projects.

I doubt Pylint's been integrated into any IDE's, but ISTR that there's an
IDE out there that has pyflakes in it.  I suspect PyCharm does its own type
stuff.  I've heard (but not tried) that vim can have pyflakes integrated
into it.

For emacs, I really don't know.  I'm more of a vim perrson, but I've
considered switching to PyCharm by JetBrains - people in the Java world
really seem to like what JetBrains did for Java, and PyCharm purportedly has
vi keybindings, so I shouldn't end up typing way too many keystrokes for the
same tasks.

>
> >  * Better refactoring tools, better code analysis tools (lint, search,
> >etc.).
> >
> > I find pylint excellent.  My idea of a refactoring tool is vim's n.n.n.,
> but
> have you looked at PyCharm?
>
>
> In this thread, I'm asking about the views of Python programmers on
> languages
> other than Python.  Thanks for the link, though (does PyCharm provide
> reliable
> refactoring tools that are useable from emacs?).
>
> I'm inclined to doubt that emacs can swallow PyCharm (or PyCharm be
swallowed by emacs).  But PyCharm probably has refactoring.  For a bolt-on
to vim or emacs, you might look at "Rope".
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: checking if a list is empty

2011-05-22 Thread Thomas Rachel

Am 11.05.2011 23:02 schrieb Ian:


On 11/05/2011 20:13, Hans Georg Schaathun wrote:

 Lists do not have truth values in the
application domain, and therefore truth values in the
implementation domain is complicated.


Exactly. Its just a convention. If it exists, its true, if if doesn't
its false.


Right. And not only that: Python objects resp. classes not claiming to 
have a truth value (__nonzero__), but a length (__len__) are judged by 
that concerning their truth value: iff the length is 0, their truth 
value is False.



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


Re: Abandoning Python

2011-05-22 Thread John Lee
Dan Stromberg  gmail.com> writes:
[...]
> Pylint does type inferencing - I find it very valuable on large projects, and
> even some not-so-large projects.I doubt Pylint's been integrated into any
> IDE's, 
[...]

That's interesting, thanks.  I see this is a different pylint than the old 
logilab pylint.  Unfortunate choice of name, since it makes it hard to find IDE 
integration work that's already done.


> But PyCharm probably has refactoring.  For a bolt-on to vim or
> emacs, you might look at "Rope".

TBH, I'm not interested in Python refactoring tools until everybody starts 
shouting that they're reliable and useful (because it seems like a hard problem 
to solve, so I guess most implementations will be more trouble than they're 
worth).


John


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


Re: Multiprocessing: don't push the pedal to the metal?

2011-05-22 Thread John Ladasky
Following up to my own post...

Flickr informs me that quite a few of you have been looking at my
graphs of performance vs. the number of sub-processes employed in a
parallelizable task:

On May 21, 8:58 pm, John Ladasky  wrote:
> http://www.flickr.com/photos/15579975@N00/5744093219
[...]
> I'll quickly ask my question first, to avoid a TL;DR problem: when you
> have a multi-core CPU with N cores, is it common to see the
> performance peak at N-1, or even N-2 processes?  And so, should you
> avoid using quite as many processes as there are cores?  I was
> expecting diminishing returns for each additional core -- but not
> outright declines.

But no one has offered any insight yet?  Well, I slept on it, and I
had a thought.  Please feel free to shoot it down.

If I spawn N worker sub-processes, my application in fact has N+1
processes in all, because there's also the master process itself.  If
the master process has anything significant to do (and mine does, and
I would surmise that many multi-core applications would be that way),
then the master process may sometimes find itself competing for time
on a CPU core with a worker sub-process.  This could impact
performance even when the demands from the operating system and/or
other applications are modest.

I'd still appreciate hearing from anyone else who has more experience
with multiprocessing.  If there are general rules about how to do this
best, I haven't seen them posted anywhere.  This may not be a Python-
specific issue, of course.

Tag, you're it!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Abandoning Python

2011-05-22 Thread John Lee
Ed Keith  yahoo.com> writes:

> 
> Have you looked at Falcon (http://www.falconpl.org/)? It seems to have a lot
> of what you are looking for.

I'm more interested in other people's opinions than my own "looking for"s.

What *should* I be looking for (other than Python itself)?  What's interesting, 
widely applicable, and new(ish)?

Falcon fails my personal book-by-its-cover test.  There are too many languages
to do without that test, unfortunately.


John


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


Re: TK program problem

2011-05-22 Thread Terry Reedy

On 5/21/2011 10:20 PM, bvdp wrote:



One of the purposes and advantages of Python 3 is having only one class
system. Best to always use new-style classes in Python 2.2+ unless you
understand and need old-style classes (and need should be never for most
people).



Thanks for this. I'll keep it in mind!

One thing I really don't understand ... is there a difference between
the old/new forms:

class foo:
class foo():

In cases where I've played with them, they _appear_ to work the same?


I believe they are. Same is true in 3.x except that the result in a 
new-style class.



Also, where does one find the magic that says that for a tkinter class
you should use:

class foo(object):


Perhaps nowhere. It may have been an unintended side-effect of the 
change in callable check, or intentional but not documented.



Not really sure where "object" comes from.


It is the base class of all (new-style) classes.
>>> object()


--
Terry Jan Reedy

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


Re: Abandoning Python

2011-05-22 Thread John Lee
John Lee  pobox.com> writes:
[...]
> That's interesting, thanks.  I see this is a different pylint than the old 
> logilab pylint.  Unfortunate choice of name, since it makes it hard to find
> IDE integration work that's already done.

Hmm, I see the last release was in 2003 :-(


John


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


Re: Dealing with name clashes in pypi

2011-05-22 Thread Terry Reedy

On 5/22/2011 2:34 PM, Patrick Sabin wrote:

I wanted to register my project (epdb) in pypi. Unfortunately there
already exists a project with the same name. It is not possible for me
to change the name of the project, because I used it in multiple
writings. Any ideas how I can deal with the situation? Is it possible to
register a project under a different name in pypi than the actual
project name?


I presume so. How would pypi know the 'actual' name?
However, there is a catalog sig list (mirrored as 
gmane.comp.python.catalog) where you might get specific suggestions on 
how to handle this.


--
Terry Jan Reedy

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


Re: and becomes or and or becomes and

2011-05-22 Thread Thomas 'PointedEars' Lahn
Stef Mientki wrote:

> must of us will not use single bits these days,
> but at first sight, this looks funny :
> 
 a=2
 b=6
 a and b
> 6
 a & b
> 2
 a or b
> 2
 a | b
> 6

Change the order of the operands and see what happens.

-- 
PointedEars

Bitte keine Kopien per E-Mail. / Please do not Cc: me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did Quora choose Python for its development?

2011-05-22 Thread Terry Reedy

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


I've noticed that on many Perl mailing lists the list members talk
very rarely about Python,


Interesting. I learned about Python on comp.lang.perl, but that was over 
a decade ago.



but only on this Python mailing list I read
many discussions about Perl, in which most of the participants use to
agree that yes, Python is better, as it shouldn't be obvious that
most of the list members prefer Python.


This list really has very little other-language bashing.


A few months ago I have asked how can I create a dictionary from a
list, and there were so many techniques that I think that it is just
a buzzword that in Perl there are many ways to do it, while in Python
there is a single way. In Python I found from the messages I received
on this mailing list that there are a lot of ways, without even
beeing a "recommended" way, while in Perl there is a single way, of
course much shorter and clearer.


I forget the exact question you asked, but this list is not the doc. The 
doc section on dicts gives dict(list_of_key_value_pairs) as the one true 
way, given such an input. The Perl way cannot be clearer and can only be 
shorted if it uses something shorter that dict().


If the list is a flat list of alternating keys and values, then yes, 
they must be paired, and there are several ways to do that, partly 
depending on the exact specifications, including allowed input and how 
an odd key left over should be treated. In any case, unpaired keys and 
values strikes me as an unusual input format for a dict. They typically 
would have been paired as some point and in Python, should not need to 
be unpaired.


--
Terry Jan Reedy

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


Re: and becomes or and or becomes and

2011-05-22 Thread Terry Reedy

On 5/22/2011 5:57 PM, Thomas 'PointedEars' Lahn wrote:

Stef Mientki wrote:


must of us will not use single bits these days,
but at first sight, this looks funny :


a=2
b=6
a and b

6

a&  b

2

a or b

2

a | b

6


Change the order of the operands and see what happens.


or change a,b to 1,2


--
Terry Jan Reedy

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


Re: and becomes or and or becomes and

2011-05-22 Thread Tim Roberts
Stef Mientki  wrote:
>
>must of us will not use single bits these days,
>but at first sight, this looks funny :
>
 a=2
 b=6
 a and b
>6
 a & b
>2
 a or b
>2
 a | b
>6

That IS funny.  Interesting how a careful choice of arugments will fool us.
One of my favorite math jokes is like that.  A teacher asked a student to
reduce the following fraction: 
  16
 
  64

He says "all I have to do is cancel out the sixes, so the answer is 1/4".
-- 
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Strange behaviour of input() function (Python 3.2)

2011-05-22 Thread sunrrrise
Hello,
this is my first post. I'm trying to learn Python language which I find great, 
but I have a big problem with its editors/IDEs.

I have tested IDLE (which installed with Python3 from ActiveState), Notepad++ 
and finally Komodo EDIT. I don't like IDLE GUI, but Notepad++ and Komodo EDIT 
looks nice for me.

Unfortunatelly there is something wrong with input() command when I'm using 
Komodo or Notepad. For example this code:

a = input("Wprowadz zmienna a: ")
b = input("Wprowadz zmienna b: ")
print("a to: ", a)
print("b to: ", b)
print(int(a) + int(b))

works well in IDLE, but when I'm switching to Notepad/Komodo I'm getting 
something like this:

Wprowadz zmienna a: 3
Wprowadz zmienna b: 2
a to:  3
b to:  Wprowadz zmienna b: 2
Traceback (most recent call last):
  File "c:\users\sunrrrise\Desktop\test.py", line 9, in 
print(int(a) + int(b))
ValueError: invalid literal for int() with base 10: 'Wprowadz zmienna b: 2'

I don't know what is going on. Any ideas or, better, solutions?

My OS: Windows 7 64bit, ActiveState Python 3.2, Notepad++ 5.9, Komodo Edit 6.1, 
coding: UTF-8

Regards,
sunrrrise
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: English Idiom in Unix: Directory Recursively

2011-05-22 Thread Chris Angelico
On Mon, May 23, 2011 at 6:22 AM, Xah Lee  wrote:
> Xah wrote:
> «In the emacs case: “Recursive delete of xx? (y or n) ”, what could it
> possibly mean by the word “recursive” there? Like, it might delete the
> directory but not delete all files in it?
> »
>
> Jonathan de Boyne Pollard wrote:
>> It might *try* to delete the directory but not any of its contents,
>> yes.
>
> you mean theoretically you see a possibility if the dir is implement
> as stilted as unix, but never in your life you find yourself might
> want to do it?

There's a difference between working with a directory itself and
working with files inside it. Generally, if you copy or delete a
directory, you will want to recurse. But if you want to, for instance,
wipe out all files whose names end with a tilde, then you might want
to recurse and you might not. So it makes sense to offer the user a
choice, and if recursive action is the only one that makes sense, at
least acknowledge that the operation might take an arbitrarily long
time. (Ever done a recursive operation on / on a large file system?
Takes just a little bit longer than a non-recursive one under the same
circumstances...)

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


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

2011-05-22 Thread Chris Angelico
On Mon, May 23, 2011 at 8:43 AM, sunrrrise  wrote:
> Hello,
> this is my first post. I'm trying to learn Python language which I find 
> great, but I have a big problem with its editors/IDEs.

Welcome!

> b to:  Wprowadz zmienna b: 2

This looks wrong. Are you copying and pasting several lines, or simply
pressing the 2 key followed by Enter?

It's showing a lengthy string in the variable 'b', which - quite
correctly - cannot be cast to int.

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


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

2011-05-22 Thread Xah Lee

this is important but i think most lispers and functional programers
still don't know it.

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

〈Guy Steele on Parallel Programing〉
http://xahlee.org/comp/Guy_Steele_parallel_computing.html

btw, lists (as cons, car, cdr) in the lisp world has always been some
kinda cult. Like, if you are showing some code example and you
happened to use lisp vector datatype and not cons (lists) and it
doesn't really matter in your case, but some lisper will always rise
up to bug you, either as innocent curious question or attacking you
for not “understanding” lisp. (just as other idiocies happen in other
lang that lispers see but other langs don't see)

it's interesting to me that all other high level langs: Mathematica,
perl, python, php, javascript, all don't have linked list as lisp's
list. It's also curious that somehow lispers never realises this. I've
been having problems with lisp's cons ever since i'm learning Scheme
Lisp in 1998 (but mostly the reason is language design at syntax and
lack of abstraction level in calling “cons, car, cdr” stuff, without
indexing mechanism). Realizing the algorithmic property and parallel-
execution issues of linked list is only recent years.

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


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

2011-05-22 Thread sunrrrise
Thank you for quick response!

English is not my native language so I'm going to keep my explanations simple. 

This really simple script asks me for two variables called "a" and "b". For 
example, I type "4" for "a" and "3" for "b" and IDLE gives me that:

Wprowadz zmienna a: 4
Wprowadz zmienna b: 3
a to:  4
b to:  3
7

Works fine!

But when I'm using Notepad (or Komodo) I get this:

Wprowadz zmienna a: 4
Wprowadz zmienna b: 3
Traceback (most recent call last):
  File "c:\users\sunrrrise\Desktop\test.py", line 7, in 
print(int(a) + int(b))
ValueError: invalid literal for int() with base 10: 'Wprowadz zmienna b: 3'
a to:  4
b to:  Wprowadz zmienna b: 3

This is exactly the same script from the same file. I really don't get it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Abandoning Python

2011-05-22 Thread Brendan Simon (eTRIX)


On 23/05/11 7:17 AM, [email protected] wrote:
> Subject:
> Re: Abandoning Python
> From:
> John Lee 
> Date:
> Sun, 22 May 2011 21:13:44 + (UTC)
>
>
>> > 
>> > Have you looked at Falcon (http://www.falconpl.org/)? It seems to have a 
>> > lot
>> > of what you are looking for.
> I'm more interested in other people's opinions than my own "looking for"s.
>
> What *should* I be looking for (other than Python itself)?  What's 
> interesting, 
> widely applicable, and new(ish)?
>
> Falcon fails my personal book-by-its-cover test.  There are too many languages
> to do without that test, unfortunately.

Take a look at Cobra.

http://cobra-language.com/docs/python/

http://cobra-language.com/

It is similar to Python, but with a quite a few nice extras and few improved 
things (eg. no "self", no ":", ...)

Possible negatives are:
* Requires either .NET or Mono frameworks.
* lack of 3rd party libraries ??


Cheers, Brendan.

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


Re: Abandoning Python

2011-05-22 Thread Daniel Kluev
On Mon, May 23, 2011 at 4:33 AM, John Lee  wrote:
> Pylint?  Does it provide some kind of guessed-at-type that has been integrated
> with IDEs?

WingIDE Pro has both Pylint integration and advanced type-guessing.

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


Re: English Idiom in Unix: Directory Recursively

2011-05-22 Thread Xah Lee
On May 22, 3:46 pm, Chris Angelico  wrote:
> On Mon, May 23, 2011 at 6:22 AM, Xah Lee  wrote:
> > Xah wrote:
> > «In the emacs case: “Recursive delete of xx? (y or n) ”, what could it
> > possibly mean by the word “recursive” there? Like, it might delete the
> > directory but not delete all files in it?
> > »
>
> > Jonathan de Boyne Pollard wrote:
> >> It might *try* to delete the directory but not any of its contents,
> >> yes.
>
> > you mean theoretically you see a possibility if the dir is implement
> > as stilted as unix, but never in your life you find yourself might
> > want to do it?
>
> There's a difference between working with a directory itself and
> working with files inside it. Generally, if you copy or delete a
> directory, you will want to recurse. But if you want to, for instance,
> wipe out all files whose names end with a tilde, then you might want
> to recurse and you might not. So it makes sense to offer the user a
> choice, and if recursive action is the only one that makes sense, at
> least acknowledge that the operation might take an arbitrarily long
> time. (Ever done a recursive operation on / on a large file system?
> Takes just a little bit longer than a non-recursive one under the same
> circumstances...)

the context is this: In emacs directory manager (aka dired), when you
call dired-do-delete on a directory, emacs prompts, this way:
“Recursive delete of xx? (y or n)”

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


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

2011-05-22 Thread Chris Angelico
On Mon, May 23, 2011 at 8:59 AM, sunrrrise  wrote:
> Thank you for quick response!
>
> English is not my native language so I'm going to keep my explanations simple.

No problem, your English is far better than my Polish. (I used Google
Translate to figure out what "Wprowadz zmienna" means.)

I tried copying and pasting your exact code, even down to using
Notepad, but it worked fine. The interpreter I used was a
freshly-downloaded Python 3.2, listing itself as r32:88445 dated Feb
20 2011, 21:29:03.

This may be a really specific bug. Can you email me the actual Python
file you're having problems with, please? Off-list, as this list
doesn't like attachments. I'll try running it on my system and see if
it's any different.

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


Re: and becomes or and or becomes and

2011-05-22 Thread Chris Angelico
On Mon, May 23, 2011 at 8:39 AM, Tim Roberts  wrote:
> That IS funny.  Interesting how a careful choice of arugments will fool us.
> One of my favorite math jokes is like that.  A teacher asked a student to
> reduce the following fraction:
>  16
>  
>  64
>
> He says "all I have to do is cancel out the sixes, so the answer is 1/4".

I like. :)

But in the OP, the difference between "and" and "&", or "or" and "|",
is subtle yet absolute. They are completely different operators. The
bitwise operators function like the arithmetic operators - evaluate
both operands, then do something that combines them into one value.
The logical operators, though, are more like the if statement:

q = a and b

is similar to:

if a:
  q = a
else:
  q = b

(Pedants, please note that I said "similar" not "equivalent".) They
happen to do similar things, but they're completely different in
operation. I do like the humour value from the careful selection of
operands though!

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


Re: English Idiom in Unix: Directory Recursively

2011-05-22 Thread Chris Angelico
On Mon, May 23, 2011 at 9:17 AM, Xah Lee  wrote:
> the context is this: In emacs directory manager (aka dired), when you
> call dired-do-delete on a directory, emacs prompts, this way:
> “Recursive delete of xx? (y or n)”

But in order to make your point (such as it is), you are ignoring the
fact that there are other uses of the term 'recurse' or 'recursive',
and consistency and clarity are important. I don't see emacs offering
me a chance to do a non-recursive delete; the only issue here seems to
be that it's explicit that it is going to destroy an entire branch of
the directory tree. If this is such a problem, grab the emacs sources
and change that string - it probably occurs in exactly one place in
the code. Voila! You now have The One True Perfect Emacs, the ultimate
text editor, because it no longer tells you that it's working
recursively.

*removes tongue from cheek after saying that last sentence*

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


Re: Why did Quora choose Python for its development?

2011-05-22 Thread Daniel Kluev
On Sun, May 22, 2011 at 11:47 PM, Octavian Rasnita  wrote:
> From: "Daniel Kluev" 
> I am talking about that flexibility which was criticized in the previous 
> messages telling that this flexibility allows any programmer to use his own 
> way.
> Perl doesn't force anyone to indent the code, don't force the programmer to 
> define a hash element before using it, allow the programmer to interpret the 
> variables in strings directly. These things should be not used always, but if 
> in some cases if the programmer wants to use them, he can use them with no 
> problems. And this means flexibility.

This is syntax-level flexibility, which, IMHO, does not affect
'advanceness' of modules at all. At language level, python is far more
flexible than perl with its magic methods and hooks, allowing to
overload any underlying language principles and protocols.

> First, this is a bad style of mapping urls, because this list must be 
> maintained every time the programmer changes something in a controller that 
> makes the app need to use other urls.

Explicit is better than implicit. One of reasons why I chose
Pylons/Pyramid as my standard toolkit is that it allowed me to define
mappers in any way I needed them to.
If you want automatically defined mappers, there are lots of other
python frameworks and modules which do exactly that. Moreover, even
Routes itself (module, which does url mapping in Pylons) allows you to
use automated mappers, via :controller/:action tokens. It allows
pretty much everything you listed as 'features' of catalyst mappings.
If you prefer to stuff routing logic into controllers and have default
routing based on controllers and method names, you can use TurboGears
framework, which has exactly that mindset, or you can use its mapping
modules in Pyramid application.

> The module DBIx::Class which is used usually as an ORM can create the class 
> files for all the tables from a database (MySQL, Oracle, PostgreSQL, SQLite, 
> MS SQL, etc), and it can be used to search using unions, sub-selects, can 
> define views at ORM level, can accept to insert different types of objects 
> like DateTime objects and can also return those type of objects, and many 
> other things, and most of the things it can do can be done without using SQL 
> code at all, but only standard Perl code and Perl data structures.

There are lots of Python modules which do exactly this and much more.
SQLAlchemy, SQLObject, Web2Py's DAL, and so on. They are integrated
into frameworks by default.

> HTML::FormFu form processor is one of the most used form processors in 
> Catalyst applications and it can generate and parse forms created directly in 
> the code of the application, or as external configuration files defined using 
> JSON, or YAML, or Apache configuration style, or Perl data structures, or 
> XML...
> The forms defined are very easy to create and the elements from those forms, 
> for example the list of elements in a combo box can be taken directly from a 
> database by specifying just a few configuration elements. The results of a 
> form submit can be also inserted in a database using a connector with 
> DBIx::Class without specifying any database table column name in the 
> programming code, and for doing this are required just a few lines of code 
> that checks if the $form->submitted_and_valid() and that does the redirection 
> after the submit, the insertion in the database requiring just:

Once again, there are dozens of such modules in python. FormAlchemy
integrates directly with SQLAlchemy, for example, and does all form
generation, parsing, validation, and instance updating/inserting for
you.

> Yes, for web apps I have seen more things which can be done much better in 
> Perl, much easier and clear, with less code, and not because the programmer 
> needs to do not-recommended tricks for shortening the code, but because there 
> are very many modules on CPAN that do the hard work.

I doubt you had enough experience with python frameworks like
Pyramid/Pylons or Web2Py. They have all features you listed, and code
is as trivial and clean, as it could ever be. Its surprising that you
present trivial ORM as 'advanced modules and libraries which are not
available for Python', while in fact it have been done long time ago
and in several flavors.

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


Re: Why did Quora choose Python for its development?

2011-05-22 Thread John Bokma
Terry Reedy  writes:

> I forget the exact question you asked, but this list is not the
> doc. The doc section on dicts gives dict(list_of_key_value_pairs) as
> the one true way, given such an input. The Perl way cannot be clearer
> and can only be shorted if it uses something shorter that dict().

my %hash = @list_of_key_value_pairs;

-- 
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: Multiprocessing: don't push the pedal to the metal?

2011-05-22 Thread Chris Angelico
On Mon, May 23, 2011 at 7:06 AM, John Ladasky  wrote:
> If I spawn N worker sub-processes, my application in fact has N+1
> processes in all, because there's also the master process itself.

This would definitely be correct. How much impact the master process
has depends on how much it's doing.

> I'd still appreciate hearing from anyone else who has more experience
> with multiprocessing.  If there are general rules about how to do this
> best, I haven't seen them posted anywhere.  This may not be a Python-
> specific issue, of course.

I don't have much experience with Python's multiprocessing model, but
I've done concurrent programming on a variety of platforms, and there
are some common issues.

Each CPU (or core) has its own execution cache. If you can keep one
thread running on the same core all the time, it will benefit more
from that cache than if it has to keep flitting from one to another.

You undoubtedly will have other processes in the system, too. As well
as your master, there'll be processes over which you have no control
(unless you're on a bare-bones system). Some of them may preempt your
processes.

Leaving one CPU/core available for "everything else" may allow the OS
to keep each thread on its own core. Having as many workers as cores
means that every time there's something else to do, one of your
workers has to be kicked off its nice warm CPU and sent out into the
cold for a while. If all your workers are at the same priority, it
will then grab a timeslice off one of the other cores, kicking its
incumbent off... rinse and repeat.

This is a tradeoff, though. If the rest of your system is going to use
0.01 of a core, then 1% thrashing is worth having one more core
available 99% of the time. If the numbers are reversed, it's equally
obvious that you should leave one core available. In your case, it's
probably turning out that the contention causes more overhead than the
extra worker is worth.

That's just some general concepts, without an in-depth analysis of
your code and your entire system. It's probably easier to analyse by
results rather than inspection.

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


Re: and becomes or and or becomes and

2011-05-22 Thread Steven D'Aprano
On Sun, 22 May 2011 15:39:33 -0700, Tim Roberts wrote:

> Stef Mientki  wrote:
>>
>>must of us will not use single bits these days, but at first sight, this
>>looks funny :
>>
> a=2
> b=6
> a and b
>>6
> a & b
>>2
> a or b
>>2
> a | b
>>6
> 
> That IS funny.  Interesting how a careful choice of arugments will fool
> us. One of my favorite math jokes is like that.  A teacher asked a
> student to reduce the following fraction:
>   16
>  
>   64
> 
> He says "all I have to do is cancel out the sixes, so the answer is
> 1/4".

One of my favourite variations on this is by Abbott and Costello, where 
Costello proves that 13*7 = 28 in three different ways.

http://www.youtube.com/watch?v=rLprXHbn19I



-- 
Steven

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


Re: Abandoning Python

2011-05-22 Thread Gregory Ewing

Ed Keith wrote:

Have you looked at Falcon (http://www.falconpl.org/)?


This paragraph on the first page doesn't exactly fire
me with enthuiasm:


Falcon provides six integrated programming paradigms: procedural, object
oriented, prototype oriented, functional, tabular and message oriented. And you
don't have to master all of them;


...until you want to read someone *else's* code, that is.

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


[no subject]

2011-05-22 Thread Chris Jones

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


[no subject]

2011-05-22 Thread Chris Jones

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


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

2011-05-22 Thread Deeyana
On Sun, 22 May 2011 15:47:53 -0700, Xah Lee wrote:

> this is important but i think most lispers and functional programers
> still don't know it.
> 
> Functional Programing: stop using recursion, cons. Use map & vectors.
> 
> 〈Guy Steele on Parallel Programing〉
> http://xahlee.org/comp/Guy_Steele_parallel_computing.html
> 
> btw, lists (as cons, car, cdr) in the lisp world has always been some
> kinda cult. Like, if you are showing some code example and you happened
> to use lisp vector datatype and not cons (lists) and it doesn't really
> matter in your case, but some lisper will always rise up to bug you,
> either as innocent curious question or attacking you for not
> “understanding” lisp. (just as other idiocies happen in other lang that
> lispers see but other langs don't see)
> 
> it's interesting to me that all other high level langs: Mathematica,
> perl, python, php, javascript, all don't have linked list as lisp's
> list. It's also curious that somehow lispers never realises this. I've
> been having problems with lisp's cons ever since i'm learning Scheme
> Lisp in 1998 (but mostly the reason is language design at syntax and
> lack of abstraction level in calling “cons, car, cdr” stuff, without
> indexing mechanism). Realizing the algorithmic property and parallel-
> execution issues of linked list is only recent years.

You might be interested in Clojure, then. Lists are more abstracted, like 
in Scheme, and vectors and also dictionaries/maps and sets are first 
class citizens along side lists. And unlike Scheme, Clojure has good 
library/host interop support. You can write real-world applications in it 
without spontaneously combusting.
-- 
http://mail.python.org/mailman/listinfo/python-list


Writing multiple files with with-context

2011-05-22 Thread Shunichi Wakabayashi
To write onto multiple files on the same time (a number of files are variable),
I'd like to code as follows, for example, IF I can do,

LIST_LEN = 4
with [ open('list_%d.txt' % i, 'w') for i in range(LIST_LEN) ] as fobjlist:
  for i in range(1000):
fobjlist[random.randrange(LIST_LEN)].write(str(i)+"\n")

or using a dict object,

DICT_KEYS = ('foo', 'bar', 'baz')
with { k: open('dict_%s.txt' % k, 'w') for k in DICT_KEYS } as fobjdict:
  for i in range(1000):
fobjdict[random.choice(DICT_KEYS)].write(str(i)+"\n")

However, list and dict don't has __exit__ method and so they cannot run.
One idea is using contextlib.nested(),

from contextlib import nested

with nested(*[open('list_%d.txt' % i, 'w') for i in range(LIST_LEN)]) as 
fobjlist:
  for i in range(1000):
fobjlist[random.randrange(LIST_LEN)].write(str(i)+"\n")

with nested(*[open('dict_%s.txt' % k, 'w') for k in DICT_KEYS]) as fobjlist:
  fobjdict = dict(zip(DICT_KEYS, fobjlist)) #convert list to dict
  for i in range(1000):
fobjdict[random.choice(DICT_KEYS)].write(str(i)+"\n")

On Python2.x, this is OK. but 3.x warns that nested() is deprecated.
Moreover, on using dict, it is required to convert list to dict.

Another idea is to make container classes having __exit__() myself.

class MyList(list):
  def __enter__(self):
return [ v.__enter__() for v in self ]
  def __exit__(self, exc_type, exc_value, traceback):
ret = False
for v in self:
  if v.__exit__(exc_type, exc_value, traceback):
ret = True
exc_type = exc_value = traceback = None
return ret

class MyDict(dict):
  def __enter__(self):
return { k: v.__enter__() for k, v in self.items() }
  def __exit__(self, exc_type, exc_value, traceback):
ret = False
for v in self.values():
  if v.__exit__(exc_type, exc_value, traceback):
ret = True
exc_type = exc_value = traceback = None
return ret

with MyList( open('list_%d.txt' % i, 'w') for i in range(LIST_LEN) ) as 
fobjlist:
  for i in range(1000):
fobjlist[random.randrange(LIST_LEN)].write(str(i)+"\n")

with MyDict( (k, open('dict_%s.txt' % k, 'w')) for k in DICT_KEYS ) as fobjdict:
  for i in range(1000):
fobjdict[random.choice(DICT_KEYS)].write(str(i)+"\n")

I think this is smarter a little than others,
but it cannot guaranteed to call __exit__() of members in containers
if members are changed during with-context.

So, do you have another, more smart and pythonic way?

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


Building Python: static library "3.2m"

2011-05-22 Thread Chris Angelico
Hi! Just a quickie, I hope, where someone will probably be able to
answer off the top of his head.

I downloaded the 3.2 sources with the intention of building that
instead of using Ubuntu's default Python 2.6.6. Ran ./configure, make,
sudo make install, and then fiddled with a few things like make all,
make libinstall, make libainstall. Eventually got a libpython3.2m.a in
/usr/local/lib.

Question: Why "3.2m"? What does that m mean? It seems to have come up
a couple of times in the build process.

Thanks in advance!

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


Re: Building Python: static library "3.2m"

2011-05-22 Thread Ned Deily
In article ,
 Chris Angelico  wrote:
> Question: Why "3.2m"? What does that m mean? It seems to have come up
> a couple of times in the build process.

It's a new feature in Python 3.2 to allow multiple versions of shared C 
object files that differ in configure options (i.e. ones that affect the 
Python C ABI) to co-exist in one Python installation.  "m" means that 
they were built with pymalloc.  Other flags are "d" for debug, and "u" 
for wide-unicode.

http://docs.python.org/py3k/whatsnew/3.2.html#pep-3149-abi-version-tagged
-so-files

-- 
 Ned Deily,
 [email protected]

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


Re: Building Python: static library "3.2m"

2011-05-22 Thread Chris Angelico
On Mon, May 23, 2011 at 2:01 PM, Ned Deily  wrote:
> It's a new feature in Python 3.2 to allow multiple versions of shared C
> object files that differ in configure options (i.e. ones that affect the
> Python C ABI) to co-exist in one Python installation.  "m" means that
> they were built with pymalloc.  Other flags are "d" for debug, and "u"
> for wide-unicode.

Ahh, thank you! I was planning to just statically link to my
executable to reduce deployment effort, but either way works.
Currently I'm puzzling over an inordinate number of symbol-not-found
errors, even though it does seem to be finding the header files. It's
weird.

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


Re: Building Python: static library "3.2m"

2011-05-22 Thread Chris Angelico
On Mon, May 23, 2011 at 2:08 PM, Chris Angelico  wrote:
> Currently I'm puzzling over an inordinate number of symbol-not-found
> errors, even though it does seem to be finding the header files. It's
> weird.

And I think I've just figured out why. PyString_* functions are no
longer supported - it's all PyUnicode now. Yes, I really am capable of
forgetting basics like that!

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


Re: Why did Quora choose Python for its development?

2011-05-22 Thread Octavian Rasnita

From: "Dennis Lee Bieber" 
Since indentation seems so crucial to easy comprehension of the logical 
structure of a program,

making it a mandatory syntactical structure becomes a desirable feature
for code that must be maintained (by others, in many cases).



Why "in many cases"? I wrote hundreads of programs which are working fine 
and which are maintained only by me. (But they would be very easy to 
maintain by other people if it would be necessary).

So in that case, why to be forced to use a strict indentation?



As for the dictionary from list... Do not confuse /algorithms/
selected by the programmer from what is part of the native language.
Otherwise one could complain that there is more than one way to code a
spam-filter using Python...



Exactly, I am not talking about a complex task that can be done in many ways 
in all programming languages.
I am talking about a simple way of creating a hash/dict from an array, which 
is so simple that there should be really a single way to do it, or very few.


Octavian

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


Re: Why did Quora choose Python for its development?

2011-05-22 Thread Octavian Rasnita

From: "Daniel Kluev" 
On Sun, May 22, 2011 at 11:47 PM, Octavian Rasnita  
wrote:

From: "Daniel Kluev" 
I am talking about that flexibility which was criticized in the previous 
messages telling that this flexibility allows any programmer to use his 
own way.
Perl doesn't force anyone to indent the code, don't force the programmer 
to define a hash element before using it, allow the programmer to 
interpret the variables in strings directly. These things should be not 
used always, but if in some cases if the programmer wants to use them, he 
can use them with no problems. And this means flexibility.


This is syntax-level flexibility, which, IMHO, does not affect
'advanceness' of modules at all. At language level, python is far more
flexible than perl with its magic methods and hooks, allowing to
overload any underlying language principles and protocols.



This means that you are forgetting Moose objects in Perl, right?
Moose is a very advanced object type system that will be the default type in 
Perl 6, but which was also implemented in Perl 5, which offers a lot of 
features for introspections in the object structure.


And the flexibility do offer the possibility of coding much easier and 
offering more features.
There are more, but a single eloquent feature is the possibility of 
interpreting variables in strings which cannot be done so nice in Python.


First, this is a bad style of mapping urls, because this list must be 
maintained every time the programmer changes something in a controller 
that makes the app need to use other urls.


Explicit is better than implicit.



This is false. Explicit in this case means to write code in 2 places for 
doing a certain thing, and maintaining means changing the code in 2 places, 
which is harder and prone to errors.



One of reasons why I chose Pylons/Pyramid as my standard toolkit is that 
it allowed me to define

mappers in any way I needed them to.



In Catalyst you can also define the url mappings in any way you need, not 
only based on controller/actions locations, but you don't need to do this by 
creating code in 2 places so it would be easier to maintain.
In Catalyst all the mappers are done "automaticly", but they can be done in 
any way you like, even in more ways that under Pylons/Pyramid as I shown 
(unless in Pylons/Pyramid can be also defined chained mappings and mappings 
based on regular expressions).




> If you want automatically defined mappers, there are lots of other
python frameworks and modules which do exactly that. Moreover, even
Routes itself (module, which does url mapping in Pylons) allows you to
use automated mappers, via :controller/:action tokens. It allows
pretty much everything you listed as 'features' of catalyst mappings.
If you prefer to stuff routing logic into controllers and have default
routing based on controllers and method names, you can use TurboGears
framework, which has exactly that mindset, or you can use its mapping
modules in Pyramid application.



Yes, the single difference is that Catalyst supports all of them, and it 
also supports using any templating system, and any ORM and any form 
processor, while some of the Python web frameworks don't support absolutely 
everything and you need to abandon some preferred modules for beeing able to 
use some other modules which are supported.



The module DBIx::Class which is used usually as an ORM can create the 
class files for all the tables from a database (MySQL, Oracle, 
PostgreSQL, SQLite, MS SQL, etc), and it can be used to search using 
unions, sub-selects, can define views at ORM level, can accept to insert 
different types of objects like DateTime objects and can also return 
those type of objects, and many other things, and most of the things it 
can do can be done without using SQL code at all, but only standard Perl 
code and Perl data structures.


There are lots of Python modules which do exactly this and much more.
SQLAlchemy, SQLObject, Web2Py's DAL, and so on. They are integrated
into frameworks by default.



I've checked the documentation for some of them and I've seen that most of 
them don't support sub-selects and some of them require using plain SQL code 
in their construct for more complex queries.
Please tell me which of them supports sub-selects, and are able to return 
objects for date and datetime fields that have methods for beeing able to 
print just the year or day, or the months names in the specified locale 
because it would be useful.



Yes, for web apps I have seen more things which can be done much better 
in Perl, much easier and clear, with less code, and not because the 
programmer needs to do not-recommended tricks for shortening the code, 
but because there are very many modules on CPAN that do the hard work.


I doubt you had enough experience with python frameworks like
Pyramid/Pylons or Web2Py. They have all features you listed, and code
is as trivial and clean, as it could ever be. Its surprising that you
present 

Re: Tkinter FileDialog

2011-05-22 Thread Godson Gera
Hi,

You can try the following

from Tkinter import*
root = Tk()
root.withdraw() #this will hide the main window
import tkFileDialog as tkf
f = tkf.Open().show()

tkFileDialog, requires a main window to be existing before it can show the
file dialog. If there are no main windows then it will create its own.
On Mon, May 23, 2011 at 1:43 AM, Alex van der Spek  wrote:

> Trying to bring up a simple File or Directory chooser using Tkinter. Right
> now I use pywin32  as Mark Hammond's extensions are somewhat more familiar
> to an (ex)VB programmer who started way back with Fortran.
>
> On Windows Vista with Python 2.7. The examples from Mark Lutz' book
> "Programming Python" do not immediately apply. The book describes Python 3.x
> only.
>
> This is what I do (in IDLE):
>
> import tkFileDialog as tk
> file2open=tk.Open().show()
>
> This works. But it also brings up a persistent Tk window. Killing this
> window forces a restart in IDLE, which is not desirable. There does not
> appear to be a way to multiselect files?
>
> I am probably missing a whole lot. Please point me to a simple example of
> GUI file manipulations. I can save myself with os.path.walk and os.listdir
> but the users I try to serve cannot.
>
> Regards,
> Alex van der Spek
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Thanks & Regards,
Godson Gera
FreeSWITCH & Python Consultant India 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Abandoning Python

2011-05-22 Thread Steven D'Aprano
On Mon, 23 May 2011 13:11:40 +1200, Gregory Ewing wrote:

> Ed Keith wrote:
>> Have you looked at Falcon (http://www.falconpl.org/)?
> 
> This paragraph on the first page doesn't exactly fire me with enthuiasm:
> 
>> Falcon provides six integrated programming paradigms: procedural,
>> object oriented, prototype oriented, functional, tabular and message
>> oriented. And you don't have to master all of them;
> 
> ...until you want to read someone *else's* code, that is.


The same might be said about Python, which supports procedural, OO and 
functional styles out of the box. Prototype-oriented is so close to OO 
that you can fake it in Python:

http://stackoverflow.com/questions/4629224/prototypal-programming-in-python

I'm not sure what they mean by tabular, perhaps something like Resolver 
System's Python-in-a-spreadsheet?

http://www.resolversystems.com/products/resolver-one/


And presumably anyone who has played around with GUI programming in 
Python will have run into message oriented coding.



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


Re: Why did Quora choose Python for its development?

2011-05-22 Thread Chris Angelico
On Mon, May 23, 2011 at 3:31 PM, Octavian Rasnita  wrote:
> From: "Dennis Lee Bieber" 
>>
>> Since indentation seems so crucial to easy comprehension of the logical
>> structure of a program,
>> making it a mandatory syntactical structure becomes a desirable feature
>> for code that must be maintained (by others, in many cases).
>
> Why "in many cases"? I wrote hundreads of programs which are working fine
> and which are maintained only by me. (But they would be very easy to
> maintain by other people if it would be necessary).
> So in that case, why to be forced to use a strict indentation?

The reason for clear code is maintenance, not maintenance-by-others.
If you come back to something in a year, you'll appreciate proper
variable names, indentation, etc.

That said, though, I still do not believe in Python's philosophy of
significant whitespace. I like to be able, if I choose, to put one
entire "logical unit" on one line, such that it can be commented out
with a single comment marker, or duplicated to another line and one
copy commented out, or whatever. To that end, I sometimes want to put
an if, its associated else, and sometimes a statement for both
branches, all in the one line. And that's not possible when whitespace
alone defines the end of an if/else block (the one-line form of a
Python 'if' can't have a non-conditional statement after it at all),
but is quite easy when things are delimited with braces.

Bug report: The "from __future__ import braces" statement isn't
working properly. Pls fix, kthxbye. :)

But I still like Python overall. There's no such thing as a perfect
language, and when it comes to syntax disagreements, I dislike
Python's significant whitespace far less than I dislike PHP's adorned
variable names. And Python, under the hood, is a very good engine for
doing what I need to do.

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


Re: Why did Quora choose Python for its development?

2011-05-22 Thread Terry Reedy

On 5/23/2011 1:31 AM, Octavian Rasnita wrote:



I am talking about a simple way of creating a hash/dict from an array,
which is so simple that there should be really a single way to do it, or
very few.


Again, Python has such:

>>> dict([['one',1],['two', 2]])
{'two': 2, 'one': 1}

--
Terry Jan Reedy

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


Re: Why did Quora choose Python for its development?

2011-05-22 Thread Carl Banks
On Sunday, May 22, 2011 12:44:18 AM UTC-7, Octavian Rasnita wrote:
> I've noticed that on many Perl mailing lists the list members talk very
> rarely about Python, but only on this Python mailing list I read many
> discussions about Perl, in which most of the participants use to agree that
> yes, Python is better, as it shouldn't be obvious that most of the list
> members prefer Python.

Evidently Perl users choose to bash other languages in those languages' own 
mailing lists.


> If Python would be so great, you wouldn't talk so much about how bad are
> other languages,

Sure we would.  Sometimes it's fun to sit on your lofty throne and scoff at the 
peasantry.


> or if these discussions are not initiated by envy, you would
> be also talking about how bad is Visual Basic, or Pascal, or Delphi, or who
> knows other languages.

I would suggest that envy isn't the reason, the reason is that Perl is just 
that much worse than Visual Basic, Pascal, and Delphi.  We only make fun of the 
really, really bad langauges.

(Or, less cynically, it's because Perl and Python historically filled the same 
niche, whereas VB, Pascal, and Delphi were often used for different sorts of 
programming.)


What I'm trying to say here is your logic is invalid.  People have all kinds of 
reasons to badmouth other languages; that some mailing list has a culture that 
is a bit more or a bit less approving of it than some other list tells us 
nothing.  In any case it's ridiculous to claim envy as factor nowadays, as 
Python is clearly on the rise while Perl is on the decline.  Few people are 
choosing Perl for new projects.


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