Re: [Tutor] Tutor Digest, Vol 106, Issue 31

2012-12-14 Thread
Hi Python tutor
I have a question I believe I have posted before: when you have filled the page 
with text (commands,list etc) how do you clear the page to allow a clean page 
to continue on writing script?
Thanks appreciate your help.
Mike

-Original Message-
From: Tutor [mailto:tutor-bounces+mwaters=its.jnj@python.org] On Behalf Of 
tutor-requ...@python.org
Sent: Friday, December 14, 2012 6:00 AM
To: tutor@python.org
Subject: Tutor Digest, Vol 106, Issue 31

Send Tutor mailing list submissions to
tutor@python.org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
tutor-requ...@python.org

You can reach the person managing the list at
tutor-ow...@python.org

When replying, please edit your Subject line so it is more specific than "Re: 
Contents of Tutor digest..."


Today's Topics:

   1. Using json to filter out results from a dictionary (Jasmine Gao)
   2. Re: Using json to filter out results from a dictionary
  (Steven D'Aprano)


--

Message: 1
Date: Thu, 13 Dec 2012 17:39:01 -0500
From: Jasmine Gao 
To: tutor@python.org
Subject: [Tutor] Using json to filter out results from a dictionary
Message-ID:

Content-Type: text/plain; charset="iso-8859-1"

Hello,

I've just started programming in python and haven't had much experience with 
json. I've written this simple script that makes a request to the Bitly API, 
specifically the 
/v3/realtime/bursting_phrasesendpoint,
and prints the response into terminal. What I want to do is take the response 
and filter out a portion of it so I only see the data I find important. So far 
I've used json to load the results into a dictionary, however I'm stuck in 
terms of how you loop through the dictionary and only print out certain keys 
while dumping the rest.

To illustrate, this is the script:

import urllib2


CLIENT_ID = "0367d81a428968a57704a295a4378521af81c91b"

CLIENT_SECRET = "404862446e88f391e8c411ca1ee912506d64fffd"

ACCESS_TOKEN = "53a01f38b09c0463cb9e2b35b151beb127843bf3"

BITLY_ENDPOINT = "
https://api-ssl.bitly.com/v3/realtime/bursting_phrases?access_token=
"+ACCESS_TOKEN


def getServiceResponse():

url = BITLY_ENDPOINT

request = urllib2.Request(url)

response = urllib2.urlopen(request)

d = json.loads(response.read())



getServiceResponse()


In terminal I run this command: python /file/location/file.py | tr "," "\n"
which returns a long list of results like this:


"data": {"selectivity": 3.0

"phrase": "justin bieber"

  "mean": 0.089997}

  {"std": 0.046334721206249076

  "ghashes": [

 {"visitors": 440

 "ghash": "QXfZfQ"}

 {"visitors": 215

 "ghash": "W9sHrc"}

 {"visitors": 92

 "ghash": "XY9PPX"}]

  "N": 203183.0

  "rate": 0.53003

"urls": [

 {"visitors": 440

 "aggregate_url": "http://bit.ly/QXfZfQ"}

 {"visitors": 215

 "aggregate_url": "http://bit.ly/W9sHrc"}

 {"visitors": 92

 "aggregate_url": "http://bit.ly/XY9PPX"}]


How do I use json to filter out the "ghashes" from what is printed into 
terminal so that the results look like this instead?:

"data": {"selectivity": 3.0

"phrase": "justin bieber"

  "mean": 0.089997}

  {"std": 0.046334721206249076

  "N": 203183.0

  "rate": 0.53003

 "urls": [

  {"visitors": 440

 "aggregate_url": "http://bit.ly/QXfZfQ"}

  {"visitors": 215

  "aggregate_url": "http://bit.ly/W9sHrc"}

  {"visitors": 92

 "aggregate_url": "http://bit.ly/XY9PPX"}]


Any help would greatly be appreciated, thank you!

- Jasmine
-- next part --
An HTML attachment was scrubbed...
URL: 


--

Message: 2
Date: Fri, 14 Dec 2012 10:21:38 +1100
From: Steven D'Aprano 
To: tutor@python.org
Subject: Re: [Tutor] Using json to filter out results from a
dictionary
Message-ID: <50ca6302.2070...@pearwood.info>
Content-Type: text/plain; charset=UTF-8; format=flowed

On 14/12/12 09:39, Jasmine Gao wrote:
> Hello,
>
> I've just started programming in python and haven't had much 
> experience with json.


This is not really a JSON problem. JSON just handles converting data in a dict 
to a string and back. As you say:

> I'm stuck in terms of how you loop through the dictionary and only 
> print out certain keys while dumping the rest.

That part is simple:

for key, item in mydict.items():
 if key != "rubbish":
 print key, item
 # In python 3, use "print(key, item)" instead


Another way:

if "rubbish" in mydict:
 del mydict
print mydict
# In python 3, use "print(mydict)" instead



> To illustrate, this is the script:
>
> import urllib2
> CLIENT_ID = "0367d81a428968a57704a295a4378521af81c91b

Re: [Tutor] Tutor Digest, Vol 106, Issue 31

2012-12-14 Thread Oscar Benjamin
If you reply to the digest email you should to do two things:
1) Change the subject line to match the email you are replying to (or
in this case choose a new subject).
2) Delete any part of the message that you are not responding to (in
this case all of it).

In fact why are you replying to the digest email when you are not
replying to any of the messages in it? If you want to send an email to
the tutor list you can just do "new mail" or equivalent in your mail
client and then type "tutor@python.org". In my mail client I only have
to "t" and "u" for "tutor" and then the software will auto-complete
the remainder of the address.
Replying to the digest instead seems pretty lazy to me.

On 14 December 2012 13:39, Waters, Mike [ITSCA Non-J&J]
 wrote:
> Hi Python tutor
> I have a question I believe I have posted before: when you have filled the 
> page with text (commands,list etc) how do you clear the page to allow a clean 
> page to continue on writing script?

What page are you talking about? Where are your commands being typed?
Are using a terminal or IDLE, or something else?

Perhaps you could try typing the command "clear".


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


[Tutor] Fwd: Re: Tutor Digest, Vol 106, Issue 31

2012-12-14 Thread Brian van den Broek
Forwarding to the list what I sent privately. Stupid android UI.

-- Forwarded message --
From: "Brian van den Broek" 
Date: 14 Dec 2012 10:01
Subject: Re: [Tutor] Tutor Digest, Vol 106, Issue 31
To: "Waters, Mike [ITSCA Non-J&J]" 

On 14 Dec 2012 08:43, "Waters, Mike [ITSCA Non-J&J]" 
wrote:
>
> Hi Python tutor
> I have a question I believe I have posted before: when you have filled
the page with text (commands,list etc) how do you clear the page to allow a
clean page to continue on writing script?
> Thanks appreciate your help.
> Mike

Mike,

Please start a new thread for a new question rather than replying to the
digest as you have done. This avoids a tonne of text irrelevant to your
question (which I have removed) and affords you the easy to avail yourself
of oportunity to give your inquiry a meaningful subject line.

What do you mean by 'page'? What software are you working with? What OS?
You've not given enough information.

If you are thinking of an interactive prompt (though you don't seem to be)
you can clear it with

print "\n" * 80 # or some appropriate value

If that doesn't help, please ask again with enough information about your
context to allow those willing to help you to do so.

Best,

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


[Tutor] New Re: Clearing Python text

2012-12-14 Thread
Hi Tutor,
I am using Win 7 ,Python 2.7. Interpreter.
To state my challenge : When I have filled a page with values and text until it 
reaches the bottom of the screen, how can I highlight this and remove to allow 
further entries? I have seen John Guttag do this but he seems to be using a MAC.
Thanks
Mike




Michael Waters
Business Unit Information Technology
Global Data Center
Data Center Services  Team
GDC 24/7 HotLine # 800-267-3471
McNeil Consumer Heathcare
A division of Johnson & Johnson
[cid:image001.png@01CDD9E5.66F96150]

Desk # 519-826-6226 ex 5860
Home# 519-767-2629 Cell 226-500-1776
Office Hours M-F 8:00am 4:00pm
My hours 8:00AM-12:00PM
ITS Guelph
890 Woodlawn Road West,Guelph,On. N1K 1A5
mwat...@its.jnj.com

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


Re: [Tutor] New Re: Clearing Python text

2012-12-14 Thread Oscar Benjamin
Further to previous comments, It is also preferred to send emails to
this list in plain text rather than html. This is because it protects
the formatting of Python code and works better with all possible
mail-clients/news-readers/archives etc.

On 14 December 2012 15:25, Waters, Mike [ITSCA Non-J&J]
 wrote:
>
> Hi Tutor,
>
> I am using Win 7 ,Python 2.7. Interpreter.
>
> To state my challenge : When I have filled a page with values and text until 
> it reaches the bottom of the screen, how can I highlight this and remove to 
> allow further entries? I have seen John Guttag do this but he seems to be 
> using a MAC.

It's still not clear what you are referring to. What piece of software
is responsible for the "page" you are referring to? The Python
interpreter itself does not have a "page".

If you run Python in a terminal, then the terminal shows a page of
commands and output. If you run Python commands in IDLE then you will
be typing your commands and viewing their output in the IDLE page. If
you edit a .py file then your editor will show you a page (although
the file itself is not really divided into pages).

Can you please clarify very specifically what this "page" is and/or
what you are doing that leads to the page being there?


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


Re: [Tutor] New Re: Clearing Python text

2012-12-14 Thread Monte Milanuk

On 12/14/2012 07:25 AM, Waters, Mike [ITSCA Non-J&J] wrote:

Hi Tutor,

I am using Win 7 ,Python 2.7. Interpreter.

To state my challenge : When I have filled a page with values and text
until it reaches the bottom of the screen, how can I highlight this and
remove to allow further entries? I have seen John Guttag do this but he
seems to be using a MAC.



I'm assuming you're using the interpreter in IDLE?

Try 'Control + L', if memory serves.



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


Re: [Tutor] New Re: Clearing Python text

2012-12-14 Thread Dave Angel
On 12/14/2012 10:25 AM, Waters, Mike [ITSCA Non-J&J] wrote:
> Hi Tutor,
> I am using Win 7 ,Python 2.7. Interpreter.
> To state my challenge : When I have filled a page with values and text until 
> it reaches the bottom of the screen, how can I highlight this and remove to 
> allow further entries? I have seen John Guttag do this but he seems to be 
> using a MAC.
> Thanks
> Mike
>

Are you talking about the DOS box (CMD window, terminal, or any other
alias)?  If so, it could be any size, from a few lines up to maybe 50
(or more, depends on the screen resolution of your particular tube). 
And what do you mean by full?   When your program is generating output
with print statements, once it reaches the bottom of the DOS box, it'll
scroll.  Python has no control over that.

If your version of CMD supports ANSI sequences, you could print ESC 2 J
from your program when you want the screen cleared.  But easier is just
to print a boatload of newlines, and figure that'll scroll the old stuff
off.


-- 

DaveA

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


[Tutor] Help please!

2012-12-14 Thread Jack Little
Hi Tutor,
I'm getting this error

Traceback (most recent call last): File "C:\Users\Jack\Desktop\python\g.py", 
line 45, in  path_1pt1()
NameError: name 'path_1pt1' is not defined

With the attached file

Please get back to me
Thank you

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


[Tutor] First semester no coding experince, please help!

2012-12-14 Thread Mark Rourke
Hello, the following attachment  (no virus I swear!)is an assignment I 
have for my programming class, I am having alot of difficulty completing 
this assignment, my teacher does not do a very good job of explaining 
this project to me, I desperately need some help/guidance/direction with 
this, please help!


Thanks
--

Mark Rourke

T: 705-728-6169
M: 705-331-0175
E: mark.rour...@gmail.com



Assignment3-1.docx
Description: Binary data
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] College student having python problems

2012-12-14 Thread Mark Rourke

The Following is my code:

#Mark Rourke, Mitch Lavalle
#Dec 04, 2012
#Global Constants
#Constant Integer MAX_QTY
MAX_QTY = 20
#Constant Real TAX_RATE
TAX_RATE = .13
#Constant Real Burger
Burger = .99
#Constant Real Fries
Fries = .79
#Constant Real Soda
Soda = 1.09
import sys
def getOrderNumber():
#Get the order number from user
#orderNumber >=0
goodOrder = True
while goodOrder == True:
try:
orderNumber = int(input("Please enter order number, Enter 0 to 
Stop"))
except ValueError:
print("Non numeric input entered. Program terminating...")
except:
print("Input Error")
else:
if (orderNumber > 0):
print ("Your order Number is %d" %(orderNumber))
return orderNumber
elif (orderNumber < 0 or orderNumber != 0):
goodOrder = True
print ("Please enter a proper value")
   




def showMenu():

#THIS IS ALL PART OF SHOWMENU:
#keep getting items for this order until the user wants to end the order
 #set initial quantities of items
numBurgers=20;
numFries=20;
numSodas=20;
menuItem = showMenu()<-ERROR THERE<
#ordering stuff from the menu
menuItem=-1

while (menuItem!= 0):
#show user menu
 print("--- 
M E N U ")

print ("Your order Number is %d")

print("Cost of Burger: %.2f" %Burger)

print("Cost of Fries: %.2f" %Fries)

print("Cost of Soda: %.2f" %Soda)

print("Enter 1 for Yum Yum Burger")

print("Enter 2 for Grease Yum Fries")

print("Enter 3 for Soda Yum")

print("Enter 0 to end order")

#get menu selection from them

itemType = int(input("Enter now->"))
#inside the function, we get input
#validate the input (1, 2, 3, 4)
#return that value
#menuItem 1 Yum Yum Burger
#menuItem 2 Greasy Yum Fries
#get how many of the item we want
#i.e. if menuItem is 1 (Yum Yum Burger) and 
howManyOfItem is 2, then the person wants 2 Yum Yum Burgers
#need to tell person how many they can order and prompt 
for number
#need to check if quantity ordered is allowed

if menuItem == 1:

#burger
print("You can order 0 through"+numBurgers+"burgers.")
numBurgAsked=input("how many would you like?")
#prompting taken care of in getitem
#passes back number that they want
if(numBurgAsked<=numBurgers):
numBurgers = numBurgers - numBurgAsked
elif menuItem == 2:
print("You can order 0 through"+numFries+"fries.")
numFriesAsked=input("how many would you like?")
if(numFriesAsked<=numFries):
numBurgers = numBurgers - numBurgAsked
elif menuItem == 3:
print("You can order 0 through"+numSodas+"sodas.")
numSodasAsked=input("how many would you like?")
if(numSodasAsked<=numFries):
numSodas = numSodas - numSodasAsked
   
#THIS IS PART OF CALCULATEFINALCOST:

#Calculate the cost of each item
costOfBurgers = calculateCost (1, burgersOrdered)
costOfFries = calculateCost (2, friesOrdered)
costOfSodas = calculateCost (3, sodasOrdered)
totalCost = CalculateTotalCost(1,2,3 + totalTax)
tax = calculateTax(totalCost * TAX_RATE)
finalCost = calculateFinalPrice(TotalCost + tax)

def main():

getOrderNumber()
showMenu()
main()

Okay this is what I've got so far on like 47 i have stated menuItem = 
showMenu()<-ERROR THERE<,
thats where I'm getting the error. tI goes into an infinate loop stating 
"File "C:\Users\Mark\Desktop\Assignment3_MarkRourke.py", line 45, in 
showMenu

menuItem = showMenu()"
can you give me some sort of way to get out of this? and if so, can you 
please show me where in the code and how?, I've been working on this for 
over 20 hours my teacher isn't helpful, can you please assist me





Mark Rourke


T: 705-728-6169
M: 705-331-0175
E: mark.rour...@gmail.com

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


[Tutor] Which version of activetcl to use for Mac OS X 10.7?

2012-12-14 Thread Yi Molina
Hi, all. I am new to python and just installed Python 2.7.3 on my Mac OS X 
10.7.5 from python.org. I read that I am supposed to use  ActiveTcl 8.5.11.1. 
So I clicked on the link on but found only 
ActiveTcl8.5.11.1.295590-macosx10.5-i386-x86_64-threaded.dmg, Which is for MAC 
OS X 10.5. I could not 
find anything for OS X 10.7, so I installed it.  I tried a few simple programs 
in IDLE and they work fine. But I'd like to confirm if this is the right 
activetcl version to use?

Thanks!
Yi

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


[Tutor] Learning Python through automating web application testing.

2012-12-14 Thread marcusw4...@hotmail.co.uk
Hello all,

I'm new to posting on mailing lists so hopefully I've picked the correct
one for my question(s).

A little about my programming experience first.

I work as a 'black box' software tester on a website/application so am
familiar with the IT development process but when it comes to
programming I'm very much a keenly interested newbie. To give you some idea
of my current ability it would be (with a bit of revision) around chapter 8
of Wesley Chun's "Core Python programming".

I do not in any way mean this as a criticism of "Core Python" but to learn,
what I really need is a project. Although "Core Python" rigorously tackles
it's subject; I've found I need a more tangible reason than "It would be
great if I could program" to stay focused on working my way through the
book. It took more than one attempt to get to chapter 8 and as I was
stubbornly refusing to ask for help (madness I know) it became quite
disheartening when I found some questions tough going. It will be an
invaluable point of reference in the future, it's simply I don't currently
need to understand it's subject with the depth it offers.  All I need at
the moment is "enough to get started" which by my rough calculation is
around 4.35% (not including appendices) of what "Core Python" has to offer!

So what I need is a small(ish) project that introduces thoroughly a useful
part of the Python language while teaching me how to program.  But for what
will sound like a silly reason I've always managed to avoid undertaking
this task. Basically a fear of failure has stopped me from starting. I mean
I've always talked a good game but what if I'm not sharp enough to learn to
competently program?  Not attempting is better than failing surely?

Because of this fear I've never admitted I've got a ready made project just
waiting for me to tackle...

Until now!

I would like to learn to automate the testing of a http(s) web
site/applications but feel slightly overwhelmed by this task so would like
to ask for some initial guidance.

These are some of questions that I have.

How do I go about this?

Where do I start?

There's just so much out there to help with learning Python I'm
experiencing information overload!

How do I stop myself from trying to run before I can walk?

In a perfect world a step by step guide, in automating web tests, using
Python is what I'm after but failing that(!) which sites/forums/mailing
lists are of particular interest to someone who would like to learn Python
programming initially through automating web tests?  (By web tests, to
begin with, I mean automated regression testing of a site by multiple users)

At work we use Selenium and Java so I'm aware that Selenium comes with a
Python driver.  Would that be a good place to start?

Apologies if I'm not supposed to ask more than one question per mail but
these are all closely related and could be thought of as "newbie struggling
to see the wood/forest for the trees!"

Many thanks for your help

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


[Tutor] Information

2012-12-14 Thread Umair Masood

How to create a server in python using SOAP? Please also tell the ports to be 
used. Kindly help me out.
Regards,Umair ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New Re: Clearing Python text

2012-12-14 Thread Alan Gauld

On 14/12/12 15:25, Waters, Mike [ITSCA Non-J&J] wrote:


To state my challenge : When I have filled a page with values and text
until it reaches the bottom of the screen, how can I highlight this and
remove to allow further entries? I have seen John Guttag do this but he
seems to be using a MAC.


Like others I don't really understand what you mean by a page.
But in general you don't need to do that. If you are using the Python prompt
>>>

You just keep adding stuff and it will scroll up.
If you just want some clear space hit return a few times.
Or as already suggested:

print '\n' * 50   # prints 50 newlines...

But it all depends on what tool you are using to enter your Python
code. You may have something odd that has a fixed screen but if so
I've never come across it!

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

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


Re: [Tutor] College student having python problems

2012-12-14 Thread Alan Gauld

On 06/12/12 23:43, Mark Rourke wrote:


def showMenu():
#THIS IS ALL PART OF SHOWMENU:
 #keep getting items for this order until the user wants to end the 
order
  #set initial quantities of items
 numBurgers=20;
 numFries=20;
 numSodas=20;
 menuItem = showMenu()<-ERROR THERE<
 #ordering stuff from the menu



def main():
 getOrderNumber()
 showMenu()
main()


main calls showMenu which calls showMenu which calls showMenu etc

You need to break the cycle of showMenu calls. Thats usually done by 
inserting some kind of check before the call to showMenu inside showMenu 
 so that you only call it when needed.


However I suspect what you really need here is to use a loop instead of 
having showMenu calling itself.


choice = None
while not choice # or some other test condition here
   choice = showMenu()

HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

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


Re: [Tutor] Help please!

2012-12-14 Thread Kwpolska
On Sun, Dec 2, 2012 at 2:37 AM, Jack Little  wrote:
> Hi Tutor,
> I'm getting this error
>
> Traceback (most recent call last): File "C:\Users\Jack\Desktop\python\g.py",
> line 45, in  path_1pt1() NameError: name 'path_1pt1' is not defined
>
> With the attached file
>
> Please get back to me
> Thank you
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

You need to define path_1pt1 *before* simpstart.  Also, about not “free source”:
(a) did you mean: open source?
(b) why did you publish it here?

-- 
Kwpolska 
stop html mail  | always bottom-post
www.asciiribbon.org | www.netmeister.org/news/learn2quote.html
GPG KEY: 5EAAEA16
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Which version of activetcl to use for Mac OS X 10.7?

2012-12-14 Thread Prasad, Ramit
Yi Molina wrote:
> 
> Hi, all. I am new to python and just installed Python 2.7.3 on my Mac OS X 
> 10.7.5 from python.org. I read that I
> am supposed to use  ActiveTcl 8.5.11.1. So I clicked on the link on but found 
> only ActiveTcl8.5.11.1.295590-
> macosx10.5-i386-x86_64-threaded.dmg, Which is for MAC OS X 10.5. I could not
> find anything for OS X 10.7, so I installed it.  I tried a few simple 
> programs in IDLE and they work fine. But
> I'd like to confirm if this is the right activetcl version to use?
> 
> Thanks!
> Yi

I usually recommend installing from a package management system and 
not manually installing. You can use MacPorts or Homebrew for OS X 
and they will take care of selecting an appropriate Tcl version.

This (MacPorts) may require you to install some developer tools 
like XCode but the process is *very* simple. I am personally unfamiliar
with Homebrew so I am not sure of their requirements.


~Ramit


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] First semester no coding experince, please help!

2012-12-14 Thread Prasad, Ramit
Mark Rourke wrote:
> Sent: Monday, December 03, 2012 9:24 AM
> To: tutor@python.org
> Subject: [Tutor] First semester no coding experince, please help!
> 
> Hello, the following attachment  (no virus I swear!)is an assignment I have 
> for my programming class, I am
> having alot of difficulty completing this assignment, my teacher does not do 
> a very good job of explaining this
> project to me, I desperately need some help/guidance/direction with this, 
> please help!
> 
> Thanks
> --
> Mark Rourke
> 
> T: 705-728-6169
> M: 705-331-0175
> E: mark.rour...@gmail.com

Why bother attaching the file and not just include the relevant
text in the email (summarizing as you can)? Many people are reluctant
to open an attachment and I can see nothing in the attachment other 
than text. Also, you would be better served by posting in plain text 
(not "rich" mode or HTML) as HTML emails can mangle code causing it to 
be unreadable.

As for your assignment, what is giving you trouble? To me this is clear 
and well documented. I wish my professors in college (or school) had
given me such complete assignments! Do you have code that is giving you 
a problem? If not, why do you not have an attempt? How can we help you 
otherwise?


~Ramit


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Thanks

2012-12-14 Thread
I just want to thank all who gave some input into my questions.
And the points on convention ,hey I just learned about plain text!
Thanks 
Mike


Michael Waters
Business Unit Information Technology
Global Data Center
Data Center Services  Team 
GDC 24/7 HotLine # 800-267-3471
McNeil Consumer Heathcare
A division of Johnson & Johnson


Desk # 519-826-6226 ex 5860
Home# 519-767-2629 Cell 226-500-1776
Office Hours M-F 8:00am 4:00pm
My hours 8:00AM-12:00PM
ITS Guelph
890 Woodlawn Road West,Guelph,On. N1K 1A5
mwat...@its.jnj.com

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


Re: [Tutor] Information

2012-12-14 Thread Prasad, Ramit
Umair Masood wrote:
> 
> How to create a server in python using SOAP? Please also tell the ports to be 
> used. Kindly help me out.
> 
> Regards,
> Umair

The 4th link looks good:
http://lmgtfy.com/?q=How+to+create+a+server+in+python+using+SOAP%3F+#

First link:
http://lmgtfy.com/?q=What+ports+are+used+in+SOAP%3F


Kindly-helping-out,
~Ramit


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help please!

2012-12-14 Thread Steven D'Aprano

On 02/12/12 12:37, Jack Little wrote:

Hi Tutor,
I'm getting this error

Traceback (most recent call last): File "C:\Users\Jack\Desktop\python\g.py",
line 45, in  path_1pt1()
NameError: name 'path_1pt1' is not defined



Names need to be defined before they are used. Code needs to be indented to
be inside a function, if it is not indented then it is considered to be part
of the "top level" code that runs immediately.

So you begin a new function, simpstart:



def simpstart():
   global ammo
   global health
   global tech_parts
   global radio_parts


By the way, you can consolidate those four lines to one:

global ammo, health, tech_parts, radio_parts


But here you lose the indentation, so Python considers the following to
be "top level" code and executes it immediately:


print "You awake in a haze. A crate,a door and a radio."
g1 = raw_input("Which do you choose  ")


Questions in English should end with a question mark, or people will
consider you ignorant and illiterate. Unless you are a famous poet
or artist, in which case they will fawn over how transgressive you are.



if g1 == "CRATE" or g1 == "Crate" or g1 == "crate":


What if they type "cRAtE" or "crATE"?

Much simpler to do this:

if g1.lower() == "create":

By the way, you will find programming much, much simpler if you always
use meaningful variable names. "g1"? What does that mean? A better name
would be something like "user_response", or even just "response".

So, skipping ahead, we come to this bit:


elif g2 == "NORTH" or g2 == "North" or g2 == "north":
 path_1pt1()


Again, this is better written as "if g2.lower() == 'north':".

At this point, Python then tries to call the path_1pt function, but it
hasn't been defined yet. So it gives you a NameError.

How do you fix this? Simple: this entire block of code needs to be
indented level with the global declarations at the start of simstart.

(Fixing this error may very well reveal further errors. Good luck!)

Another comment:



#A Towel Production
# APOC
#---
global ammo1
global ammo2
global ammo3
global health
global tech_parts
global exp
global radio_parts


These seven global lines don't do anything. They are literally pointless. One
of the mysteries to me is why Python allows global declarations outside of
functions, but these lines literally do nothing at all except fool the reader
(you!) into thinking that they do something. Get rid of them.



ammo1=10
ammo2=0
ammo3=0


I note that you have three variables, "ammo1" through "ammo3", but in the
simpstart function, you declare a global "ammo".




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


Re: [Tutor] Clearing Python text

2012-12-14 Thread Mike G
I use Windows XP, Python 2.7, Notepad++ as my editor, and generally
run my .py files from cmd, this is how I toggle between running my .py
file after an edit (and save) and subsequently clearing the screen -
it's pretty easy.

I "arrow-up/arrow-down" on the keyboard to reprint (type) the latest
command in cmd, this toggles between running my .py file...
runs my file ... C:\Python27\MyScripts>python helloworld.py

and to clear whatever printed to the screen...
clears the screen ... C:\Python27\MyScripts>cls

Once you've typed both at the prompt just arrow up or down, then hit
enter - file run or screen cleared, as well saves time retyping.

Sorry if I missed it but this works for me because I too prefer to
print to a cleared screen, don't know why, just do.

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


Re: [Tutor] exercise

2012-12-14 Thread Matthew Ngaha
> return {e for (e, g) in self.sort_email.items()
> if g & groups_list}
>

guys i think ive got it. The & in that comprehension was really
confusing me, but i found out it means intersection, so i took the
sets manually and saw the results i got using intersection and it
became more clear from there. A Big Thanks if you took the time to
help solve my issues.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor