Re: [Tutor] Help!

2013-01-26 Thread Jos Kerc
You are missing a multiplication sign.

Near the end of your formula.


On Fri, Jan 18, 2013 at 1:56 PM, Carpenter, Steven 
steven.carpen...@oakland.k12.mi.us wrote:

 To Whom it May Concern,

 I’m trying to get this code working. *Here’s my question:*

 Consider a triangle with sides of length 3, 7, and 9. The law of cosines
 states that given three sides of a triangle (a, b, and c) and angle C
 between sides a and b: Write Python code to calculate the three angles in
 the triangle.

 *Here’s my code: *

 # Calculate the angles in a triangle

 # Imports the Math data

 import math

 # Sets up the different angles with corresponding letters

 # The first angle is a

 a = 3

 # The second angle is b

 b = 7

 # The third angle is c

 c = 9

 # Calculates angle C

 print(math.acos(((a**2)+(b**2)-(c**2))/(2(a*b

 *Here’s my output:*

 Traceback (most recent call last):

   File E:\Programming\Problem4.py, line 12, in module

 print(math.acos(((a**2)+(b**2)-(c**2))/(2(a*b

 TypeError: 'int' object is not callable

 ** **

 *Steven Carpenter*

 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Cheese shop tutorial mirror

2013-01-26 Thread Peter Otten
Per Fagrell wrote:

 I'm interested in uploading a module to pypi, but with the python wiki
 down after the hack there's no access to the Cheese shop tutorial. Does
 anyone have a mirror or reasonable facsimile that could be used until the
 wiki is back on-line and repopulated?

You're lucky, the wiki is up again:

http://wiki.python.org/moin/CheeseShopTutorial

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 107, Issue 79

2013-01-26 Thread Farhan Farhan


plz don't send me any msg again.plz i want to unfreind you.___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Read and write list on I file

2013-01-26 Thread jarod...@libero.it
HI there!!!
I have a file like this:

12345-2 ppp
12389-4

i
...

I want to read  this file and organize in different way: The second number
present  after - mean the times are ripetuted the elements..so in the 
example
In the end I want to  have this result

12345-1 ppp
12345-2 ppp
12389-1

i
12389-2

i
12389-3

i
12389-4

i
Someone have a suggestion how to do this simple task.. I write some code but
don't do all the think I want.

import re

f = open(file.txt,r)

for item in f:
 if re.match(r'['0-9]',item):
  line=iteme.strip.split(\t)
  num = line[0].split(-)
  key = num[0]
  vl = in(num[1])
  for i in range(1,vl):
 

   else:
   print all line





thanks in advance for any help!

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help!

2013-01-26 Thread Russel Winder
Following up on Jos Kerc's answer:
 
On Fri, 2013-01-18 at 07:56 -0500, Carpenter, Steven wrote:
[…]
 print(math.acos(((a**2)+(b**2)-(c**2))/(2(a*b

2(a*b) → 2 * (a * b)

 TypeError: 'int' object is not callable

Juxtaposition does not imply multiplication in Python as it does in
mathematics.
-- 
Russel.
=
Dr Russel Winder  t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Roadm: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


signature.asc
Description: This is a digitally signed message part
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Can Python monitor web browser content

2013-01-26 Thread Albert-Jan Roskam
 Original Message -

 From: Alan Gauld alan.ga...@btinternet.com
 To: tutor@python.org
 Cc: 
 Sent: Friday, January 25, 2013 8:54 PM
 Subject: Re: [Tutor] Can Python monitor web browser content
 
 On 25/01/13 17:52, 3n2 Solutions wrote:
 
  I was wondering if Python can monitor web browser content.
 
 Browsers just display html text and Python can read html so
 yes you can do it by getting your program to emulate a browser.
 
 Look at the standard library modules urllibm htmllib and htmlParser.
 Or for more adventurous parsing try the external module BeautifulSoup, it 
 tends 
 to handle badly formed html better and is arguably easier to use than the 
 standard options..

I used the mechanize package before: http://pypi.python.org/pypi/mechanize/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python Help

2013-01-26 Thread wrw
On Jan 23, 2013, at 4:37 PM, Grady Trexler grady...@gmail.com wrote:

 
 Below is my code.  I am using python 2.4 It tells me I have a syntax error.  
 Please help!  (I think the first twenty lines have what you would be looking 
 for.  After that it just repeats itself.)
 #scenario maker
 #created by: Grady Trexler
 #started on 1/3/13
 #last update: 1/3/13
 
 def rungame()
   guyone = raw_input(Please enter a name:)
 

[megabyte]


   print %s: EVERYTHING % (guytwo)
   print %s pushed passed %s and ran away.  The two never saw 
 eachother again. % (guytwo, guyone)
 rungame()
 -- 
 --T-rexmix
 Check out my website-
 www.thegradypage.weebly.com 
 It has new blog posts all the time!
 Fight against Gandalf. Like a Balrog. 
 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor


In the future, please also show us the error and the traceback so we don't have 
to read through your whole code looking for lints.


  File text.py, line 1
def rungame()
 ^
SyntaxError: invalid syntax

You forgot the colon after the closing ) in the def statement.

-Bill
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python Help

2013-01-26 Thread Dave Angel

On 01/23/2013 04:37 PM, Grady Trexler wrote:

Below is my code.  I am using python 2.4 It tells me I have a syntax error.


I don't see any such thing.  Plesae include the traceback, which will 
indicate WHERE you have a syntax error.  And if you look yourself, 
you'll probably spot it, since it's usually either in the line specified 
or the one right before it.


Also, please use text mail.  By using html, you have killed the 
indentation that you presumably had in your original.  If you didn't 
have it in your original, then that's your second syntax error.


All right, I gave up and tried pasting your misformed code into a text 
editor.  Looks like you have a problem on the very first non-comment 
line:no colon on the def line




  Please help!  (I think the first twenty lines have what you would be
looking for.  After that it just repeats itself.)
#scenario maker
#created by: Grady Trexler
#started on 1/3/13
#last update: 1/3/13

def rungame()
guyone = raw_input(Please enter a name:)

guytwo = raw_input(Please enter a name:)


snip

Also please pick a better topic than  Python Help.  Nearly every new 
thread here is asking for help with Python, so how does yours stand out? 
 Even syntax error would be a better one.




--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How does # -*- coding: utf-8 -*- work?

2013-01-26 Thread Santosh Kumar
Everything starting with hash character in Python is comment and is
not interpreted by the interpreter. So how does that works? Give me
full explanation.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How does # -*- coding: utf-8 -*- work?

2013-01-26 Thread Joel Goldstick
On Sat, Jan 26, 2013 at 11:38 AM, Santosh Kumar sntshkm...@gmail.comwrote:

 Everything starting with hash character in Python is comment and is
 not interpreted by the interpreter. So how does that works? Give me
 full explanation.


If you google you get this:


http://stackoverflow.com/questions/4872007/where-does-this-come-from-coding-utf-8



 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor




-- 
Joel Goldstick
http://joelgoldstick.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Read and write list on I file

2013-01-26 Thread Steven D'Aprano

On 26/01/13 20:21, jarod...@libero.it wrote:

(edited slightly to make it more clear)


HI there!!!
I have a file like this:

12345-2 p
12389-4 i

I want to read  this file and organize in different way: The second number
present  after - mean the times are ripetuted the elements..so in the
example In the end I want to  have this result

12345-1 p
12345-2 p
12389-1 i
12389-2i
12389-3i
12389-4i

Someone have a suggestion how to do this simple task..


Untested, but this should work. Adding error checking is left up to you.


f = open('file.txt', 'r')
# each line looks like:
# d-d ccc...
# where d is a digit and c is any non-space character.

for line in f:
head, tail = line.split(' ')
head, num = head.split('-')
num = int(num)
for i in range(1, num+1):
print %s-%s %s % (head, i, tail)

f.close()



--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How does # -*- coding: utf-8 -*- work?

2013-01-26 Thread eryksun
On Sat, Jan 26, 2013 at 11:38 AM, Santosh Kumar sntshkm...@gmail.com wrote:

 Everything starting with hash character in Python is comment and is
 not interpreted by the interpreter. So how does that works? Give me
 full explanation.

The encoding declaration is parsed in the process of compiling the
source. CPython uses the function get_coding_spec in tokenizer.c.

CPython 2.7.3 source link:
http://hg.python.org/cpython/file/70274d53c1dd/Parser/tokenizer.c#l205

You can use the parser module to represent the nodes of a parsed
source tree as a sequence of nested tuples. The first item in each
tuple is the node type number. The associated names for each number
are split across two dictionaries. symbol.sym_name maps non-terminal
node types, and token.tok_name maps terminal nodes (i.e. leaf nodes in
the tree). In CPython 2.7/3.3, node types below 256 are terminal.

Here's an example source tree for two types of encoding declaration:

 src1 = '# -*- coding: utf-8 -*-'
 parser.suite(src1).totuple()
(339, (257, (0, '')), 'utf-8')

 src2 = '# coding=utf-8'
 parser.suite(src2).totuple()
(339, (257, (0, '')), 'utf-8')

As expected, src1 and src2 are equivalent. Now find the names of node
types 339, 257, and 0:

 symbol.sym_name[339]
'encoding_decl'
 symbol.sym_name[257]
'file_input'

 token.ISTERMINAL(0)
True
 token.tok_name[0]
'ENDMARKER'

The base node is type 339 (encoding_decl). The child is type 257
(file_input), which is just the empty body of the source (to keep it
simple, src1 and src2 lack statements). Tacked on at the end is the
string value of the encoding_decl (e.g. 'utf-8').
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor