Re: [Tutor] look back comprehensively

2018-12-23 Thread Asokan Pichai
place some of these. Of course that assumes Unix/Linux OS. In this speciic case grep with its -B option can be used to generate a file that contains only the lines of interest. HTH Asokan Pichai ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] A required question

2018-11-25 Thread Asokan Pichai
On Sat, Nov 24, 2018, 14:33 Avi Gross David, > > As I suspected. Yes, I am aware how to do those things. Just wondered if > anyone automated the process so a fairly simple interface worked. > Does the requirements.txt file (associated with pip IIRC) does most of what you want? > > I am dropping t

Re: [Tutor] Recommended Python Compiler

2017-07-31 Thread Asokan Pichai
For a simple beginners editor -- geany is a great choice. It can be used with minimal or no configuration/set up; and once you know your way around you can tweak it as much as you want. It is easily installable on Debian/Ubuntu -- Asokan Pichai *---* We will find a way. Or

Re: [Tutor] noob python question

2015-10-26 Thread Asokan Pichai
nabble.com/noob-python-question-tp5174789.html > Sent from the Python - tutor mailing list archive at Nabble.com. > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailma

Re: [Tutor] list comprehension with else

2015-01-18 Thread Asokan Pichai
On Sun, Jan 18, 2015 at 6:50 PM, Sydney Shall wrote: > I am a beginner and I have a question of syntax. > Welcome! > > I am just learning to use list comprehension, which oc course, I find very > helpful indeed. > > However, I am stuck with a specific problem of how to incorporate an else > in

Re: [Tutor] most useful ide

2014-02-02 Thread Asokan Pichai
great addition to my toolkit. YMMV Asokan Pichai ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Fwd: What's in a name?

2014-01-03 Thread Asokan Pichai
name of the entity "alist" and its actual symbol aka alist, why not do something like: Lists = {"lista": lista, "listb": lisb} and use Lists[x] ... HTH Asokan Pichai ___ Tutor maillist - Tutor@python.org To un

Re: [Tutor] Converting integers into digit sum (Python 3.3.0)

2013-12-10 Thread Asokan Pichai
On Tue, Dec 10, 2013 at 4:06 PM, Asokan Pichai wrote: > > > > On Tue, Dec 10, 2013 at 3:09 PM, Rafael Knuth wrote: > >> Hej there, >> >> > I don't know if everyone would consider this more elegant but it's >> > certainly sh

Re: [Tutor] Converting integers into digit sum (Python 3.3.0)

2013-12-10 Thread Asokan Pichai
elegant solution IMHO and way better than my > original code (convert int to string, store each digit in an empty > list, then convert them back to int and sum them). > > If you liked it, I will give you one that uses one less variable :-) def digitSum(n): dsum = 0 while n &

Re: [Tutor] Converting integers into digit sum (Python 3.3.0)

2013-12-09 Thread Asokan Pichai
return [int(ch) for ch in str(n)] def digitSum(n): return sum(num2Digits(n)) Asokan Pichai "So, if I look into my foggy crystal ball at the future of computing science education, I overwhelmingly see the depressing picture of "Business as usual". The universities will conti

Re: [Tutor] how to iterate through a dictionary and assign list values?

2013-12-04 Thread Asokan Pichai
ot trying to tell you what to do as that would greatly depend on what you are trying to do. But d = {key:value for key, value in zip(keys, values)} and d = dict(zip(keys, values)) are worth studying. Asokan Pichai "So, if I look into my foggy crystal ball at the future of computing scien

Re: [Tutor] Off Topic re: unichr not working as expected

2013-07-23 Thread Asokan Pichai
you get to contradict your teacher in >> class, >> and you're right - wel it was then. I'm a tad more mature, now - sometimes >> ;') >> > Way offtopic: It is Xenon Hexa Flouride IIRC. LOve that book 107 stories about CHemistry Asokan Pichai "Expectin

Re: [Tutor] Data persistence problem

