Re: [BangPypers] Django - Infinte Loop

2014-07-08 Thread Navin Kabra
1. Why are you doing this using a signal? Signals are best used when saving of Model1 needs to trigger some action on Model2. If you want to modify Model1 itself, you're better off doing this inside MyModel::save 2. If you really want to do it this way, put an if condition in my_func so that

Re: [BangPypers] Multiple return values from a function : Where to draw the line ?

2014-05-23 Thread Navin Kabra
Mandar Vaze / मंदार वझे mandarv...@gmail.com writes: Code 1: ... return dict(fname=fname, lname=lname, saluation=salutation, gender=gender, addr1=addr1, addr2=addr2, city=city, state=state, country=country) First of all, both functions are returning a single value, a

Re: [BangPypers] First python interview

2013-10-14 Thread Navin Kabra
of python closures. A lot of complex code gets written by people who don't think of using an appropriate closure - The 'with' statement. - Properties. I adapted this from here: http://www.quora.com/Navin-Kabra/answers/Python-programming-language-1 Also check out this StackOverflow question: http

Re: [BangPypers] [Novice] Question on File seek and tell methods

2013-06-17 Thread Navin Kabra
The way I would do this is as follows: I would use itertools to make the code more concise. Also, a strong recommendation that `with` should be used whenever you want to open a file. And use of the `print_function` from `__future__` for python-3 compatibility. from __future__ import

Re: [BangPypers] Python dictionaries, deleting elements while iterating.

2013-02-25 Thread Navin Kabra
Anand Chitipothu anandol...@gmail.com writes: loop. In Python 3, it can be written as a dictionary-comprehension. Dictionary and set comprehensions are also available in Python 2.7 ___ BangPypers mailing list BangPypers@python.org

Re: [BangPypers] python framework for android

2012-01-03 Thread Navin Kabra
On Wed, Jan 4, 2012 at 11:37 AM, Kenneth Gonsalves law...@gmail.com wrote: can anyone recommend a python framework for android? Negative vote for SL4A (previously known as ASE - Android Scripting Environment). I have played with it, and I think it is largely a toy - it is good for personal use -

Re: [BangPypers] ElementTree object instance evaluates to False?

2011-12-05 Thread Navin Kabra
On Tue, Dec 6, 2011 at 9:49 AM, Vikas BN vikas...@gmail.com wrote:    I'm working on a script to parse XML files and am using cElementTree for the same. However,    I was under the impression that anything that's a None type or 0 or would evaluate to False    and the rest would be True (incl

Re: [BangPypers] continue in try..except

2011-11-19 Thread Navin Kabra
On Sat, Nov 19, 2011 at 8:31 PM, Nikunj Badjatya nikunjbadja...@gmail.comwrote: Can someone throw some light on this please. If I understand right, this is what you want to do: Somewhere deep inside the main function, an exception is thrown. In the exception handler, if some condition is

Re: [BangPypers] if not with comparision statement in python

2011-07-30 Thread Navin Kabra
On Sat, Jul 30, 2011 at 1:13 PM, Asif Jamadar asif.jama...@rezayat.net wrote: if not minimum=actual_result and  not maximum=actual_result: How to check if actual result is not laying between minimum value and maximum value. if not minimum = actual_result = maximum:

Re: [BangPypers] [OT] getting a business email vendor

2011-06-30 Thread Navin Kabra
On Thu, Jun 30, 2011 at 11:57 AM, Vishal vsapr...@gmail.com wrote: We would like to have a *good* business email vendor, and hosting for our website. Would like to know the ones you have found to be good in *India*. Try Mithi Software (http://www.mithi.com/) a Pune-based company.

Re: [BangPypers] Nice feature

2011-04-01 Thread Navin Kabra
With Python 2.6.5 (on ubuntu) I get even more bizarre behavior: foo=(1,[2,3,4]) foo[1]+=6 Traceback (most recent call last): File stdin, line 1, in module TypeError: 'int' object is not iterable foo (1, [8, 9, 10]) On Fri, Apr 1, 2011 at 6:17 PM, Noufal Ibrahim nou...@gmail.com wrote:

Re: [BangPypers] Fwd: Help with Python IDE's

2011-03-27 Thread Navin Kabra
On Mon, Mar 28, 2011 at 9:18 AM, Gora Mohanty g...@mimirtech.com wrote: Most any IDE that one is using, and that handles Python should work. Personally, I use emacs with various modes for Django development. Can you share exactly which modes you're using for django developement. I use

Re: [BangPypers] issues using constructor in unittest

2011-03-14 Thread Navin Kabra
On Mon, Mar 14, 2011 at 1:56 PM, Nitin Kumar nitin.n...@gmail.com wrote: See below small example. I am trying to have one constructor for a class with unittest inherited. Avoid overriding the constructor of TestCase. That is not recommended. self.x = 3 Put this is setUp

Re: [BangPypers] Proposed python module: simpleoauth

2011-03-10 Thread Navin Kabra
On Thu, Mar 10, 2011 at 12:32 PM, Baishampayan Ghose b.gh...@gmail.comwrote: Where is the code? simpleoauth/__init__.py seems to have only one line - /home/navin/d/hacks/python/oauth/simple_oauth.py Aargh... sorry. Checked in from the wrong directory. It should be fixed now. (Deleted and

[BangPypers] Proposed python module: simpleoauth

2011-03-09 Thread Navin Kabra
Hi All, Need your help on this. After getting very confused and frustrated at the state of OAuth libraries in python, I decided that there needs to be a simpler way of doing OAuth in Python. As a proof-of-concept I've implemented the following: https://github.com/ngkabra/simpleoauth The design

Re: [BangPypers] [JOB] Python developer required in Pune with web development experience

2011-01-12 Thread Navin Kabra
On Thu, Jan 13, 2011 at 11:44 AM, Kenneth Gonsalves law...@au-kbc.orgwrote: or a way of saying: 'there is going to be bargaining here'? I think it's a way of saying: Salary will depend upon who you are, how much experience you have, what your current salary is, and how desperately we need you.

Re: [BangPypers] regular expression for Indian landline numbers

2010-11-25 Thread Navin Kabra
On Fri, Nov 26, 2010 at 9:03 AM, Dhananjay Nene dhananjay.n...@gmail.comwrote: Thus there could be the optional prefixes +91 or 0 followed by an additional sequence of numbers which may have embedded some spaces, hyphens or in rare cases parenthesis which are quite ignorable. So all one

Re: [BangPypers] Django-based CMS recommendations?

2010-11-24 Thread Navin Kabra
On Thu, Nov 25, 2010 at 12:34 AM, Venkatraman S venka...@gmail.com wrote: Let me give you a word of caution : Pinax is a monster and sometimes cane make you go mad. By monster , i dont mean the hugeness, but how sometimes certain customizing aspects of it can cause involuntary hair loss.

Re: [BangPypers] string to list query

2010-08-04 Thread Navin Kabra
On Thu, Aug 5, 2010 at 10:07 AM, Vikram K kpguy1...@gmail.com wrote: Suppose i have this string: z = 'AT/CG' How do i get this list: zlist = ['A','T/C','G'] This is a very poorly specified question. And in absence of any information about what exactly are the constraints on the input, and

Re: [BangPypers] list problem

2010-07-22 Thread Navin Kabra
I suggest that in such cases, avoid the temptation to do something clever. If it was difficult for you to write the code, it will be even more difficult to read and understand it. Unless there is a very good reason, write the simplest, most braindead code. xdictstart={} xdictend={} for item in

Re: [BangPypers] sorting of list

2010-06-24 Thread Navin Kabra
On Fri, Jun 25, 2010 at 1:18 AM, Vikram kp...@rediffmail.com wrote: Suppose i have this: z1 = [[34,44,'1011'],[40,60,'1011'],[50,50,'1013'],[40,20,'1011'],[10,30,'1013']] how do i sort the nested list z1 so as to obtain: bla =

Re: [BangPypers] Regarding Python popularity

2010-02-08 Thread Navin Kabra
On Mon, Feb 8, 2010 at 4:58 PM, Shashwat Anand anand.shash...@gmail.comwrote: Mine one of senior (at Amazon) suggested me Go learn C++/ Java and improve your DS/ Algo/ OS/OOP skills On the other hand, I would like to point out that to really, really improve your DS/Algo skills (two of the

Re: [BangPypers] which one is the best pythonic way .

2010-02-08 Thread Navin Kabra
On Tue, Feb 9, 2010 at 10:22 AM, Srinivas Reddy Thatiparthy srinivas_thatipar...@akebonosoft.com wrote: 1.sum([i for i in range(1000) if i%3==0 or i%5==0]) Slightly better would be: sum((i for i in range(1000) if i%3==0 or i%5==0)) 2.gen=(i for i in range(1000)) sum([i for i in gen if

Re: [BangPypers] Tuples vs Lists, perfromance difference

2009-12-24 Thread Navin Kabra
On Thu, Dec 24, 2009 at 1:05 PM, Senthil Kumaran orsent...@gmail.comwrote: Also interesting stuff about the Java comparison. The question remains, why the JVM is so fast and why Python is not as far as JVM? I am sure there must be a ton of info on this over the net :) Java is

Re: [BangPypers] Tuples vs Lists, perfromance difference

2009-12-23 Thread Navin Kabra
On Wed, Dec 23, 2009 at 9:03 PM, Senthil Kumaran orsent...@gmail.comwrote: On Wed, Dec 23, 2009 at 11:15:56AM +0530, Vishal wrote: After having everything in Python now, performance is something people want to look at. Hence these efforts. Would you like to explain a bit more on this?

Re: [BangPypers] Tuples vs Lists, perfromance difference

2009-12-23 Thread Navin Kabra
On Thu, Dec 24, 2009 at 7:39 AM, Senthil Kumaran orsent...@gmail.comwrote: Here is the link: http://shootout.alioth.debian.org/ There are three Java states given, Java -xint, Java steady state and Java -server. Try choosing each of them and compare against Python and C++. With respect to

Re: [BangPypers] mobile application development

2009-12-16 Thread Navin Kabra
I might add that you can't code in Python on the Android, since it runs only Java apps. I heard there are efforts to bring X language apps into Android, but none is yet mature. You can code in python http://code.google.com/p/android-scripting/wiki/PythonAndroidAPI (but agreed, that it's

Re: [BangPypers] How to search a word list very fast

2009-10-30 Thread Navin Kabra
Amit, Question: why do you want to build this yourself? Depending on what exactly you want to do, it is quite likely that there already exists an algorithm or a free service that does this for you. You should search for that... On Fri, Oct 30, 2009 at 11:37 AM, Amit Sethi

Re: [BangPypers] some doubts regarding python

2009-10-29 Thread Navin Kabra
Something like this should work: def lcm2(a, b): return a*b/fractions.gcd(a,b) def lcm(mylist): return reduce(lcm2, mylist) Actually, this probably should be reduce(lcm2, mylist, 1) navin. ___ BangPypers mailing list BangPypers@python.org

Re: [BangPypers] New to python - neuron ring

2009-10-12 Thread Navin Kabra
On Mon, Oct 12, 2009 at 12:49 PM, Gopinath R gopiindia...@gmail.com wrote: I am a newbie to python. i like to learn python strongly. which version is recommended to start with 2.6 or 3.0. I believe 3.0 has lot more features added, there is no backward compatibility in that. we cannot use some

Re: [BangPypers] New to python - neuron ring

2009-10-12 Thread Navin Kabra
On Mon, Oct 12, 2009 at 1:14 PM, Navin Kabra navin.ka...@gmail.com wrote: On Mon, Oct 12, 2009 at 12:49 PM, Gopinath R gopiindia...@gmail.comwrote: I am a newbie to python. i like to learn python strongly. which version is recommended to start with 2.6 or 3.0. I believe 3.0 has lot more

Re: [BangPypers] Python at Schools

2009-09-30 Thread Navin Kabra
On Thu, Oct 1, 2009 at 2:17 AM, shameek ghosh shamee...@gmail.com wrote: college.So I retracked and instead started with teaching them effective ways of playing battleships using common search methods in algorithms etc Wow, this is a really cool insight, and an interesting way to

Re: [BangPypers] Implementing a fast factorial function in python

2009-09-14 Thread Navin Kabra
print f(1) This is a HUGE number. I don't think you are expected to get the answer by direct calculation. I would guess that you are expected to use mathematical reasoning to figure out the answer (and not computation) ___ BangPypers

Re: [BangPypers] Performance benefits of Generators?

2009-07-03 Thread Navin Kabra
OTOH, Decorators , lambdas ('syntactic sugars') et al reduce the number of lines of code, depending on the scenario, for a given piece of complex logic, but these are 'slow'. But, I dont think the factor is huge enough to cause a performance bottleneck.  I had similar reservations on list

Re: [BangPypers] Performance benefits of Generators?

2009-07-03 Thread Navin Kabra
No not yet. I am not building a application where every mu-sec matters. I appreciate the link and comments though. Will be helpful some day in the future. I guess my point is this: If you've chosen python as a language for your app, you have pretty much accepted that your application is not