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
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
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
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
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
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
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
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
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 &
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
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
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
; 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
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
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"
___
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
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
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
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
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'
>
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
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
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
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
--
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
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
"":
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
___
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
--
.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
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
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
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
**
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
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
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
>
> 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)
-----
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
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
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
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(
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
(mylist[1:])
Asokan Pichai
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
> 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
>
> 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
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
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
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
Asokan Pichai
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
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
; + 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
50 matches
Mail list logo