Re: Catch exception with message?

2016-06-03 Thread Piyush Verma
Below is exception type and it is user defined exception. I do not see error number in exception stack. What other option we can use as filter in below exception apart from message? UserDefinedException: User defined message: {} #012 File "/opt/cio/lib/python2.7/site-packages/manager.py", line 11

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Ian Kelly
On Jun 3, 2016 7:12 PM, "Gregory Ewing" wrote: > > 4. It must not matter what order the methods in a super > chain are called. This is because you cannot predict > which method a given super call will invoke. It could > belong to a subclass of the class making the call. It can't belong to a subcl

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Christopher Reimer
On 6/3/2016 7:31 PM, Steven D'Aprano wrote: On Sat, 4 Jun 2016 09:06 am, Sayth Renshaw wrote: I cant create a list with an append method pf.append(thing) in one go . Correct. You cannot append to a list until the list exists. Nor can you uppercase a string until the string exists: s = "hell

Re: for / while else doesn't make sense

2016-06-03 Thread Lawrence D’Oliveiro
On Saturday, June 4, 2016 at 3:00:36 PM UTC+12, Steven D'Aprano wrote: > You can exit a loop because you have run out of items to process, or you can > exit the loop because a certain condition has been met. But why should they be expressed differently? item_iter = iter(items) while True

Re: for / while else doesn't make sense

2016-06-03 Thread Lawrence D’Oliveiro
On Saturday, June 4, 2016 at 2:22:18 PM UTC+12, Steven D'Aprano wrote: > and a loop with two or more exits a *trivially different* way: > > for x in seq: > do_something() > if condition: > break > if another_condition: > break But that loop has 3 exits, written in two

Re: for / while else doesn't make sense

2016-06-03 Thread Steven D'Aprano
On Sat, 4 Jun 2016 02:24 am, Lawrence D’Oliveiro wrote: > On Saturday, June 4, 2016 at 3:52:42 AM UTC+12, Rob Gaddi wrote: >> Lawrence D’Oliveiro wrote: >> >>> The reason why I don’t like this is that there are two ways out of the >>> Python for-statement, and they are written quite differently.

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Steven D'Aprano
On Sat, 4 Jun 2016 11:06 am, Gregory Ewing wrote: > Nagy László Zsolt wrote: >> I do not use diamond shapes in my hierarchy, I guess that does not >> affect me. I may be wrong. > > If there are no diamonds, In Python 3, or Python 2 with new-style classes, there are ALWAYS diamonds when you use

Re: Catch exception with message?

2016-06-03 Thread Steven D'Aprano
On Sat, 4 Jun 2016 09:14 am, Piyush Verma wrote: > Generally we catch exception using > except Exception as e: > > But sometimes, we see same type of exception is present with different > message. That suggests that whoever wrote the code doesn't know what they're doing. Intentionally giving the

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Steven D'Aprano
On Sat, 4 Jun 2016 09:06 am, Sayth Renshaw wrote: > I cant create a list with an append method pf.append(thing) in one go . Correct. You cannot append to a list until the list exists. Nor can you uppercase a string until the string exists: s = "hello world" s = s.uppercase() Nor can you add o

Re: Don't put your software in the public domain

2016-06-03 Thread Steven D'Aprano
On Sat, 4 Jun 2016 06:58 am, Nobody wrote: > OTOH, a Free software licence is unilateral; the author grants the user > certain rights, with the user providing nothing in return. That's not the case with the GPL. The GPL requires the user (not the end-user, who merely avails themselves of their c

Re: for / while else doesn't make sense

2016-06-03 Thread Steven D'Aprano
On Sat, 4 Jun 2016 02:22 am, Lawrence D’Oliveiro wrote: > In Python you write a loop with one exit in one way, a loop with two exits > in a different way, and a loop with more than two exits in yet another > entirely different way. Can you say “cognitive burden”? Yes I can, but I don't see the po

Re: Don't put your software in the public domain

2016-06-03 Thread Steven D'Aprano
On Sat, 4 Jun 2016 02:15 am, Lawrence D’Oliveiro wrote: > On Friday, June 3, 2016 at 9:53:47 PM UTC+12, Steven D'Aprano wrote: > >> A licence is something like a contract... > > A licence is quite different from a contract. A contract requires some > indication of explicit agreement by both part

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Terry Reedy
On 6/3/2016 10:20 AM, Sayth Renshaw wrote: Very briefly because I hope to shot down eloquently. Python is beautiful and is supposed to be a duck typed language, Yes? Then if I create and assign to a new variable with a list action why does the duck not quack? It feels wrong to spend a line wr

