Re: Python is readable

2012-03-14 Thread alex23
Rick Johnson wrote: > However, when we are talking about the Python > programming language "readable" simply means: "neophyte readable". > That is, "readable to someone with little or no experience with the > language". Nonsense. List comprehensions are not immediately obvious to new Python users

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread Cameron Simpson
On 15Mar2012 12:22, Ben Finney wrote: | Roy Smith writes: | > I'll admit I hadn't considered that, but I don't see it as a major | > problem. The type intuition could be designed to only work for types | > other than NoneType. | | −1, then. It's growing too many special cases, and is no longer s

Re: Python is readable

2012-03-14 Thread Rick Johnson
On Mar 14, 7:27 pm, Chris Angelico wrote: > Okay, here's something for debate. > > Should the readability of a language be gauged on the basis of its > standard library, or should you be comparing actual code? I think the library matters greatly. Yes, one could argue that the same functionality "

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-14 Thread Dave Angel
On 03/14/2012 01:27 PM, Prasad, Ramit wrote: It seems like an excellent thing to add to the "os" module. If 'prctl' is a standard POSIX system call, then it should be a candidate for inclusion in the os module if someone opens a tracker enhancement issue and presents an argument in favor. I th

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread MRAB
On 15/03/2012 00:52, Roy Smith wrote: In article<4f612a9d$0$12033$742ec...@news.sonic.net>, John Nagle wrote: On 3/13/2012 2:08 PM, Roy Smith wrote: > Using argparse, if I write: > > parser.add_argument('--foo', default=100) > > it seems like it should be able to intuit that th

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread Ben Finney
Roy Smith writes: > I'll admit I hadn't considered that, but I don't see it as a major > problem. The type intuition could be designed to only work for types > other than NoneType. −1, then. It's growing too many special cases, and is no longer simple to describe, so that indicates it's probably

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread Roy Smith
In article <4f612a9d$0$12033$742ec...@news.sonic.net>, John Nagle wrote: > On 3/13/2012 2:08 PM, Roy Smith wrote: > > Using argparse, if I write: > > > > parser.add_argument('--foo', default=100) > > > > it seems like it should be able to intuit that the type of foo should > > be int (i.e.

Re: Python is readable

2012-03-14 Thread Chris Angelico
On Thu, Mar 15, 2012 at 10:54 AM, Arnaud Delobelle wrote: > I don't know this book and there may be a pedagogical reason for the > implementation you quote, but pairwise_sum is probably better > implemented in Python 3.X as: > > def pairwise_sum(list1, list2): >    return [x1 + x2 for x1, x2 in zi

Re: Style question (Poll)

2012-03-14 Thread Chris Angelico
On Thu, Mar 15, 2012 at 7:37 AM, Croepha wrote: > Which is preferred: > > for value in list: >  if not value is another_value: >    value.do_something() >    break > > --or-- > > if list and not list[0] is another_value: >  list[0].do_something() > > Comments are welcome, Thanks General principle

Re: Python is readable

2012-03-14 Thread Arnaud Delobelle
On 14 March 2012 23:34, Kiuhnm wrote: > I've just started to read >  The Quick Python Book (2nd ed.) > The author claims that Python code is more readable than Perl code and > provides this example: > > --- Perl --- > sub pairwise_sum { >    my($arg1, $arg2) = @_; >    my(@result) = (); >    @list

Python is readable

2012-03-14 Thread Kiuhnm
I've just started to read The Quick Python Book (2nd ed.) The author claims that Python code is more readable than Perl code and provides this example: --- Perl --- sub pairwise_sum { my($arg1, $arg2) = @_; my(@result) = (); @list1 = @$arg1; @list2 = @$arg2; for($i=0; $i <

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread John Nagle
On 3/13/2012 2:08 PM, Roy Smith wrote: Using argparse, if I write: parser.add_argument('--foo', default=100) it seems like it should be able to intuit that the type of foo should be int (i.e. type(default)) without my having to write: parser.add_argument('--foo', type=int, default=10

Re: How to decide if a object is instancemethod?

2012-03-14 Thread Steven D'Aprano
On Thu, 15 Mar 2012 08:26:22 +1100, Ben Finney wrote: > Jon Clements writes: > >> import inspect >> if inspect.ismethod(foo): >># ... >> >> Will return True if foo is a bound method. > > But under what other conditions will it return True? The name suggests > that *any* method – static meth

RE: Style question (Poll)

2012-03-14 Thread Prasad, Ramit
> > Only use 'is' if you are looking for objects like True, > > False, None or something that MUST be exactly the same object. > > I've rarely seen valid uses of 'is True' or 'is False'. It can be useful when you think something might be None or False. Although, I suppose you could always just us

Re: Style question (Poll)

2012-03-14 Thread Arnaud Delobelle
On 14 March 2012 22:15, Prasad, Ramit wrote: > Only use 'is' if you are looking for objects like True, > False, None or something that MUST be exactly the same object. I've rarely seen valid uses of 'is True' or 'is False'. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

RE: Style question (Poll)

2012-03-14 Thread Prasad, Ramit
> >> Which is preferred: > >> > >> for value in list: > >> if not value is another_value: > >> value.do_something() > >> break > > Do you really mean 'is' or '=='? Let me expound on how 'is' and '==' are very different. It may work for some comparisons but often not for others. Certain

Re: How to break long method name into more than one line?

2012-03-14 Thread Terry Reedy
On 3/14/2012 4:53 PM, Herman wrote: I followed the rule because it was a very good advice. For example, def test_plus_1Plus1_2(self): Suppose you want to test that a function call returns a particular 300-char multiline string? If this test fails, you immediately know that it's testing the

Re: How to decide if a object is instancemethod?

2012-03-14 Thread Ben Finney
Jon Clements writes: > import inspect > if inspect.ismethod(foo): ># ... > > Will return True if foo is a bound method. But under what other conditions will it return True? The name suggests that *any* method – static method, class method, bound method, unbound method – will also result in T

Re: Style question (Poll)

2012-03-14 Thread Terry Reedy
On 3/14/2012 4:49 PM, Arnaud Delobelle wrote: On 14 March 2012 20:37, Croepha wrote: Which is preferred: for value in list: if not value is another_value: value.do_something() break Do you really mean 'is' or '=='? If you mean x is not y, write it that way. 'not x is y' can be mis

Re: How to break long method name into more than one line?

2012-03-14 Thread Herman
I followed the rule because it was a very good advice. For example, def test_plus_1Plus1_2(self): If this test fails, you immediately know that it's testing the "plus" method, with 1 and 1 as the arguments, and expect to return 2. Sticking this rule also means your test cases are small enough, so

Re: Style question (Poll)

2012-03-14 Thread Arnaud Delobelle
On 14 March 2012 20:37, Croepha wrote: > Which is preferred: > > for value in list: >  if not value is another_value: >    value.do_something() >    break > > --or-- > > if list and not list[0] is another_value: >  list[0].do_something() Hard to say, since they don't do the same thing :) I suspe

Style question (Poll)

2012-03-14 Thread Croepha
Which is preferred: for value in list: if not value is another_value: value.do_something() break --or-- if list and not list[0] is another_value: list[0].do_something() Comments are welcome, Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a ConfigParser which keeps comments

2012-03-14 Thread Tim Chase
On 03/14/12 12:06, Terry Reedy wrote: On 3/14/2012 6:07 AM, Gelonida N wrote: Now I'm looking for a library, which behaves like config parser, but with one minor difference. The write() mehtod should keep existing comments. Assuming that you have not overlooked anything, I would just subclass

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread Ian Kelly
On Wed, Mar 14, 2012 at 7:30 AM, Roy Smith wrote: > It's already inferred that the type is a string if you don't give it any > value.  What possible meaning could: > > parser.add_argument('--foo', default=100) > > have?  If I run the program with: > > $ prog > > then foo defaults to the integer 10

Re: Global join function?

2012-03-14 Thread Peter Otten
Darrel Grant wrote: > In the virtualenv example bootstrap code, a global join function is used. > > http://pypi.python.org/pypi/virtualenv At this point there is probably an import that you have overlooked: from os.path import join > subprocess.call([join(home_dir, 'bin', 'easy_install'),

Re: Global join function?

2012-03-14 Thread Chris Rebert
On Wed, Mar 14, 2012 at 11:41 AM, Darrel Grant wrote: > In the virtualenv example bootstrap code, a global join function is used. > > http://pypi.python.org/pypi/virtualenv > >    subprocess.call([join(home_dir, 'bin', 'easy_install'), >                     'BlogApplication']) > > > In interpeter,

Re: Global join function?

2012-03-14 Thread Jon Clements
On Wednesday, 14 March 2012 18:41:27 UTC, Darrel Grant wrote: > In the virtualenv example bootstrap code, a global join function is used. > > http://pypi.python.org/pypi/virtualenv > > subprocess.call([join(home_dir, 'bin', 'easy_install'), > 'BlogApplication']) > > >

Global join function?

2012-03-14 Thread Darrel Grant
In the virtualenv example bootstrap code, a global join function is used. http://pypi.python.org/pypi/virtualenv subprocess.call([join(home_dir, 'bin', 'easy_install'), 'BlogApplication']) In interpeter, I tried this: >>> [join([], 'bin', 'easy_install')] Traceback (mo

blues

2012-03-14 Thread mabhanisi blues
Can i come in am i welcome -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-14 Thread Alain Ketterlin
Terry Reedy writes: > On 3/14/2012 12:02 PM, Grant Edwards wrote: > >> It seems like an excellent thing to add to the "os" module. > > If 'prctl' is a standard POSIX system call, then it should be a > candidate for inclusion in the os module if someone opens a tracker > enhancement issue and pres

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread MRAB
On 14/03/2012 13:30, Roy Smith wrote: In article<87399bgw18@benfinney.id.au>, Ben Finney wrote: Right. I dislike proposals for run-time type inference in Python, since they are too magical. Especially since we're talking about user input (arguments from the command line to the progr

RE: Is it technically possible to give Python option of naming process of running script?

2012-03-14 Thread Prasad, Ramit
> > > It seems like an excellent thing to add to the "os" module. > > > > If 'prctl' is a standard POSIX system call, then it should be a > > candidate for inclusion in the os module if someone opens a tracker > > enhancement issue and presents an argument in favor. > > > I think this request wa

RE: Is it technically possible to give Python option of naming process of running script?

2012-03-14 Thread Prasad, Ramit
> > It seems like an excellent thing to add to the "os" module. > > If 'prctl' is a standard POSIX system call, then it should be a > candidate for inclusion in the os module if someone opens a tracker > enhancement issue and presents an argument in favor. I think this request was already denied

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-14 Thread Terry Reedy
On 3/14/2012 12:02 PM, Grant Edwards wrote: It seems like an excellent thing to add to the "os" module. If 'prctl' is a standard POSIX system call, then it should be a candidate for inclusion in the os module if someone opens a tracker enhancement issue and presents an argument in favor. -

Re: Is there a ConfigParser which keeps comments

2012-03-14 Thread Terry Reedy
On 3/14/2012 6:07 AM, Gelonida N wrote: Hi, At the moment I use ConfigParser http://docs.python.org/library/configparser.html for one of my applications. Now I'm looking for a library, which behaves like config parser, but with one minor difference. The write() mehtod should keep existing co

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-14 Thread Grant Edwards
On 2012-03-14, Chris Angelico wrote: > On Thu, Mar 15, 2012 at 1:43 AM, xliiv wrote: >> Like the topic.. . >> I use Python a lot, both Windows and Linux, and it's little weird to have >> many python process without fast distinction which is what. > > I've no idea if it's even possible on Windows

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-14 Thread Chris Angelico
On Thu, Mar 15, 2012 at 1:43 AM, xliiv wrote: > Like the topic.. . > I use Python a lot, both Windows and Linux, and it's little weird to have > many python process without fast distinction which is what. I've no idea if it's even possible on Windows. On Linux, what you want is the prctl functio

Re: Jinja2 + jQuery tabs widget

2012-03-14 Thread JoeM
Disregard, apparently you can't include a {block} more than once in a Jinja2 template, which was causing the error. Cheers, Joed -- http://mail.python.org/mailman/listinfo/python-list

Is it technically possible to give Python option of naming process of running script?

2012-03-14 Thread xliiv
Like the topic.. . I use Python a lot, both Windows and Linux, and it's little weird to have many python process without fast distinction which is what. -- http://mail.python.org/mailman/listinfo/python-list

Re: Jinja2 + jQuery tabs widget

2012-03-14 Thread Jon Clements
On Wednesday, 14 March 2012 14:16:35 UTC, JoeM wrote: > Hi All, > > I'm having issues including a {block} of content from Jinja2 > template into a jQueryUI tab. Does anyone know if such a thing is > possible? An example is below, which gives me a 500 error when loading > the page. > > Thank

Re: concatenate function

2012-03-14 Thread ferreirafm
Hi there, The problem has been solved. I 've decided to run the python script as argument of qsub instead of run qsub from inside of the script itself. I also use .wait() as suggest by colleagues above. Final code goes here: http://ompldr.org/vZDFiag Thank you very much for helping. -- View th

Re: Instantiate a python class object in C

2012-03-14 Thread Dids
Ok, I have it :) PyImport_Import , PyModule_GetDict, PyDict_GetItemString and PyObject_CallObject Need to take a second look at cython when I have a spare cycle or 2. Thanks for the the tip :) A+ Dids, -- http://mail.python.org/mailman/listinfo/python-list

