I just read in a book a little while ago that ** trumps a negative
sign? I am struggling with the audacity of that as -1 is negative 1,
NOT minus 1. How can an arithmetic operation trump an attribute of a
negative integer? It truly makes no sense to me. Thank you for any
enlightenment you can p
Hi Alan,
I rewrote the code as follows:
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
fh = open(fname)
count = 0
for line in fh:
if not line.startswith('From'): continue
line2 = line.strip()
line3 = line2.split()
line4 = lin
Hi Emile,
I hope this answers your question?
Question: How do I remove each duplicate line output?
Here is the raw data code:
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
fh = open(fname)
count = 0
for line in fh:
if not line.startswith('
On 31/07/15 01:25, ltc.hots...@gmail.com wrote:
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
fh = open(fname)
count = 0
for line in fh:
if not line.startswith('From'): continue
line2 = line.strip()
line3 = line2.split()
line4 = line3[1]
On 31/07/15 01:58, D Wyatt wrote:
I just read in a book a little while ago that ** trumps a negative
sign? I am struggling with the audacity of that as -1 is negative 1,
NOT minus 1. How can an arithmetic operation trump an attribute of a
negative integer?
Because Python is a programming lang
On Fri, Jul 31, 2015 at 2:58 AM, D Wyatt wrote:
> I just read in a book a little while ago that ** trumps a negative
> sign? I am struggling with the audacity of that as -1 is negative 1,
> NOT minus 1. How can an arithmetic operation trump an attribute of a
> negative integer? It truly makes
Hello!
On 07/31/2015 01:58 AM, D Wyatt wrote:
I just read in a book a little while ago that ** trumps a negative
sign? I am struggling with the audacity of that as -1 is negative 1,
NOT minus 1.
I'm not sure about what you mean by "trumps", but the square of negative
one is positive one (nega
2015-07-31 2:58 GMT+02:00 D Wyatt :
>
> >>> 3**2
> 9
> >>> (-3)**2
> 9
> >>> -3**2
> -9
> >>>
>
>
Try to get any other result for these operations in a primary school paper,
and then have a look at your marks...
___
Tutor maillist - Tutor@python.org
To
On 31/07/15 10:55, Jose Amoreira wrote:
Given the precedence rules already mentioned by Alan and Todd, the
results of the operations you showed us are exactly as expected. You'll
get the same results if you try with a pocket calculator or using any
other programming language or scientific packag
On 07/31/2015 11:36 AM, Alan Gauld wrote:
On 31/07/15 10:55, Jose Amoreira wrote:
Given the precedence rules already mentioned by Alan and Todd, the
results of the operations you showed us are exactly as expected. You'll
get the same results if you try with a pocket calculator or using any
othe
On Thu, Jul 30, 2015 at 05:58:27PM -0700, D Wyatt wrote:
> I just read in a book a little while ago that ** trumps a negative
> sign?
Correct. Exponentiation has higher priority than subtraction, addition,
multiplication and division:
2+3**2 => 11 not 25
10-3**2 => 1 not 49
2*3**2 => 18 not
Hi Alan,
Here is the revised code below:
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
fh = open(fname)
count = 0
for line in fh:
if not line.startswith('From'): continue
line2 = line.strip()
line3 = line2.split()
line4 = line3[1]
I am trying to setup my python application in a more standard way. In my
research, the general recommendation seems to be that if my application is
called projectgendocs, here is an acceptable structure:
ProjectParent
|-- bin/
| |-- projectgendocs.py
|
|-- projectgendocs
| |-- unittest
| | |--
On 31/07/15 15:39, ltc.hots...@gmail.com wrote:
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
fh = open(fname)
count = 0
for line in fh:
if not line.startswith('From'): continue
line2 = line.strip()
line3 = line2.split()
line4 = line3[1]
Greetings again Hal,
Thank you for posting your small amounts of code and results inline.
Thanks for also including clear questions. Your "surface" still
seems to add extra space, so, if you could trim that, you may get
even more responses from others who are on the Tutor mailing list.
Now
2015-07-31 19:23 GMT+02:00 D Wyatt :
> > Try to get any other result for these operations in a primary school
> paper,
> > and then have a look at your marks...
> >
>
> Condescending and unhelpful response. Why did you bother?
>
>
I tell you another way. These ARE the arithmetically correct resul
On 31 July 2015 at 17:13, Anthony DuPont wrote:
> I am trying to setup my python application in a more standard way. In my
> research, the general recommendation seems to be that if my application is
> called projectgendocs, here is an acceptable structure:
>
> ProjectParent
> |-- bin/
> | |-- pr
On 31/07/15 18:08, D Wyatt wrote:
> It looks odd to us but that's not the point, its how the language works.
> You learn to get used to it. Most languages have some idiosyncrasies like
> this.
Yes, I understand that the creator of the language can make it work
however he wants, but I was really
Hi Deb,
On Fri, Jul 31, 2015 at 10:48:57AM -0700, D Wyatt wrote:
> I have never really thought about any of this before, but many of you
> have responded like this is so obvious. That is not helpful. I'm
> looking at a negative number as being an object that is one less than
> zero, and the una
>
> He is quite within his rights to do that. It's his language after all.
> Some languages solve these problems by not permitting infix notation,
> so in Lisp for example
>
> (3 - 5)
>
> is illegal, you need to do
>
> (- 3 5)
>
> It looks odd to us but that's not the point, its how the language w
>
> Mathematically, this is perfectly acceptable, and what we would
> normally expect. In algebra, if we write:
>
> -x²
>
> we normally mean the negative of (x squared), not (negative x) squared,
> which would be just x². So Python here agrees with standard mathematical
> notation.
>
>
> Speaking
>
> This matches the precedence rules for written mathematics, where negation
> has a lower precedence than exponentiation as well. So python is doing the
> correct thing here mathematically. See, for example,
> http://mathforum.org/library/drmath/view/53194.html
> __
Like Chris mentions, usually you don't write your own stuff in /bin/.
To make what you've written work anyhow, you can run them from inside
/ProjectParent/, not from inside /ProjectParent/bin/.
eg, `python bin/projectgendocs.py`
On Fri, Jul 31, 2015 at 1:16 PM, Chris Warrick wrote:
> On 31 Jul
2015-07-31 20:51 GMT+02:00 Alan Gauld :
>
> (For example Forth was designed to fit
> into the very small amount of memory left over on an astronomical telescope
> control system, so is very, very terse, and uses many "illogical" code
> layouts.
> Everything was sacrificed to save space.)
>
Thank
Hi Martin,
Hal is not have a great day, indeed to day:
Here is the raw data entered:
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
fh = open(fname)
count = 0
addresses = set()
for line in fh:
line2 = line.strip()
line3 = line2.split()
line4 = line3[
On 31/07/15 18:48, D Wyatt wrote:
I have never really thought about any of this before, but many of you
have responded like this is so obvious. That is not helpful.
That's a fair point.
In our defence I guess that many of the active "tutors" on the list are
professional programmers. And pro
On 7/31/2015 11:57 AM, ltc.hots...@gmail.com wrote:
→Question: Why is the list index out of range on line # 9:
IndexError
Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\assinment_8_5_v_20.py in ()
7 line2 = line.strip()
8 line3 = line2.s
On 31/07/15 19:57, ltc.hots...@gmail.com wrote:
for line in fh:
line2 = line.strip()
line3 = line2.split()
line4 = line3[0]
You need to check that there actually is something
in the list to access. If you get a line with only
one word in it, or even a blank line this will fail.
addr
Emile,
--> Captured is a printout from line3 to addresses, below:
In [46]: print line3
[]
In [47]: print line2.split()
[]
In [48]: print line2
In [49]: print line.strip()
In [50]: print fh
In [51]: print addresses
set(['1.0', 'sou...@collab.sakaiproject.org;', 'Jan', 'mail.umich.ed
On 31/07/2015 19:57, ltc.hots...@gmail.com wrote:
I believe that this is the third time that you've been asked to do
something about the amount of whitespace that you're sending to this list.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our langua
30 matches
Mail list logo