Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Zubin Mithra
On Thu, Jul 1, 2010 at 12:09 AM, Stef Mientki stef.mien...@gmail.comwrote:

  hello,

 I've lot of functions that returns their result in some kind of tuple /
 list / array,
 and if there is no result, these functions return None.
 Now I'm often what to do something if I've more than 1 element in the
 result.
 So I test:

if len ( Result )  1 :

 But to prevent exceptions, i've to write ( I often forget)
 if Result and ( len ( Result )  1 ) :


use
if Result:
   do something

Checking the length would be a bad idea.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Python for web applications

2010-06-30 Thread Zubin Mithra
On Wed, Jun 30, 2010 at 11:34 PM, Wyatt Schwartz wyattj...@gmail.comwrote:

 Dear Python-List members,

 Sorry for asking such a simple (or possibly complicated) question, as I am
 new to Python programming. Anyways, I have read online that many popular
 websites use Python for some of their web-based applications (for example,
 Reddit), and that lead me to wonder how is this done?

 Thanks in advance!

 I would recommend that you check out the various web-frameworks which are
out there. Django is the framework I use and love, but there are loads out
there.

Have fun!
Zubin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Composition of functions

2010-06-30 Thread Zubin Mithra
Hello,

 y=list(x).reverse()
  print y
 None


 L = [a, b, c]
 L.reverse()
 L
[c, b, a]

As you can see, L.reverse() performs the operation on itself and returns
nothing. Hence, the return type None.

Instead of

y=''.join(list(x).reverse())

you should probably do,

 t = list(x).reverse()
 y = ''.join(t)

Cheers!
Zubin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Composition of functions

2010-06-30 Thread Zubin Mithra
 Er, I don't think you thought that one entirely through (/ tried it out):


My Apologies.

Here is a working one.

  x=123
 t = list(x)
 t.reverse()
 print ''.join(t)
321


But of course, the method which was suggested earlier is far more elegant.

 print ''.join(reversed(list(x)))

Cheers!
Zubin
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue8312] Add post/pre hooks for distutils commands

2010-04-06 Thread Zubin Mithra

Changes by Zubin Mithra zubin.mit...@gmail.com:


--
nosy: +zubin71

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8312
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8324] add a distutils test command

2010-04-06 Thread Zubin Mithra

Changes by Zubin Mithra zubin.mit...@gmail.com:


--
nosy: +zubin71

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8324
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8274] test_run failing

2010-03-31 Thread Zubin Mithra

New submission from Zubin Mithra zubin.mit...@gmail.com:

==
FAIL: test_run (distutils2.tests.test_build_clib.BuildCLibTestCase)
--
Traceback (most recent call last):
  File 
/media/disk/myWorks/working/distutils2/src/distutils2/tests/test_build_clib.py,
 line 137, in test_run
self.assertTrue('libfoo.a' in os.listdir(build_temp))
AssertionError: False is not True

--
Ran 135 tests in 1.004s

FAILED (failures=1, skipped=4)
Traceback (most recent call last):
  File runtests.py, line 18, in module
test_main()
  File runtests.py, line 12, in test_main
run_unittest(distutils2.tests.test_suite())
  File 
/media/disk/myWorks/working/distutils2/src/distutils2/tests/__init__.py, line 
86, in run_unittest
_run_suite(suite)
  File 
/media/disk/myWorks/working/distutils2/src/distutils2/tests/__init__.py, line 
66, in _run_suite
raise TestFailed(err)
distutils2.tests.TestFailed: Traceback (most recent call last):
  File 
/media/disk/myWorks/working/distutils2/src/distutils2/tests/test_build_clib.py,
 line 137, in test_run
self.assertTrue('libfoo.a' in os.listdir(build_temp))
AssertionError: False is not True

--
assignee: tarek
components: Distutils2
messages: 102011
nosy: tarek, zubin71
severity: normal
status: open
title: test_run failing
type: behavior
versions: Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8274
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8190] Add a PyPI XML-RPC client module

2010-03-29 Thread Zubin Mithra

Changes by Zubin Mithra zubin.mit...@gmail.com:


--
nosy: +zubin71

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8190
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8250] Implement pkgutil APIs as described in PEP 376

2010-03-29 Thread Zubin Mithra

Changes by Zubin Mithra zubin.mit...@gmail.com:


--
nosy: +zubin71

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8250
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8252] add a metadata section in setup.cfg

2010-03-29 Thread Zubin Mithra

Changes by Zubin Mithra zubin.mit...@gmail.com:


--
nosy: +zubin71

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8252
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8253] add a resource+files section in setup.cfg

2010-03-29 Thread Zubin Mithra

Changes by Zubin Mithra zubin.mit...@gmail.com:


--
nosy: +zubin71

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8253
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8254] write a configure command

2010-03-29 Thread Zubin Mithra

Changes by Zubin Mithra zubin.mit...@gmail.com:


--
nosy: +zubin71

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8254
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8255] step-by-step tutorial

2010-03-29 Thread Zubin Mithra

Changes by Zubin Mithra zubin.mit...@gmail.com:


--
nosy: +zubin71

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8255
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7677] distutils, better error message for setup.py upload -sign without identity.

2010-03-24 Thread Zubin Mithra

Zubin Mithra zubin.mit...@gmail.com added the comment:

are you suggesting that a warning stating that 

'--identity has`nt been used'

has to be generated?

--
nosy: +zubin71

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7677
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



D-Bus

2010-03-18 Thread Zubin Mithra
Hello,

I have experience writing scripts to connect to the D-Bus interface provided
by different applications but have no experience writing a D-Bus interface
for an application. Could someone point me in the right direction? A
tutorial or a good example would be nice.

Cheers!!!
Zubin Mithra

http://zubin71.wordpress.com
-- 
http://mail.python.org/mailman/listinfo/python-list


PyAutoRun

2010-02-26 Thread Zubin Mithra
Hello,

I have been using python for quite some time; however this is the
first python project i have worked on.

The code is hosted at http://github.com/zubin71/PyAutoRun

The code needs re-factoring and feature additions; i have put up a
TODO list there too. It`d be great if anyone could work on this; i
intend to develop this further(with a bit of help) and will request
for its addition into debian and ubuntu repositories, in time.

Also, any kind of code-review, criticism, is also appreciated.
However, it`d be awesome if you could just fork it at github, pull,
modify and push. :)

Have a nice day!

cheers!!!
Zubin
-- 
http://mail.python.org/mailman/listinfo/python-list


socket programming

2009-12-30 Thread Zubin Mithra
The code snippet i have pasted at,

http://paste.pocoo.org/show/160555/

produces a traceback which also has been pasted at the above link. The
snippet attempts at socket programming using OOPs concepts. Please help.

Thankx in advance
Zubin Mithra
-- 
http://mail.python.org/mailman/listinfo/python-list


code review

2009-12-23 Thread Zubin Mithra
Hello,

I`m pretty new to developing applications using python and i would
like advance on this script i recently created which helps linux
programmers on the linux terminal. The code is very simple to
understand(i hope) and serves a simple purpose; however i am not sure
if my way of scripting is the right pythonic way of doing it.

The package can be found at www.code.google.com/p/pyautorun

I`d love any feedback, ideas and criticism after a code review. Thank
you in advance.

cheers!!!
Zubin Mithra
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: more efficient?

2009-12-22 Thread Zubin Mithra
thank you for your help and support. i`ll keep your advice in mind. :)

cheers!!!
Zubin



On Tue, Dec 22, 2009 at 8:07 PM, Lie Ryan lie.1...@gmail.com wrote:
 On 12/22/2009 5:13 PM, Zubin Mithra wrote:

 I have the following two implementation techniques in mind.

 def myfunc(mystring):
     check = hello, there  + mystring + !!!
     print check


 OR
 structure = [hello, there,,!!!]
 def myfunc(mystring):
     structure[2] = mystring
     output = ''.join(mystring)

 i heard that string concatenation is very slow in python; so should i
 go for the second approach? could someone tell me why? Would there be
 another 'best-practice-style'?
 Please help. Thankx in advance!

 Python's strings are immutable and to concatenate two string the interpreter
 need to copy two whole string into a new string object. This isn't a
 performance problem until you're trying to concatenate a list containing a
 thousand strings:
 ['abc', 'bcd', 'cde', 'def', ...]
 with the naive approach:
 joined = ''
 for s in lst:
    joined = joined + s

 first python will conc. '' and 'abc', copying 0+3 = 3 chars
 then it conc. 'abc' and 'bcd', copying 3+3 = 6 chars
 then it conc. 'abcbcd' and 'cde' copying 6+3 = 9 chars
 then it conc. 'abcbcdcde' and 'def' copying 9+3 = 12 chars
 and so on...

 for four 3-letter strings, python copies 3 + 6 + 9 + 12 = 30 chars, instead
 of the minimum necessary 12 chars. It gets worse as the number of strings
 increases.

 When you concatenate two 1000-chars large strings, both + and ''.join will
 have to copy 2000 chars. But when you join one thousand 2-chars string
 you'll need to copy 1001000 chars[!] with +.

 Now, early optimization *is evil*. Don't start throwing ''.join every here
 and there. The performance by the concatenations won't start to matter until
 you're concatenating a large lists (40) and + is much more readable than
 ''.join().

 When concatenating small number of strings I preferred
 %-interpolation/str.format; it's often much more readable than ''.join and
 +.
 --
 http://mail.python.org/mailman/listinfo/python-list

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


more efficient?

2009-12-21 Thread Zubin Mithra
I have the following two implementation techniques in mind.

def myfunc(mystring):
check = hello, there  + mystring + !!!
print check


OR
structure = [hello, there,,!!!]
def myfunc(mystring):
structure[2] = mystring
output = ''.join(mystring)

i heard that string concatenation is very slow in python; so should i
go for the second approach? could someone tell me why? Would there be
another 'best-practice-style'?
Please help. Thankx in advance!

cheers!!!
Zubin
-- 
http://mail.python.org/mailman/listinfo/python-list