Re: Instantiate a python class object in C

2012-03-14 Thread Stefan Behnel
Dids, 14.03.2012 14:46: > Apologies if this was asked before, I couldn't find anything. > > I have a class defined in a python file: > for example: > > class demo: > [ class definition goes here] > > I'm writing a C extension. > In the first function, I take an instance of the "demo" class

Re: How to decide if a object is instancemethod?

2012-03-14 Thread Jon Clements
On Wednesday, 14 March 2012 13:28:58 UTC, Cosmia Luna wrote: > class Foo(object): > def bar(self): > return 'Something' > > func = Foo().bar > > if type(func) == : # This should be always true > pass # do something here > > What should type at ? > > Thanks > Cosmia import insp

Instantiate a python class object in C

2012-03-14 Thread Dids
Hi, Apologies if this was asked before, I couldn't find anything. I have a class defined in a python file: for example: class demo: [ class definition goes here] I'm writing a C extension. In the first function, I take an instance of the "demo" class and do my magic. It's working, all is

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread Roy Smith
In article <87399bgw18@benfinney.id.au>, Ben Finney wrote: > Right. I dislike proposals for run-time type inference in Python, since > they are too magical. > > Especially since we're talking about user input (arguments from the > command line to the program); that requires more explicit de

How to decide if a object is instancemethod?

