Re: [Tutor] puzzled by Python 3's print()

2010-07-01 Thread Shantanoo
without using decimal module: >>> x = 2034 >>> print('%d'%(x/2)) 1017 On Thu, Jul 1, 2010 at 13:56, Richard D. Moores wrote: x = 2034 x/2 > 1017.0 print(x/2) > 1e+15 > > I was expecting, in fact needing, 117 or 1

Re: [Tutor] Prime Numbers

2010-10-07 Thread Shantanoo
ki/Prime_number http://en.wikipedia.org/wiki/Primality_test once you decide which algorithm you want to implement, you should be able to get the python code in less than week's time :). HTH. regards, shantanoo ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Rounding a Python float to the nearest half integer

2010-10-11 Thread Shantanoo
=== round(...) round(number[, ndigits]) -> floating point number Round a number to a given precision in decimal digits (default 0 digits). This always returns a floating point number. Precision may be negative. === >>> round(1.23423,2) 1.23 >>> round(1.23623,2) 1.24 HTH. On Mon, O

[Tutor] Re: Opening and reading .cvs files in Python

2004-12-17 Thread Shantanoo Mahajan
+++ Johan Geldenhuys [14-12-04 15:18 +0200]: | Hi, | I want to find out how to open a .cvs file on a remote Windows machine | and get file to my local linux folder. .cvs file?? | | Any help would be appreciated. | -- |Johan | | -- | This E-Mail has been scanned. | Enjoy Your Day. |

Re: [Tutor] How o convert spaces into tabs??

2009-06-02 Thread शंतनू (Shantanoo)
jyotsna guleria wrote: Hello every one, I am trying to parse a file: I want to convert all the spaces in between the characters to single tab. e.g: my file has contents like: 1G579011 10 2 0 0 0 0 0 00 5Ht-2

Re: [Tutor] single file .exe

2005-07-21 Thread Shantanoo Mahajan
? | | Cheers | jorge py2exe? Shantanoo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] substituting empty line with stuff

2005-08-03 Thread Shantanoo Mahajan
ini | Maybe... for x in open('_file_'): a=x.split() if len(a) == 1: b = a[0] else: print b, print x, Regards, Shantanoo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] validation

2007-08-27 Thread Shantanoo Mahajan
someone point me in the right direction? > > Thanks > > Michael http://docs.python.org/tut/node10.html Check section 8.3. 'Exception Handling'. You may use the example without any modifications. regards, shantanoo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] IRC bot

2007-09-20 Thread शंतनु (Shantanoo)
send("PONG %s\r\n" % line[1]) > <<<--->>> > > Thanks in advance Instead of writing your own code for the bot, I would suggest using supybot (http://supybot.com/). regards, shantanoo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] comparing dates

2007-11-23 Thread Shantanoo Mahajan
andtimes.html' may be useful. regards, shantanoo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python Editor For Mac Os X

2007-12-13 Thread शंतनु (Shantanoo)
On Dec 14, 2007 10:02 AM, chinni <[EMAIL PROTECTED]> wrote: > Hi which editor for python on Mac os x platform is best with color syntax > compiler etc... You can try emacs, vim, textmate, eclipse(?) regards, shantanoo ___ Tutor mailli

Re: [Tutor] RSH?

2005-11-03 Thread Shantanoo Mahajan
#x27; % ( password, user, hostIP, '/absolute/path/of/python /absolute/path/of/python/script' ) ) Also dirty method: (i,o,e) = os.popen3('telnet hostIP) Where, i = input o = output e = error i.write('...') for sending input. o.readline() and e.r

Re: [Tutor] lists and strings

2005-11-08 Thread Shantanoo Mahajan
="this is string" b=1234567890 c={} c['a'] = a c['b'] = b and then dump c. Regards, Shantanoo pgp5hG8KxTdBW.pgp Description: PGP signature ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] for loops over multiple lists of the same length

2006-06-22 Thread Shantanoo Mahajan
y',6,'blue'],['jhon',34,'orange'],['jeremy',1,'green'],['junita',19,'yellow']] people = [Person(name,age,color) for name,age,color in data] Regards, Shantanoo -- Eliminate guilt. Don't fiddle expenses, taxes or benefits, and don't cheat colleagues. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] printing 00

