Re: [Tutor] How I overcame my problems executing python programs.

2012-03-16 Thread cyclicf...@yahoo.com
I've just received this e-mail on my android and believe that the above  
advice is good(as always), this list is great for beginners as there are a  
never-ending amt. Of talented/knowledgable ppl. Available. Additionally, I  
love Eclipse's Pydev(Comes incl. 'd) already in  
AptanaStudio(Eclipse-derivative for web-development and best of all python.  
Its very new, and although there is a commercial version, they provide full  
features to the free Aptana version. If you go this route, there is one less  
step, and me starting python a year or so ago, it was a life-saver. The  
other life-saver was the pydoc feature that comes with the std. Python  
Windows installation. Its amazing and if my memory serves correctly in  
Windows IDLE launched from the help menu.  Thats great for quickly  
referencing things. But good luck!! 


Sent from my Verizon Wireless Phone

-Original message-
From: tutor-requ...@python.org
To: tutor@python.org
Sent: Fri, Mar 16, 2012 01:12:28 GMT+00:00
Subject: Tutor Digest, Vol 97, Issue 41

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. how I overcame the problem "I cannot run Python programs"
 (Tamar Osher)
  2. Re: how I overcame the problem "I cannot run Python   programs"
 (eire1...@gmail.com)
  3. more about how I overcame not being able to run my programs
 (Tamar Osher)
  4. Re: more about how I overcame not being able to run my
 programs (Alan Gauld)
  5. Re: how I overcame the problem "I cannot run Python   programs"
 (Mark Lawrence)
  6. Re: more about how I overcame not being able to runmy
 programs (Steven D'Aprano)
  7. Re: how I overcame the problem "I cannot run Python   programs"
 (Alan Gauld)


--

Message: 1
Date: Thu, 15 Mar 2012 17:12:37 -0500
From: Tamar Osher 
To: "Tutor@Python.org" 
Subject: [Tutor] how I overcame the problem "I cannot run Python
programs"
Message-ID: 
Content-Type: text/plain; charset="iso-8859-1"


I realized that my computer was running the programs.  The black box was  
flashing off and disappearing immediately, so that I never saw the programs.  
Also, I am using Notepad++, in addition to IDLE.  I am now able to see my  
programs and provide user input, when I use Notepad++.

Also, I still have not fully overcome, I am slowly on my way to success.
I am working vigorously on Python, but only 10% of my time is learning  
Python.  The rest of my time is learning everything related to Python, to  
get my programs to work.
I greatly appreciate everyone's help!  I cannot thank each of you enough.   
Thanks for being there when I need someone!  Have a wonderful day!








		 	   		  
-- next part --

An HTML attachment was scrubbed...
URL:  



--

Message: 2
Date: Thu, 15 Mar 2012 22:30:47 +
From: eire1...@gmail.com
To: "Tamar Osher" ,
tutor-bounces+eire1130=gmail@python.org,"Tutor@Python.org"

Subject: Re: [Tutor] how I overcame the problem "I cannot run Python
programs"
Message-ID:
	 
<1795078761-1331850648-cardhu_decombobulator_blackberry.rim.net-1415149165-@b 
11.c28.bise6.blackberry>


Content-Type: text/plain


That's the nature of things I'm afraid. 

I do about half of my development on windows. My recomendation, download  
eclipse and install pydev. IDE choice is always a touchy subject but for  
windows, this should be your choice.


I have notepad++ as well. Its great. But eclipse is better, especially for  
learning. I can't describe how much it helped me.





Sent from my Verizon Wireless BlackBerry

-Original Message-
From: Tamar Osher 
Sender: tutor-bounces+eire1130=gmail@python.org
Date: Thu, 15 Mar 2012 17:12:37 
To: Tutor@Python.org

Subject: [Tutor] how I overcame the problem "I cannot run Python programs"

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




--

Message: 3
Date: Thu, 15 Mar 2012 17:39:53 -0500
From: Tamar Osher 
To: "Tutor@Python.org" 
Subject: [Tutor] more about how I overcame not being able to run my
programs
Message-ID: 
Content-Type: text/plain; charset="iso-8859-1"


I am very appreciative for the many valuable individuals who graciously take  
their precious time to help others in need.  Special 

Re: [Tutor] stuck on null values

2012-03-16 Thread Joel Goldstick
On Thu, Mar 15, 2012 at 5:45 PM, ADRIAN KELLY  wrote:
>
>
>
> Adrian Kelly
> 1 Bramble Close
> Baylough
> Athlone
> County Westmeath
>
> 0879495663
>
>
>> Date: Thu, 15 Mar 2012 17:38:52 -0400
>> Subject: Re: [Tutor] stuck on null values
>> From: joel.goldst...@gmail.com
>> To: kellyadr...@hotmail.com
>> CC: tutor@python.org
>
>>
>> On Thu, Mar 15, 2012 at 5:24 PM, ADRIAN KELLY 
>> wrote:
>> > Please can anyone tell me how to solve the problem i am having here, i
>> > am
>> > trying to loop if the value is left blank by the user
>> > but how can i then use the value and multiply it.  e.g. while
>> > number_child=="" i want to multiply the input i
>> > get.???
>> >
>> > def main():
>> >     print """
>> > 
>> >
>> >                 Welcome to the Travel Kiosk
>> > 
>> > """
>> >
>> >     adult=15
>> >     child=5
>> >     firstname=raw_input("Please enter your firstname: ")
>> >     lastname=raw_input ("Please enter your lastname: ")
>> >     number_child=raw_input("Enter the number of kids: ")
>> >     number_adults=raw_input("Enter the number of adults: ")
>> >     while number_child=="":
>> >         number_child=raw_input("Enter the number of kids: ")
>> >     price=child*number_child
>> >
>> >
>> >     print """
>> > ___
>> >
>> > Thank you, the Price will be: """,price
>> >     print"""
>> > ___
>> > """
>> >
>> > main()
>> >
>> >
>> >
>> >
>> >
>> >
>> > Adrian Kelly
>> > 1 Bramble Close
>> > Baylough
>> > Athlone
>> > County Westmeath
>> >
>> > 0879495663
>> >
>> > ___
>> > Tutor maillist  -  Tutor@python.org
>> > To unsubscribe or change subscription options:
>> > http://mail.python.org/mailman/listinfo/tutor
>> >
>> raw_input returns the values the user types as a string. In python if
>> you have 3 * 'bob' the result will be "bobbobbob"
>>
>> So you need to turn the number_child into a number like so:
>> int(number_child)
>>
>> You will need to do the same thing for the number of adults.
>>
>> That will get you started, but if your user types in something that
>> isn't a number, your program will fail. See if you can get it to work
>> for good data and then come back with what happens when you type in
>> other than integers.
>>
>> Also, when your program fails, it prints out what is called a
>> traceback. When you get this situation, be sure to post the traceback
>> with your problem. It helps figure out what went wrong
>>
>>
>> --
>> Joel Goldstick
>
> ...
> adrian replied,
> i tried it with integers earlier and then i couldn't use while
> number_children=="":
>
>
First, don't reply to the last responder.  Reply to the list

Take a look at this:

while True:
  num = raw_input("give me an integer: ")
  try:
n = int(num)
break
  except:
print "Sorry, that wasn't and integer!"
pass

While True will keep doing forever the block underneath it
try: is how python checks to see if something causes an except.  An
exception is something that isn't what you want to have happen for
your code to continue happily
if n can't be converted to an int, it raises an exception, and
immediately jumps to the code at 'except:

However, if n=int(num) is happy, break happens which will get you out
of the while True loop



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


[Tutor] Help for to do a script

2012-03-16 Thread Boris Vladimir Comi

Hello, I am writing to request your help in the realization of a script. I am 
new to this and I'm just learning the wonderful world of python and this has 
made me a little difficult.

Briefly I commented what I intend to do:

I detect a class of atmospheric phenomena known as Mesoscale Convective Systems 
(MCS). To accomplish this, I have a database of satellites by 2004, every half 
hour. These data were downloaded from the server: unidata2.ssec.wisc.edu and 
data format is: 200404271515.goes12ir (Area Format)

The first thing to do is detect a convective system in the satellite data, 
using the following characteristics:

MCS Criteria

Minimum Size: Continuous cold cloud shield (TIR <219 K and Must Have an area> 
34000 km ²)

Duration: Definition of Minimum Size Must Be A Period of Exceed or ≥ 3h

Initiation: Time When the Minimum Size is met

Maximum Extention: Time when the continuous cloud shield (TIR <219 K) is at its 
maximum size

Termination: When the Time Minimun Size is not satisfied

where: Temperature Infrarred is TIR

To achieve this, first I created a script in python to identify a MCS in my 
database (script in attached)

The script is run from a linux terminal ($ python TIR.py), to run it I get the 
following error:

File "/home/mcidasv/JYTHON/TIR.py", line 22
count = count + 1;
^
SyntaxError: invalid syntax

 If anyone can help me with this script or any idea you suggest to improve it, 
I would greatly appreciate.



Boris Vladimir Comi Gonzalez
Universidad Nacional Autónoma de México
Grupo de Tormentas Convecivas
  # Call data from the directory(/home/mcidasv/Documentos/CLASS)

def scm(directory):
  import os;
  fs = os.listdir(directory);

  # now fs will be a list of all the files in directory

  from edu.wisc.ssec.mcidas import AreaFile;
  for name in fs:
  print "Reading in:",name
  af = AreaFile(directory+"/"+name);
  ad = af.getAreaDirectory();
  count = 0;
  data = af.getFloatData();

  # now look through the first band y count pixels
  # MCS detected whose his temperature infrared (TIR) is < 219 K
  
  for i in xrange(ad.getLines()):
  for j in xrange(ad.getElements()):
  if (data[0][i][j] > 199.5 and (data[0][i][j] < 200.5
  count = count + 1;
  print "For file",name," count = ",count  
 
scm("/home/mcidasv/Documentos/CLASS")
  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help for to do a script

2012-03-16 Thread Joel Goldstick
On Fri, Mar 16, 2012 at 2:52 PM, Boris Vladimir Comi
 wrote:
> Hello, I am writing to request your help in the realization of a script. I
> am new to this and I'm just learning the wonderful world of python and this
> has made me a little difficult.
>
> Briefly I commented what I intend to do:
>
> I detect a class of atmospheric phenomena known as Mesoscale Convective
> Systems (MCS). To accomplish this, I have a database of satellites by 2004,
> every half hour. These data were downloaded from the server:
> unidata2.ssec.wisc.edu and data format is: 200404271515.goes12ir (Area
> Format)
>
> The first thing to do is detect a convective system in the satellite data,
> using the following characteristics:
>
> MCS Criteria
>
> Minimum Size: Continuous cold cloud shield (TIR <219 K and Must Have an
> area> 34000 km ²)
>
> Duration: Definition of Minimum Size Must Be A Period of Exceed or ≥ 3h
>
> Initiation: Time When the Minimum Size is met
>
> Maximum Extention: Time when the continuous cloud shield (TIR <219 K) is at
> its maximum size
>
> Termination: When the Time Minimun Size is not satisfied
>
> where: Temperature Infrarred is TIR
>
> To achieve this, first I created a script in python to identify a MCS in my
> database (script in attached)
>
> The script is run from a linux terminal ($ python TIR.py), to run it I get
> the following error:
>
>
> File "/home/mcidasv/JYTHON/TIR.py", line 22
>     count = count + 1;
>     ^
> SyntaxError: invalid syntax
>
> If anyone can help me with this script or any idea you suggest to improve
> it, I would greatly appreciate.
>
>
>
> Boris Vladimir Comi Gonzalez
> Universidad Nacional Autónoma de México
> Grupo de Tormentas Convecivas
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

Here is your code:

 for i in xrange(ad.getLines()):
  for j in xrange(ad.getElements()):
  if (data[0][i][j] > 199.5 and (data[0][i][j] < 200.5
  count = count + 1;
  print "For file",name," count = ",count

Notice that this line is broken:

  if (data[0][i][j] > 199.5 and (data[0][i][j] < 200.5

change it to this and try running again:

  if (data[0][i][j] > 199.5) and (data[0][i][j] < 200.5)


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


Re: [Tutor] Help for to do a script

2012-03-16 Thread Joel Goldstick
On Fri, Mar 16, 2012 at 2:58 PM, Joel Goldstick
 wrote:
> On Fri, Mar 16, 2012 at 2:52 PM, Boris Vladimir Comi
>  wrote:
>> Hello, I am writing to request your help in the realization of a script. I
>> am new to this and I'm just learning the wonderful world of python and this
>> has made me a little difficult.
>>
>> Briefly I commented what I intend to do:
>>
>> I detect a class of atmospheric phenomena known as Mesoscale Convective
>> Systems (MCS). To accomplish this, I have a database of satellites by 2004,
>> every half hour. These data were downloaded from the server:
>> unidata2.ssec.wisc.edu and data format is: 200404271515.goes12ir (Area
>> Format)
>>
>> The first thing to do is detect a convective system in the satellite data,
>> using the following characteristics:
>>
>> MCS Criteria
>>
>> Minimum Size: Continuous cold cloud shield (TIR <219 K and Must Have an
>> area> 34000 km ²)
>>
>> Duration: Definition of Minimum Size Must Be A Period of Exceed or ≥ 3h
>>
>> Initiation: Time When the Minimum Size is met
>>
>> Maximum Extention: Time when the continuous cloud shield (TIR <219 K) is at
>> its maximum size
>>
>> Termination: When the Time Minimun Size is not satisfied
>>
>> where: Temperature Infrarred is TIR
>>
>> To achieve this, first I created a script in python to identify a MCS in my
>> database (script in attached)
>>
>> The script is run from a linux terminal ($ python TIR.py), to run it I get
>> the following error:
>>
>>
>> File "/home/mcidasv/JYTHON/TIR.py", line 22
>>     count = count + 1;
>>     ^
>> SyntaxError: invalid syntax
>>
>> If anyone can help me with this script or any idea you suggest to improve
>> it, I would greatly appreciate.
>>
>>
>>
>> Boris Vladimir Comi Gonzalez
>> Universidad Nacional Autónoma de México
>> Grupo de Tormentas Convecivas
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
> Here is your code:
>
>     for i in xrange(ad.getLines()):
>          for j in xrange(ad.getElements()):
>              if (data[0][i][j] > 199.5 and (data[0][i][j] < 200.5
>                  count = count + 1;
>      print "For file",name," count = ",count
>
> Notice that this line is broken:
>
>              if (data[0][i][j] > 199.5 and (data[0][i][j] < 200.5
>
> change it to this and try running again:
>
>              if (data[0][i][j] > 199.5) and (data[0][i][j] < 200.5):
>
>
> --
> Joel Goldstick

Sorry, also put : at end of if statements

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


Re: [Tutor] stuck on null values

2012-03-16 Thread Alan Gauld

On 16/03/12 14:44, Joel Goldstick wrote:


Take a look at this:

while True:
   num = raw_input("give me an integer: ")
   try:
 n = int(num)
 break
   except:
 print "Sorry, that wasn't and integer!"
 pass



The pass is redundant it does nothing (thats its purpose! :-)
You can also remove the variable n:

while True:
try:
   num = int(raw_input("give me an integer: "))
   # use num now or keep it for later
   break
except:
  print "Sorry, that wasn't an integer!"

# can also use num here...


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 for to do a script

2012-03-16 Thread Alan Gauld

On 16/03/12 18:52, Boris Vladimir Comi wrote:


*File "/home/mcidasv/JYTHON/TIR.py", line 22
count = count + 1;
^
SyntaxError: invalid syntax*


Error messages indicate where Python found the problem.
Often the real problem is a line or so before that.

In your case you omitted the colon after the if statement.

Note that Python does not require semi colons at
the end of lines. It rarely causes problems but
it doesn't help either.

--
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] stuck on null values

2012-03-16 Thread Joel Goldstick
On Fri, Mar 16, 2012 at 3:02 PM, Alan Gauld  wrote:
> On 16/03/12 14:44, Joel Goldstick wrote:
>
>> Take a look at this:
>>
>> while True:
>>   num = raw_input("give me an integer: ")
>>   try:
>>     n = int(num)
>>     break
>>   except:
>>     print "Sorry, that wasn't and integer!"
>>     pass
>
>
>
> The pass is redundant it does nothing (thats its purpose! :-)
> You can also remove the variable n:
>
> while True:
>    try:
>       num = int(raw_input("give me an integer: "))
>       # use num now or keep it for later
>       break
>    except:
>      print "Sorry, that wasn't an integer!"
>
> # can also use num here...
>
>
> HTH
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
Good Catch!  I originally had the pass in alone, but then decided to
give a helpful message.  Didn't remove the pass
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor



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


[Tutor] Datetime objects

2012-03-16 Thread Luke Thomas Mergner
Hi,

I am having trouble comparing two datetime objects. Using Sqlalchemy I save a 
string as a date into an sqlite field (which has no native date format, I 
gather). 

> import datetime as dt

> date_obj = dt.datetime.strptime(date_string,'%m.%d.%Y')

I want to compare that date later with an inputed date, which I created with 
strptime(). This function is only available for datetime.datetime.strptime() 
not datetime.date 

> >>> compare_date = dt.datetime.strptime('2011-01-27', '%Y-%m-%d')

> >>> print compare_date
> datetime.datetime(2012, 1, 27, 0, 0)

Despite the fact that I don't care about the time fields, they still get added. 
It appears that I can get at the date object returned in an sqlalchemy object:

> >>> for row in query_object:
> ... type(row.date)
> ... 
> 2012-03-16 19:18:18,420 INFO sqlalchemy.engine.base.Engine SELECT posts.date 
> AS posts_date 
> FROM posts
> 2012-03-16 19:18:18,420 INFO sqlalchemy.engine.base.Engine ()
> 
> 
> 


But when I compare them, it always returns false because datetime.date does not 
seem to compare to datetime.datetime...

> >>> for row in q1:
> ... print type (row.date), row.date, ' vs ', type(compare_date), 
> compare_date, row.date == compare_date
> ... 
> 2012-03-16 19:33:56,011 INFO sqlalchemy.engine.base.Engine SELECT posts.date 
> AS posts_date 
> FROM posts
> 2012-03-16 19:33:56,011 INFO sqlalchemy.engine.base.Engine ()
>  2011-11-05  vs   2012-01-27 
> 00:00:00 False
>  2011-11-29  vs   2012-01-27 
> 00:00:00 False
>  2011-12-23  vs   2012-01-27 
> 00:00:00 False
>  2012-01-18  vs   2012-01-27 
> 00:00:00 False
>  2012-01-17  vs   2012-01-27 
> 00:00:00 False
>  2012-01-27  vs   2012-01-27 
> 00:00:00 False
>  2012-01-14  vs   2012-01-27 
> 00:00:00 False

Can  anyone help me out here? Thanks in advance.

PS: I'm asking here since I think this is a simple object comparison question, 
not a question specific to a library (sqlalchemy).  If it matters, I'm playing 
around with a small web log application built on Werkzeug, Sqlalchemy, and 
Jinja2. I'm actually very impressed with the progress I've made.

Luke Mergner
Mechanicsville, MD
lmerg...@gmail.com___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Datetime objects

2012-03-16 Thread Steven D'Aprano

Luke Thomas Mergner wrote:

Hi,

I am having trouble comparing two datetime objects.


No you're not. You're having trouble comparing a datetime and a date object.

[...]

But when I compare them, it always returns false because datetime.date does
not seem to compare to datetime.datetime...


Use date_obj.date() to return a date object without the times, then compare
that to the date objects sqlalchemy gives you.



--
Steven

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