Re: question

2008-05-29 Thread John Henderson
Gandalf wrote:

> how do i write this code in order for python to understand it
> and print me the x variable
> 
> x=1
> def ():
> x++
> if x > 1:
> print "wrong"
> else :
> print x
> 
> ()

Example:

x=1
def (x):
x += 1
if x > 1:
return "wrong"
else :
   return x

print (x)


John
--
http://mail.python.org/mailman/listinfo/python-list


Re: SMS sending and receiving from website?

2008-05-30 Thread John Henderson
globalrev wrote:

> can i send and receive messages from a website using python?

Absolutely.  But I'm not clear what you mean by "from a
website".  Do you mean to use SMPP protocol to lodge and
receive messages?  Or do you want access to your own cellular
hardware from a web interface?

> how would that work with costs? would the mobileowner pay both
> ways?

That depends on the country, the carrier and the offers/plans
that carrier makes.  In most of the civilized world, SMS
receivers pay nothing.

John
--
http://mail.python.org/mailman/listinfo/python-list


Re: SMS sending and receiving from website?

2008-05-31 Thread John Henderson
globalrev wrote:

> i want to build a service where you can send an SMS with your
> cellphone to my website and then the site will collect the
> data you asked for and SMS it back.
> 
> so what components would i need for that?

Arguably the simplest route is to use a phone with a serial
connection to a computer, whether that connection be RS232,
USB, IrDA or Bluetooth.

For outgoing messages in large volume, SMS lodgement directly to
an SMSC (message centre) via SMPP over an internet connection
is likely to be a cheaper option in the long term.  But that'll
depend on what's on offer in your part of the world.

There's probably some means of receiving messages without using
your own hardware, but I'm not aware of any details.

If using your own hardware, I'd suggest a cellular modem rather
than a handset.  These are permanently powered by a low voltage
DC supply, rather than a battery you need to keep charged
without destroying it with constant overcharge.

And a modem is more likely to support text-mode command
interactions with your computer rather than raw PDU-mode
interactions.  PDU-mode requires your software to translate
to/from the raw transmitted SMS data, but gives you much
greater control.

The rest is software, and your cost will depend on how you get
or develop that.

You might be able to get a SIM (assuming a GSM or UMTS cellular
device) with very cheap SMS rates.  A pre-paid service will
limit your losses if your software ever gets over-enthusiastic
about sending messages.

John
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to invoke the Python idle

2008-06-29 Thread John Henderson
Only-Trouble wrote:

> Hi all
> I am running openSUSE 10.3
> I am learning python on my own, it seems like  the system has
> already installed a python IDLE
> The question is how to invoke it?

If it's anything like my Red Hat system, I had to find the
command first.  In my case, at:

/usr/lib/python2.2/site-packages/idle/idle

I copied that file to somewhere where it was available on my
$PATH variable.

John
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Math libraries - How to?

2008-04-28 Thread John Henderson
[EMAIL PROTECTED] wrote:

> Hi, I am a very newbie who would very much appreciate some
> hints.
> 
> Python 2.52. on Windows XP for now. Soon on Ubuntu 8
> 
> I am teaching myself Python following free tutorials. I can
> solve problems using arithmetic, but when I try to upgrade the
> programs using math libraries nothing seems to work. I
> downloaded a 2002 tutorial from Zelle "An Introduction to
> Computer Science" where he uses a "import math" statement to
> calculate a square root. I tried the
> "pi" library function but it didn“t work. I tried using def
> Pi()  it did not work either. I am yet to find a tutorial that
> explains how to declare (or initialize) and pass numbers to
> the functions such as "cos(x)" and the pi which does not have
> a variable in it. Is just a constant.
> 
> Here is the arithmetic program I made that it worked before I
> added
> the "import math" line.  I  erased the constant p = 3.1416 and
> added the "i" for the library function "pi" in the algorithms.
> But I get an error message not recognizing "pi"
> 
> 
> 
> #volumen.py
> # A program to compute the volume and surface area of a sphere
> import math


Change that line, "import math", to:

from math import *

and it'll work.  I'm learning too, so some proficient person
might be able to explain the difference to both of us :)

John


> 
> def main():
> 
> print "This program calculates the volume and surface area
> of a
> sphere"
> print
> r = input("Please enter the radious: ")
> print
> r3 = r*r*r
> volume = 4/3*pi*r3
> r2 = r*r
> surface = 4*pi*r2
> print "The Volume is", volume, " Cubic centimeters"
> print
> print "The Surface area is", surface, " square
> centimeters"
> 
> main()
> 
> *** Error message *
> 
> Traceback (most recent call last):
>   File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 20,
>   in
> 
> main()
>   File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 13,
>   in main
> volume = 4/3*pi*r3
> NameError: global name 'pi' is not defined

--
http://mail.python.org/mailman/listinfo/python-list

Re: Python, are you ill?

2008-05-10 Thread John Henderson
[EMAIL PROTECTED] wrote:

> If you are in the interactive prompt of the Python interpreter
> and you do this
> 
> print """Testing\"""   or   print '''Testing\'''
> 
> you get three dots [...] as if Python expects a code block. If
> you press Enter, you get three dots again, and again, and
> again... You can't get out of the code block with pressing the
> Enter key; you have to press Ctrl+Z (if you're in Linux) in
> order to get out of that code block, which then throws you
> back to the Linux command line, but before that it prints this
> line
> 
> [1]+  Stopped python
> 
> 
> If you do
> 
> print "Testing\"   or   print 'Testing\'
> 
> you get an error, but not of you use the triple quotes. Is
> that a bug in the interpreter perhaps?

>>> print """testing\"""
"""
testing"""

John
--
http://mail.python.org/mailman/listinfo/python-list