Re: Don't put your software in the public domain

2016-06-03 Thread Steven D'Aprano
On Fri, 3 Jun 2016 11:14 pm, Michael Torrie wrote: > I'm not sure this is completely right. The GPL explicitly says one doesn't > have to agree to the GPL to use the software. The GPL only comes into > affect when distribution is involved. Yes, you're right, I was unclear. See https://opensour

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Gregory Ewing
Ben Finney wrote: With classes all inheriting ultimately from ‘object’ (as all Python 3 classes do, and as all current Python 2 classes should), mutliple inheritance inevitably places your classes in a diamond inheritance pattern. That's usually harmless, though, because object provides very li

Re: Catch exception with message?

2016-06-03 Thread cs
On 04Jun2016 04:44, Piyush Verma <114piy...@gmail.com> wrote: Generally we catch exception using except Exception as e: But sometimes, we see same type of exception is present with different message.Is there a way to capture same exception with message filtering? Please help me to do this. Qui

Re: Don't put your software in the public domain

2016-06-03 Thread Lawrence D’Oliveiro
On Saturday, June 4, 2016 at 8:58:19 AM UTC+12, Nobody wrote: > On Fri, 03 Jun 2016 09:15:55 -0700, Lawrence D’Oliveiro wrote: > > >> [quoted text muted] > > > > A licence is quite different from a contract. A contract requires some > > indication of explicit agreement by both parties, a licence

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Gregory Ewing
Nagy László Zsolt wrote: I do not use diamond shapes in my hierarchy, I guess that does not affect me. I may be wrong. If there are no diamonds, there is no need to use super. Explicit inherited method calls, done correctly, will work fine. The only downside is that if your inheritance hierarc

Re: Catch exception with message?

2016-06-03 Thread Ben Finney
Piyush Verma <114piy...@gmail.com> writes: > But sometimes, we see same type of exception is present with different > message.Is there a way to capture same exception with message > filtering? Please help me to do this. That's a nasty code smell. Why would you want your code to behave differently

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Ben Finney
Ian Kelly writes: > Except that since we're discussing design for multiple inheritance, > the positional argument "spam" is inappropriate. All arguments should > be passed by keyword; the DolorSitAmet.__init__ method cannot be > certain that LoremIpsum will be the next class in the MRO, and the >

Re: Catch exception with message?

2016-06-03 Thread Random832
On Fri, Jun 3, 2016, at 19:14, Piyush Verma wrote: > Generally we catch exception using > except Exception as e: > > But sometimes, we see same type of exception is present with different > message.Is there a way to capture same exception with message > filtering? Please help me to do this. The m

Re: Catch exception with message?

2016-06-03 Thread Ian Kelly
try: something except Exception as e: if e.args[0] == message_of_interest: handle_it else: raise On Fri, Jun 3, 2016 at 5:14 PM, Piyush Verma <114piy...@gmail.com> wrote: > Generally we catch exception using > except Exception as e: > > But sometimes, we see same type o

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Sayth Renshaw
> > def getsMeet(files=file_list): > > """Get a File or List of Files. > > > > From the list of files determine > > what meetings exist and prepare them > > to be parsed > > """ > > pyqFiles = [] > > for filename in sorted(file_list): > > pyqFiles = pyqF

Catch exception with message?