2013-06-22 Thread Asokan Pichai
; Loads of the design pattern stuff is written to help programmers get > around the straight jacket that languages can impose, whereas > implementating the same patterns in Python is often ludicrously easy. > http://norvig.com/design-patterns/ Read this for an insight into how design patterns chan

Re: [Tutor] producing PDF files

2013-06-11 Thread Asokan Pichai
On Tue, Jun 11, 2013 at 3:23 PM, Khalid Al-Ghamdi wrote: > Hi, > > Do you know of a python module for converting text files to PDF format? > > thanks > Reportlab http://www.reportlab.com/software/opensource/ sphinx http://sphinx-doc.org/ is a great choice too. Asokan Pich

Re: [Tutor] Regarding python function arguments

2013-06-11 Thread Asokan Pichai
mer from you that you are not sharing company confidential information, if you post a solution? Asokan Pichai "Expecting the world to treat you fairly because you are a good person is a little like expecting the bull to not attack you because you are a vegetarian" ___

Re: [Tutor] Issue w/ program: Flip a coin and count heads and tails

2013-05-24 Thread Asokan Pichai
if random.randint(1,2) == 2: - this is the second toss I am talking about tails = tails + 1 Now if you replace the second toss by an "else" and count it as a tail you should go towards the code you are looking for. Try it and tell us how it goes. All the best Asokan Picha

Re: [Tutor] Issue w/ program: Flip a coin and count heads and tails

2013-05-24 Thread Asokan Pichai
s and tails. > > We've got 1 tails here. > > We've got 1 heads here. > > We've got 2 tails here. > > We've got 2 heads here. > > We've got 3 tails here. > > We've got 3 heads here. > > We've got 4 tails here. > > We

Re: [Tutor] Running python from windows command prompt

2013-04-10 Thread Asokan Pichai
t(arg): args = [] for a in arg: args.append(float(a)) return args Now replace the data = line with data = arg2list(argv) # NOT sys.argv HTH Asokan Pichai "Expecting the world to treat you fairly because you are a good person is

Re: [Tutor] Please Help

2013-03-22 Thread Asokan Pichai
Why do I say that? Among other things, k< math.floor(float(len(number_list)/2)) is very poor in any language. Asokan Pichai The root of all superstition is that men observe when a thing hits, but not when it misses. -- Francis Bacon ___ Tutor maillis

Re: [Tutor] How to change the char in string for Python

2013-02-24 Thread Asokan Pichai
On Feb 24, 2013 4:27 PM, "Sudo Nohup" wrote: > > Dear all, > > I want to change the value of a char in a string for Python. However, It seems that "=" does not work. > > Could you help me? Thanks! > > str = "abcd" > result = [char = 'a' for char in str if char == 'c'] > > > OR: > > str = 'abcd' >

Re: [Tutor] Please help

2013-01-01 Thread Asokan Pichai
functions; again it is very likely to be wrong. My advice, look at PEP 8 and also some sample python code in the tutorial to understand how to format code. Remember: Leading whitespace is syntactically significant HTH Asokan Pichai Religion offers hope against all the strife and misery of the

Re: [Tutor] Beginner's question

2012-11-22 Thread Asokan Pichai
How about this? # Assumption x, y, z are all > 0 x, y, z = a = x * (x % 2) b = y * (y % 2) c = z * (z % 2) big = a if big < b: big = b if big < c big = c if big == 0: print "No odd number" else: print big, "is biggest odd number" Asokan Pichai If a

Re: [Tutor] help with homework

2012-10-29 Thread Asokan Pichai
On Mon, Oct 29, 2012 at 2:28 PM, Alan Gauld wrote: > On 29/10/12 08:37, Asokan Pichai wrote: > >>> teachers put stupid artificial constraints on your code, >> >> >>> >>> such as ba

Re: [Tutor] help with homework

2012-10-29 Thread Asokan Pichai
a counter that is incremented under certain conditions. I would hesitate to condemn in such strong terms without knowing more background. Asokan Pichai ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.pyt

Re: [Tutor] For - if - else loop; print selective output