2006-07-11 Thread Shantanoo Mahajan
owing: | >>> time = Time(12,34.4,00) | >>> printTime(time) | 12:34:0 | >>> time.seconds | 0 instead of %d you may use %02d. Shantanoo -- It's not what you look at that matters, it's what you see. ~Henry David Thoreau ___ Tut

Re: [Tutor] getting 'pwd' for XP ?

2006-09-28 Thread Shantanoo Mahajan
+++ Dave S [28-09-06 16:10 +0100]: | I currently running XP (like a fish out of water :) and I need to know the dir | that the python script is executed from. a linux 'pwd' How can I achieve | this - I have looked in sys & os & os.path but found nothing suitable Python 2.4.

Re: [Tutor] getting 'pwd' for XP ?

2006-09-28 Thread Shantanoo Mahajan
+++ Shantanoo Mahajan [28-09-06 21:12 +0530]: | +++ Dave S [28-09-06 16:10 +0100]: | | I currently running XP (like a fish out of water :) and I need to know the dir | | that the python script is executed from. a linux 'pwd' How can I achieve | | this - I have looked in sys & os

Re: [Tutor] Better way to substitute text?

2006-09-30 Thread Shantanoo Mahajan
| out_put.close() replace_words = ['TWY', 'RWY', 'WIP'] for line in in_put: for replace_word in replace_words: out_put.write(line.replace(replace_word,""+replace_word+"")) You can furthur reduce for loops. Shantanoo -- Always have an answe

Re: [Tutor] Puzzled by print lst.sort()

2006-09-30 Thread Shantanoo Mahajan
>I believe sorting in place has performance advantages too. | > | >It's covered in the official FAQ: | > | >http://www.python.org/doc/faq/general/#why-doesn-t-list-sort-return-the-sorted-list | | Thanks for the further enlightenment, Liam. Maybe following is helpful: >>

Re: [Tutor] Sort Output

2008-09-17 Thread Shantanoo Mahajan
deepcopy(a) >>> a [2, 1, 3, 4] >>> b [2, 1, 3, 4] >>> a.sort() >>> a [1, 2, 3, 4] >>> b [2, 1, 3, 4] >>> HTH. regards, shantanoo On 18-Sep-08, at 1:00 AM, Wayne Watson wrote: I'm using Python 2.4 in Win XP. I was surprised to find

Re: [Tutor] sqlite3 lists to database conversion/ using python variables in sqlite3

2008-11-19 Thread शंतनू (Shantanoo)
gt; list1=['hello','hi'] >>>> list2=['a','b'] >>>>c.execute('''create table ABC(hello text,hi text)''') >>>> list1_value= ",".join(list1) >>>> list2_value= ",".j

Re: [Tutor] Extracting information from an EXCEL/Matlab file to use in Python

2009-02-11 Thread Shantanoo Mahajan (शंत नू महा जन)
://sourceforge.net/projects/pyxlwriter/ regards, shantanoo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-25 Thread Shantanoo Mahajan (शंत नू महा जन)
e has ONLY lines that end in either "yes" or "no". Any suggestions are appreciated. Also, I feel that my code is not the best way of solving the problem even if the problem of list indices is solved. Is my guess right? Another suggestion. I would not read all data f

Re: [Tutor] Printing Problem python 3

2009-04-29 Thread Shantanoo Mahajan (शंत नू महा जन)
d perfectly for me. === $ python3.0 Python 3.0 (r30:67503, Jan 14 2009, 09:13:26) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>&

Re: [Tutor] array and dictionary

2008-09-20 Thread Shantanoo Mahajan (शंत नू महा जन)
Straight forward method would be... >>> a=[[1],[2]] >>> b={} >>> for x in range(len(a)): ... b[x] = a[x] ... >>> a [[1], [2]] >>> b {0: [1], 1: [2]} >>> regards, shantanoo On 21-Sep-08, at 11:36 AM, Dinesh B Vadhia wrote: Hi! Say, I