2016-06-03 Thread Piyush Verma
Generally we catch exception using except Exception as e: But sometimes, we see same type of exception is present with different message.Is there a way to capture same exception with message filtering? Please help me to do this. Regards, ~Piyush -- https://mail.python.org/mailman/listinfo/python

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Sayth Renshaw
> > pyqFiles = [] > > for filename in sorted(file_list): > > pyqFiles = pyqFiles.append(pq(filename=my_dir + filename)) > > > > return pyqFiles > > [snip] > > PS I am really having a lot of fun coding. > > To have even more fun, note that the above can be replaced by [unteste

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Sayth Renshaw
On Saturday, 4 June 2016 02:04:43 UTC+10, Michael Selik wrote: > > > That totally makes sense I was just double checking, had hoped I could > > create a variable assign it to a list and append in one stroke. > > > > In fact you can! It's called a "list comprehension" > > pyqFiles = [pq(my_

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Ian Kelly
On Fri, Jun 3, 2016 at 2:16 PM, Ben Finney wrote: > If you're writing a custom initialiser that handles two additional > parameters, then those parameters should not be present when you call > the super() method's initialiser:: > > # You specified Python 3, which allows simpler syntax. > >

Re: Don't put your software in the public domain

2016-06-03 Thread Nobody
On Fri, 03 Jun 2016 09:15:55 -0700, Lawrence D’Oliveiro wrote: >> [quoted text muted] > > A licence is quite different from a contract. A contract requires some > indication of explicit agreement by both parties, a licence does not. More precisely, it requires "mutual consideration", i.e. each p

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Ben Finney
Nagy László Zsolt writes: > Fortunately, I can change all of the classes, and extracting the > common parameter into a common base class worked. This is why Liskov's Substitution Principle is good: Thinking of it as a law helps lead to better design. In this case, the same parameter doing diffe

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Ben Finney
Nagy László Zsolt writes: > So you are right: the custom __init__ in the BootstrapDesktop class is > not really needed, and does not do anything useful in that particular > class. I disagree: setting initial attributes is a normal and useful case for defining a custom initialiser. > My original

Re: [Q] ImportError by __import__() on Python >= 3.4

2016-06-03 Thread MRAB
On 2016-06-03 06:48, Makoto Kuwata wrote: On Fri, Jun 3, 2016 at 9:31 AM, MRAB > wrote: On 2016-06-02 15:04, Makoto Kuwata wrote: Hi, I have a trouble around __import__(). The following sample code works well on Python <= 3.3,

Re: Recommendation for Object-Oriented systems to study

2016-06-03 Thread Ankush Thakur
On Wednesday, June 1, 2016 at 2:53:22 PM UTC+5:30, Terry Reedy wrote: > On 5/31/2016 1:52 PM, Ankush Thakur wrote: > > Hi Terry, > > > > Can you point me towards the source code? > > For IDLE 3.4.4 or 3.5.1: /Lib/idlelib/help.py, at least on > Windows. > > > by "after reading it carefully", do

Re: Recommendation for Object-Oriented systems to study

2016-06-03 Thread Ankush Thakur
On Friday, June 3, 2016 at 7:54:55 PM UTC+5:30, Sayth Renshaw wrote: > On Monday, 30 May 2016 00:42:17 UTC+10, Ankush Thakur wrote: > > Hello, > > > > I'm a self-taught programmer who has managed to claw his way out of Python > > basics and even covered the intermediate parts. But I feel I have

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Michael Selik
On Fri, Jun 3, 2016 at 12:01 PM Nagy László Zsolt wrote: > > Is the problem that the attribute or parameter has the same name in > both base classes, but has different meanings in each? > If they had different meanings, a simple rename would solve the problem. > Sometimes finding a good name ain

Re: for / while else doesn't make sense

2016-06-03 Thread Lawrence D’Oliveiro
On Saturday, June 4, 2016 at 3:52:42 AM UTC+12, Rob Gaddi wrote: > Lawrence D’Oliveiro wrote: > >> The reason why I don’t like this is that there are two ways out of the >> Python for-statement, and they are written quite differently. Why the >> asymmetry? Logically, all ways out of a loop are of

Re: for / while else doesn't make sense

2016-06-03 Thread Lawrence D’Oliveiro
On Friday, June 3, 2016 at 9:33:32 PM UTC+12, BartC wrote: > On 03/06/2016 03:47, Lawrence D’Oliveiro wrote: >> On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote: >>> Simple iterative for-loops are more of a DIY effort... >> >> There is one case that Python handles more nicely than C. > >

Re: Don't put your software in the public domain

2016-06-03 Thread Lawrence D’Oliveiro
On Friday, June 3, 2016 at 9:53:47 PM UTC+12, Steven D'Aprano wrote: > A licence is something like a contract... A licence is quite different from a contract. A contract requires some indication of explicit agreement by both parties, a licence does not. That’s why Free Software licences only ha

Re: Recommendation for Object-Oriented systems to study

2016-06-03 Thread Lawrence D’Oliveiro
On Friday, June 3, 2016 at 9:12:19 PM UTC+12, Phuong Phan wrote: > However, when I have chance to learn and work with other languages such as > C# and C++. I found that they are also supercool. Have you been exposed to Lisp yet? -- https://mail.python.org/mailman/listinfo/python-list

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Nagy László Zsolt
def getsMeet(files=file_list): """Get a File or List of Files. From the list of files determine what meetings exist and prepare them to be parsed """ pyqFiles = [] for filename in sorted(file_list): pyqFiles = pyqFiles.append(pq(filename=my_dir + file

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Peter Pearson
On Fri, 3 Jun 2016 07:20:24 -0700 (PDT), Sayth Renshaw wrote: [snip] > pyqFiles = [] > for filename in sorted(file_list): > pyqFiles = pyqFiles.append(pq(filename=my_dir + filename)) > > return pyqFiles [snip] > PS I am really having a lot of fun coding. To have even more fun,

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Michael Selik
On Fri, Jun 3, 2016 at 11:58 AM Sayth Renshaw wrote: > That totally makes sense I was just double checking, had hoped I could > create a variable assign it to a list and append in one stroke. > In fact you can! It's called a "list comprehension" pyqFiles = [pq(my_dir + filename) for filenam

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Nagy László Zsolt
Is the problem that the attribute or parameter has the same name in both base classes, but has different meanings in each? If they had different meanings, a simple rename would solve the problem. They have the same meaning. If you can't change the base classes, I've got some other solutions,

Re: for / while else doesn't make sense

2016-06-03 Thread Rob Gaddi
Lawrence D’Oliveiro wrote: > On Friday, June 3, 2016 at 8:09:21 AM UTC+12, Rob Gaddi wrote: >> Although your loop is really the _canonical_ use case for >> >> for loopvar in range(initial_value, limit+1): >> processing >> if found_what_im_looking_for: >> break >> else: >> do_w

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Sayth Renshaw
That totally makes sense I was just double checking, had hoped I could create a variable assign it to a list and append in one stroke. Thanks Sayth -- https://mail.python.org/mailman/listinfo/python-list

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Matt Wheeler
Hi, On Fri, 3 Jun 2016, 16:04 Sayth Renshaw, wrote: > > So at the point I create the variable it refers to an object. > It's best to think of them as names, rather than variables, as names in python don't behave quite how you'll expect variables to if you're coming from some other languages. M

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Ian Kelly
On Fri, Jun 3, 2016 at 9:04 AM, Sayth Renshaw wrote: > > >> The problem is that you think that *variables* have a type. This isn't >> the case. Objects have a type. A variable is a name by which you can >> refer to an object. There are various ways in which you can associate a >> object with a var

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Michael Selik
On Fri, Jun 3, 2016 at 10:41 AM Ian Kelly wrote: > On Fri, Jun 3, 2016 at 8:06 AM, Nagy László Zsolt > wrote: > > There is still something I don't get: how to create cooperative classes > > when some base classes share some of the parameters? > > Why do they need to share the same parameter? >

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Sayth Renshaw
> The problem is that you think that *variables* have a type. This isn't > the case. Objects have a type. A variable is a name by which you can > refer to an object. There are various ways in which you can associate a > object with a variable, the most obvious being an assignment statement. So a

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Paul Rudin
Sayth Renshaw writes: > Very briefly because I hope to shot down eloquently. > > Python is beautiful and is supposed to be a duck typed language, Yes? > > Then if I create and assign to a new variable with a list action why > does the duck not quack? > > It feels wrong to spend a line writing wha

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Ian Kelly
On Fri, Jun 3, 2016 at 8:06 AM, Nagy László Zsolt wrote: > >>> That's overly strict. As Raymond shows, it is easy to deal with >>> changing method signatures in *cooperative* classes. >> I must watch that for sure. > > All right, I have read this: > > https://rhettinger.wordpress.com/2011/05/26/su

Re: Recommendation for Object-Oriented systems to study

2016-06-03 Thread Sayth Renshaw
On Monday, 30 May 2016 00:42:17 UTC+10, Ankush Thakur wrote: > Hello, > > I'm a self-taught programmer who has managed to claw his way out of Python > basics and even covered the intermediate parts. But I feel I have a ton of > theory in my head and would like to see some smallish applications

I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Sayth Renshaw
Very briefly because I hope to shot down eloquently. Python is beautiful and is supposed to be a duck typed language, Yes? Then if I create and assign to a new variable with a list action why does the duck not quack? It feels wrong to spend a line writing what is already obvious def getsMeet(f

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Nagy László Zsolt
>> That's overly strict. As Raymond shows, it is easy to deal with >> changing method signatures in *cooperative* classes. > I must watch that for sure. All right, I have read this: https://rhettinger.wordpress.com/2011/05/26/super-considered-super/ There is still something I don't get: how to

Re: Don't put your software in the public domain

2016-06-03 Thread Michael Torrie
On Jun 3, 2016 04:57, "Steven D'Aprano" wrote: > (1) If the GPL licence is valid, then they are in breach of the licence > terms, the licence is revoked, and they are not legally permitted to > distribute or use the software; > > (2) If, as some people insist, the GPL licence is not valid, then th

Re: Storing data in mysql

2016-06-03 Thread mbg1708
On Thursday, 2 June 2016 09:51:59 UTC+1, Anup reni wrote: > How to store this 3 dimensional data in Mysql database for plotting on map? > ​ Actually, this looks like a question about the use of the SQL standard. I really like Joe Celko's book "Instant SQL Programming".which provides LOTS of

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Nagy László Zsolt
>> But I have to initialize some default attributes. > Then the statement “there is NOTHING else here” must be false. Either > the custom ‘__init__’ does something useful, or it doesn't. Well... the custom __init__ method with nothing else just a super() call was expressed there to show the super

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Steven D'Aprano
On Fri, 3 Jun 2016 07:18 am, Random832 wrote: > On Thu, Jun 2, 2016, at 13:36, Steven D'Aprano wrote: [...] >> But since the constructor/initialiser methods are so closely linked, many >> people are satisfied to speak loosely and refer to "the constructor" as >> either, unless they specifically wi

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Nagy László Zsolt
> Raymond Hettinger gives an excellent presentation where he describes various > problems with MI and gives solutions for them. I think this might be it: > > http://pyvideo.org/video/1094/the-art-of-subclassing-0 This is a much better version from one year later: https://www.youtube.com/watch?v=m

Re: Python on Windows with linux environment

2016-06-03 Thread Eric S. Johansson
On 6/3/2016 12:02 AM, Muhammad Ali wrote: > On Friday, June 3, 2016 at 6:27:50 AM UTC+8, Eric S. Johansson wrote: >> On 6/2/2016 2:03 PM, Joel Goldstick wrote: >>> Although the OP is using Windows 7, according to recent articles, >>> Ubuntu is teaming with MS for Windows 10 to include a bash shell,

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Ben Finney
Nagy László Zsolt writes: > > [...] > >> class BootstrapDesktop(BootstrapWidget, BaseDesktop): > >> def __init__(self, appserver, session): > >> # there is NOTHING else here, it just connects bootstrap widget > >> implementation with desktop methods > >> super(BootstrapDeskto

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Nagy László Zsolt
> > In Python 3, that will be automatic and you don't need to worry about it. I'm using Python 3. I'm aware of old style and new style classes in Python 2. > > > [...] >> class BootstrapDesktop(BootstrapWidget, BaseDesktop): >> def __init__(self, appserver, session): >> # there is NOT

EuroPython 2016 Keynote: Gaël Varoquaux

2016-06-03 Thread M.-A. Lemburg
We are pleased to announce our final keynote speaker for EuroPython 2016: *** Gaël Varoquaux *** About Gaël Varoquaux Gaël Varoquaux is an INRIA faculty researcher working on data science for brain imaging in the Neurospin brain research institute

Re: Don't put your software in the public domain

2016-06-03 Thread Steven D'Aprano
On Thu, 2 Jun 2016 04:41 pm, Gregory Ewing wrote: > Steven D'Aprano wrote: > >> http://linuxmafia.com/faq/Licensing_and_Law/public-domain.html > > From that: >> It might be ruled to create a global licence for unrestricted use. That > > licence might or might not then be adjudicated to be revo

Re: for / while else doesn't make sense

2016-06-03 Thread BartC
On 03/06/2016 03:47, Lawrence D’Oliveiro wrote: On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote: Simple iterative for-loops are more of a DIY effort... There is one case that Python handles more nicely than C. And that is iterating over a fixed set of values. E.g. in Python for

Re: for / while else doesn't make sense

2016-06-03 Thread BartC
On 03/06/2016 02:05, Lawrence D’Oliveiro wrote: On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote: One major objection was that C's 'for' isn't really a for-statement at all (as it is understood in most other languages that haven't just copied C's version), but is closer to a 'while' sta

Re: Recommendation for Object-Oriented systems to study

2016-06-03 Thread Phuong Phan
Hi All, I think you all are very professional programmer and or working in IT industry, teaching programming and so on. So I think it is quite funny that you spent time to discuss about this topic. I am not pro like you guys. I like programming. And when I think to develop my career as an IT engi