2012-10-25 Thread Asokan Pichai
-- a = [['jimmy', '25', 'pancakes'], ['tom', '23', 'brownies'], ['harry', '21', 'cookies']] matches = [ i[1] in ('25', '26') for i in a ] ] if not any(matches): print "Not found" else: for match in matches: if match: print "Yes" Asokan Pichai -- ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] rounding up to the nearest multiple of 8

2012-10-05 Thread Asokan Pichai
en(s)] + s . -- where s is string to be padded Asokan Pichai If a language is designed for non-programmers, soon only non-programs get written in it.--- Anonymouse ___ Tutor maillist - Tutor@python.org To unsu

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-23 Thread Asokan Pichai
"": return False return "vt" In p or "vn" in p .. selectedLines = [ x for x in TextAsListStripped if select(x) ] .. Asokan Pichai If a language is designed for non-programmers, soon only non-programs get written in it. --- Anonymouse ___

Re: [Tutor] Recursive assignment in nested lists

2012-08-04 Thread Asokan Pichai
Seems very odd requirement. Anyway here is one way: --- def setValue(NestedList, pos, value): nl = NestedList for p in pos[:-1]: nl = nl[p] nl[pos[-1]] = value return NestedList --

Re: [Tutor] group txt files by month

2012-04-02 Thread Asokan Pichai
.max(), f.min(), f.mean() Replace the last two lines with # -- Monthwise[fname[1:7]] = .np.genfromtxt(filename, skip_header=6) # - Now at the end you have a dictionary whose keys are the strings of type '201012' and the values are the f. Yo

Re: [Tutor] New to this list ....

2012-03-30 Thread Asokan Pichai
   return(results) > For the specific values it may be simpler to write: def getflag(thisflag, results): results[2- thisflag] += 1 return results Or you may rearrange the meaning of results and write results[thisflag] += 1 HTH Asokan Pichai ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Reading/dealing/matching with truly huge (ascii) files

2012-02-23 Thread Asokan Pichai
Did you try loadtxt() from numpy? http://mail.scipy.org/pipermail/scipy-user/2010-August/026431.html the poster above notes that 2.5 million lines and 10 columns takes 3 minutes to load. Asokan Pichai ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] How to convert seconds to hh:mm:ss format

2012-02-17 Thread Asokan Pichai
On Fri, Feb 17, 2012 at 3:16 AM, alain Delon wrote: > userName = raw_input("Enter your name ") >      print "hi " + userName + ". \n " >      seconds = input("Enter the number of seconds since midnight:") >      hours = seconds/3600 >      hoursRemain = hours%60 **

Re: [Tutor] Character Buffer Object Error

2012-02-07 Thread Asokan Pichai
se and outstring (empty) Read the instring character by character if the current character is not a digit append it to outstring else append the transform(current char) to outstring If you can organize your code like this it may be easier HTH Regard

Re: [Tutor] ploting of a square well

2012-02-05 Thread Asokan Pichai
On Sun, Feb 5, 2012 at 11:16 PM, Asokan Pichai wrote: > Try changing > plot(x, v) > to > plot(x, v(x)) > > Asokan Pichai But your v(x) is probably in need of changing. I am answering from a machine with a small screen and no python Hence no definite statemen

Re: [Tutor] ploting of a square well

2012-02-05 Thread Asokan Pichai
Try changing plot(x, v) to plot(x, v(x)) Asokan Pichai We are all atheists about most of the gods that societies have ever believed in. Some of us just go one god further. – Richard Dawkins ___ Tutor maillist - Tutor@python.org To unsubscribe or

Re: [Tutor] something relevant to array

2011-12-23 Thread Asokan Pichai
> > into one as: > a b > a b > a b > Is this ok? a = [line.split()[1] for line in open('a.txt') if len(line.strip()) == 26] b = [line.split()[1] for line in open('b.txt') if len(line.strip()) == 26] both = zip(a, b) -----

Re: [Tutor] Need Explanation...