2012-03-14 Thread Cosmia Luna
class Foo(object): def bar(self): return 'Something' func = Foo().bar if type(func) == : # This should be always true pass # do something here What should type at ? Thanks Cosmia -- http://mail.python.org/mailman/listinfo/python-list

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread Ben Finney
Steven D'Aprano writes: > On Wed, 14 Mar 2012 08:35:12 +1100, Ben Finney wrote: > > That feels too magical to me. I don't see a need to special-case > > that usage. There's not much burden in being explicit for the > > argument type. > > And yet you are programming in Python instead of Java, Pasc

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread Ulrich Eckhardt
Am 13.03.2012 22:08, schrieb Roy Smith: Using argparse, if I write: parser.add_argument('--foo', default=100) it seems like it should be able to intuit that the type of foo should be int (i.e. type(default)) without my having to write: parser.add_argument('--foo', type=int, default=1

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread Steven D'Aprano
On Wed, 14 Mar 2012 08:35:12 +1100, Ben Finney wrote: > r...@panix.com (Roy Smith) writes: > >> Using argparse, if I write: >> >> parser.add_argument('--foo', default=100) >> >> it seems like it should be able to intuit that the type of foo should >> be int (i.e. type(default)) > […] > > -0.

Info on RIDE

2012-03-14 Thread laloo
Hi Sir I have installed the robot framework but have a problem understanding the RIDE and how to execute Data driven Test Case If you can take me through this on Skype it will be really great. Thanks Laloo Thadhani -- http://mail.python.org/mailman/listinfo/python-list

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread rusi
On Mar 14, 2:08 am, r...@panix.com (Roy Smith) wrote: > Using argparse, if I write: > >     parser.add_argument('--foo', default=100) > > it seems like it should be able to intuit that the type of foo should > be int (i.e. type(default)) without my having to write: > >     parser.add_argument('--fo

Is there a ConfigParser which keeps comments

2012-03-14 Thread Gelonida N
Hi, At the moment I use ConfigParser http://docs.python.org/library/configparser.html for one of my applications. Now I'm looking for a library, which behaves like config parser, but with one minor difference. The write() mehtod should keep existing comments. Does anybody know or implement so

Re: PyCrypto builds neither with MSVC nor MinGW

2012-03-14 Thread Alec Taylor
Oh wait, just realised it was loading the (x86) tools. Doing a quick search I noticed that I didn't have the x64 components installed, so loading up the MSVC08 setup again and installing it, then: copying vcvarsamd64.bat to vcvarsall.bat and adding its directory (C:\Program Files (x86)\Microsoft Vi