[Tutor] Unsubscribe

2016-10-01 Thread spawgi
On Sat, Oct 1, 2016 at 8:12 AM, boB Stepp wrote: > On Sat, Oct 1, 2016 at 2:02 AM, Alan Gauld via Tutor > wrote: > > On 01/10/16 05:24, boB Stepp wrote: > > > >> > === > >> '''Exerise 3.1 from "Think Python 2" by Allen

Re: [Tutor] HELP-Regarding python

2013-01-29 Thread spawgi
missed a parenthesis, it should look like - with open(, ) as : //operation with the file. On Wed, Jan 30, 2013 at 12:31 PM, wrote: > A safer approach would be - > with open(, as : > //operation with the file. > > This way, you do not have to remember to close the file explicitly. > > > On Wed,

Re: [Tutor] HELP-Regarding python

2013-01-29 Thread spawgi
A safer approach would be - with open(, as : //operation with the file. This way, you do not have to remember to close the file explicitly. On Wed, Jan 30, 2013 at 12:27 PM, Dave Angel wrote: > On 01/30/2013 01:51 AM, Gayathri S wrote: > >> Hi All! >> I don't know how to

[Tutor] Query - Where to put in global variables, if needed, as a good programming practice

2012-06-15 Thread spawgi
Hello, The point of good-bad-ness of global variables aside, if I needed to use them, which is a better place to put them. 1. In the __init__ function of a class? So they are available at the time an object is initialized or 2. In the actual function of the class where the variables are needed? Pr

Re: [Tutor] How to exit this loop in the interpreter

2012-05-03 Thread spawgi
Thanks Jerry! By the way, I know I can change the way the loops works and bypass this issue :) I just wanted to mention this behavior which I thought interesting and present some corner case (I have worked extensively in testing). And I agree, probably I should not have used color. Bad on my part.

[Tutor] How to exit this loop in the interpreter

2012-05-03 Thread spawgi
Hello all, I have encountered the following scenario. Here is the code - on IDLE on Windows XP. *>>> while True: try: number = raw_input("enter number - ") print number * number except ValueError: print "invalid number" except: print "unspecified except

Re: [Tutor] why list is not thread-safe, but deque and queue are thread-safe?

2012-05-02 Thread spawgi
http://stackoverflow.com/questions/6319207/are-lists-thread-safe On Wed, May 2, 2012 at 7:58 PM, Lion Chen wrote: > Hi, All, > i can not understand why list is not thread-safe, but deque and queue > are thread-safe? > > that's all. thanks. > > Lion Chen > __

Re: [Tutor] Is there space a between "#!" and "/usr/bin/env python" ?

2012-05-02 Thread spawgi
I have observed that either ways, works fine. On Wed, May 2, 2012 at 2:15 PM, Santosh Kumar wrote: > Now its enough info. Thanks all for clearing my doubt. > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > h

Re: [Tutor] Fwd: help

2012-04-30 Thread spawgi
What does your input look like? Please provide that information. Regards, - SWP On Mon, Apr 30, 2012 at 12:30 PM, viral shah wrote: > > > I want to print below matrix. > > can any one suggest me the method for the same > > 1 2 3 > 4 5 6 > 7 8

Re: [Tutor] Pythonic way of concatenation of elements in an array

2012-01-26 Thread spawgi
Hello Steven, Thanks a lot for the detailed answer. I will implement your suggestions. Really appreciate it. Thanks and Regards, Sumod On Fri, Jan 27, 2012 at 4:34 AM, Steven D'Aprano wrote: > spa...@gmail.com wrote: > >> Hello, >> >> My code is - >> >> l = len(m) >> item = str(m[1]) >> for i i

[Tutor] Pythonic way of concatenation of elements in an array

2012-01-26 Thread spawgi
Hello, My code is - l = len(m) item = str(m[1]) for i in range(2,l): item = item + "-" + str(m[i]) This code is part of a bigger function. It works fine. But I am not happy with the way I have written it. I think there is a better (Pythonic) way to rewrite it. If anyone knows how to improve

Re: [Tutor] how to remove the coming duplication

2011-11-09 Thread spawgi
Hello, list.remove will remove the first occurrence of the value from the list. So the output is expected as far as Python is concerned. May be you should think about using pop function. Please take a look at the code below >>> def RemoveComingDuplicates(a): for i in range(len(a)-1): print i,i+

Re: [Tutor] Python 2.7 on Ubuntu 11.10 - Do not unintall

2011-11-02 Thread spawgi
>Tutor maillist - Tutor@python.org <mailto:Tutor@python.org> >> >>To unsubscribe or change subscription options: >> >> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor> >> >> >> >

Re: [Tutor] Python 2.7 on Ubuntu 11.10 - Do not unintall

2011-11-01 Thread spawgi
Shouldn't this be treated as a bug then? As a user I should be allowed to uninstall the software I want to. Or you uninstalled other things by mistake? On Wed, Nov 2, 2011 at 6:18 AM, Joel Montes de Oca wrote: > On Tue 01 Nov 2011 08:56:41 PM EDT, Max gmail wrote: > >> Heh, yeah. It's usually a

Re: [Tutor] Calendar

2011-09-12 Thread spawgi
If you want to create a calendar for a webpage, I think you can use many ready made JS packages for this. May be jquery also has something. Is using Python mandatory for this task? And why? On Tue, Sep 13, 2011 at 12:45 AM, nitin chandra wrote: > Hi All, > > I need to create a calendar with pyth

Re: [Tutor] Dynamically linking python into my vc project - help required

2011-08-03 Thread spawgi
+1 to Alan on this. Also, you may want to try stackoverflow.com for this question. Thanks and Regards, Sumod On Wed, Aug 3, 2011 at 1:41 PM, Alan Gauld wrote: > On 03/08/11 07:52, mrinal...@edss.co.in wrote: > >> Hi, >> >> I am trying to embed python into my MFC application. I have done this >>

Re: [Tutor] Python scripts into executable Windows programss

2011-08-03 Thread spawgi
For a seamless application development experience, you may want to consider these steps. 1. Use Eclipse-pydev to write your scripts 2. Use py2exe to convert into executable programs 3. Use Inno setup to create installers There is support for 2.6 and 2.7 with Python. Please see the news page - http

Re: [Tutor] time zone conversion

2011-08-01 Thread spawgi
Quick question - Is any daylight saving taken into consideration for this? On Tue, Aug 2, 2011 at 1:35 AM, ian douglas wrote: > Hi all, > > Been trying to wrap my head around some datetime vs time stuff with regards > to parsing a string as a date plus time with a timezone offset. > > This is the

Re: [Tutor] get last 7 days string in a log file

2011-08-01 Thread spawgi
Hi, Let me understand the problem - Do you want to count the number of times the application was restarted between today and 7 days back? => If yes, then you will need to do some string manipulation to get the required dates. Then you will need to apply both the conditions to the line i.e. if the

Re: [Tutor] File parsing

2011-06-16 Thread spawgi
Output on your sample input - $./file_reversing_program.py input.txt "you? are how there, Hi" you thank fine, doing am I. On Fri, Jun 17, 2011 at 1:26 AM, wrote: > Hello Neha, > > I think this script will do what you want and will also fix some of the > issues in your original code - > --

Re: [Tutor] File parsing

2011-06-16 Thread spawgi
Hello Neha, I think this script will do what you want and will also fix some of the issues in your original code - 1 #! /usr/bin/python 2 3 import curses.ascii 4 import string 5 import sys 6 7 with open(sys.argv[1],'r') as inpu

Re: [Tutor] Creating a dictionary

2011-05-27 Thread spawgi
Thanks for the detailed explanation Steve. That was very helpful. On Fri, May 27, 2011 at 8:04 PM, Steven D'Aprano wrote: > Válas Péter wrote: > >> Hi, >> I think I am new to here, as far as I remember. :-) >> >> http://docs.python.org/dev/library/stdtypes.html#dict says: >> we can create a dicti

Re: [Tutor] Creating a dictionary

2011-05-27 Thread spawgi
I think the way - d = dict({'one': 1, 'two': 2}) can be used to created dictionary using list comprehension. e.g. >>> d = dict((i,i**2) for i in range(10)) >>> d {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81} I do not think the second approach can be used in this fashion. >Fr

Re: [Tutor] Creating a dictionary

2011-05-27 Thread spawgi
The first approach does not really give you any variable (in easy form) to operate upon. The second approach returns a dict object that you can later reuse in easier form. So one advantage is certainly that ease of object reuse and also object modification. If you want to add, remove, update anythi

Re: [Tutor] Non programmer wanting to become programmer

2011-05-26 Thread spawgi
Hello amt, Please find my responses below - On Fri, May 27, 2011 at 1:06 AM, amt <0101...@gmail.com> wrote: > First of all, hello! I want to start learning programming. I'm looking > into becoming more than a hobbyist programmer. I searched a lot on Google on > what programming language should

Re: [Tutor] Python and the web

2011-05-22 Thread spawgi
Please see the Django framework and Google App Engine using Python. I particularly recommend the GAE using Python to create a basic data driven application. It will give answers to quite a few of your questions. Regards SWP On Sun, May 22, 2011 at 11:39 PM, michael scott wrote: > I want to start

Re: [Tutor] STRING PROC

2011-05-20 Thread spawgi
You can also try this >>> a = '>> a '>> a.partition('<') ('', '<', 'NAME') >>> splitstring = a.partition('<') >>> splitstring ('', '<', 'NAME') >>> splitstring[0] '' >>> splitstring[1] '<' >>> splitstring[2] 'NAME' I guess you can use this tuple. Hope this helps. Thanks and Regards, Sumod On F

Re: [Tutor] What is `if __name__ == "__main__"` for?

2011-05-20 Thread spawgi
If the module is run as a program, then the __name__ is assigned the value __main__ . If the module is imported, then the value is not assigned. Please see here - http://stackoverflow.com/questions/419163/what-does-if-name-main-do

Re: [Tutor] xrange() with start or stop > sys.maxint?

2011-05-18 Thread spawgi
What is the version of python you are using? >From the documentation of python 2.71. http://docs.python.org/library/functions.html#xrange CPython implementation detail: xrange() is intended to be simple and fast. Implementations may impose restrictions to achieve this. The C implementation of Pyt

Re: [Tutor] Sequencing

2011-05-18 Thread spawgi
I don't think we can solve your homework :). But regarding hint, try to think in terms of each number as part of list and then process the list. Also, consider the option if the numbers will be given as a string or as integers or float etc. Thanks. On Wed, May 18, 2011 at 2:49 PM, Cindy Lee wrot

Re: [Tutor] Indexing a List of Strings

2011-05-18 Thread spawgi
Agreed that your original sequences are 1000 char long. But it helps to understand the problem better if you can give examples with smaller strings. Please can you post smaller examples? This will also help you test your code on your own inputs. On Wed, May 18, 2011 at 5:40 AM, Spyros Charonis wro

Re: [Tutor] String Processing Query

2011-05-17 Thread spawgi
This snipped also works - may be there is a better solution - ', '*'] >>> s = '' >>> for line in lines: line = line.rstrip('\n') if line.startswith('>from header'): continue elif line.startswith('*'): s = s + '\n' else: s = s + line >>> s 'abcdefghijklmnopqrstuvwxyz\npoiuytrewqlkjhgfdsamnbvcxz\