2011-12-10 Thread Asokan Pichai
e [1,2,3,100] > but p is empty... why it is? > > please teach. > append() Method is a mutator; it modifies the list. DOES NOT return the modified list; returns None to be exact HTH Asokan Pichai ___ Tutor maillist - Tutor@python.org

Re: [Tutor] plotting in python

2011-11-30 Thread Asokan Pichai
en(z) You may insert that line above the plot and see Asokan Pichai ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Shortening the code

2011-11-22 Thread Asokan Pichai
I hope you understand > now why I delete the file :) Often if you [name things]/[write code] in terms of WHAT you want to do, rather than HOW you want to do, you will find the going easier For example, a function that is named *bookChair(chairId)*, inside which yo

Re: [Tutor] Python code trouble!

2011-11-22 Thread Asokan Pichai
Okay! I wrote some code. It is below so that you can avoid scrolling down and seeing it if you do not want to see any code! HTH Asokan people = list(" ABCDEFGHIJKLMN") COUNT = len(people) remove = 3 SPACE = ' ' def survivorCount(a): return len(a) - a.count(

Re: [Tutor] IndexError: list index out of range

2011-11-21 Thread Asokan Pichai
On Tue, Nov 22, 2011 at 4:32 AM, Steven D'Aprano wrote: > John wrote: > >> >> Hi all, >> >> I have wriiten the following code: >> [Segment] >> >> def survivor(names, step): > index = step - 1 >>next = names >>while len(next)> 1: >>next.remove (next[index]) >> > > > W

Re: [Tutor] A recursion question

2011-11-18 Thread Asokan Pichai
(mylist[1:]) Asokan Pichai ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Clock in tkinter?

2011-11-15 Thread Asokan Pichai
> On Wed, Nov 16, 2011 at 1:30 AM, Mic wrote: > Hi! > I am new to programming WELCOME! >and I hop this question isn’t stupid. A teacher of mine said, "The only stupid question is the one you thought of asking but did not ask!" Happy l

Re: [Tutor] how to remove the coming duplication

2011-11-10 Thread Asokan Pichai
> > Beware of negative indices: > > >>> remove_coming_duplication([1, 2, 1]) > [2, 1] # should be [1, 2, 1] > > I ran into that and hence I chose to zip, compare and add the last element Asokan Pichai ___ Tutor maillist - Tutor@python.org To unsubs

Re: [Tutor] how to remove the coming duplication

2011-11-10 Thread Asokan Pichai
I was so miffed at not reading the OP's mail carefully that I wrote a one liner. Ok. Here it goes: def no_adjacent_dup(lst): return [ x for x, y in zip(lst, lst[1:]) if x != y] + [lst[-1]] :-) Enjoyed working that one out; but whether it is a good solution .... Asokan P

Re: [Tutor] how to remove the coming duplication

2011-11-09 Thread Asokan Pichai
Bad to reply to my own post. Failed to understand the >> just remove the coming duplication, not unique the list. Sorry; ignore my ideas Asokan Pichai ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options

Re: [Tutor] how to remove the coming duplication

2011-11-09 Thread Asokan Pichai
uplicates as you did. look at sorted(a) Option 3: This is probably the least efficient but has the merit of retaining the original order Count the occurrence of each item and remove 1 less look at a.count() I have chosen to indicate the directions; hope it helps Asokan Pichai Enjoy programming in python ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] regexp

2011-11-06 Thread Asokan Pichai
Asokan Pichai ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tutor Digest, Vol 92, Issue 128

2011-10-31 Thread Asokan Pichai
being returned. That is whenever X is True nothing is returned from alpha(). Even if beta() returns something that is not being used. But when X is False something (q in this simplistic example) is being returned So this is a bug. HTH Asokan Pichai SVP - Learning and Development “Faith consis

Re: [Tutor] Tutor Digest, Vol 92, Issue 127

2011-10-31 Thread Asokan Pichai
; + choice.upper() + > '\' which is an invalid response. Please try again.' >raw_input('Press Enter to try again.') > UserChoice () # If the choice is not valid, run > the function over > You should use return User