Re: [Tutor] How do I open my browser from within a Python program

2006-09-14 Thread Simon Brunning
On 9/14/06, nimrodx <[EMAIL PROTECTED]> wrote:
> Basically a dumb question I can't seem to find the answer to.
>
> How do I execute a bash command from within a python program.

Well, this question doesn't match the subject line. So, *two* answers.

To open a web browser from within a python program, you want something like:

import webbrowser
webbrowser.open('www.google.com')

To run a shell command - well, it depends. If you don't care about
reading the output or so on, you can just do:

import os
os.system('ls')

If you want to access the input and/or output streams, or to wait for
the shell command to finish, or anything even remotely complex, look
at the subprocess module.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How do I open my browser from within a Python program

2006-09-15 Thread Simon Brunning
On 9/15/06, Will Shattuck <[EMAIL PROTECTED]> wrote:
> On 9/14/06, Simon Brunning <[EMAIL PROTECTED]> wrote:
> >
> > To open a web browser from within a python program, you want something like:
> >
> > import webbrowser
> > webbrowser.open('www.google.com')
> >
>
> I learned something tonight :) I only have 5 or 10 minutes here and
> there to do any learning with python.  So when I saw this my interest
> was raised.  So I started IDLE, and tried it out.  It didn't work as
> above so, I looked for the python module to make sure I was typing
> everything correctly.  The only thing I missed was that there should
> be double quotes instead of single quotes.  Why, I don't know yet as
> I'm not that far, but it kind of makes sense from my dabbling with
> programming over the last 5 years.
>
>   import webbrowser
>   webbrowser.open("www.google.com")

I think you must have had some other issue. In Python, string literals
can be delimited by either singe or double quotes - the resulting
string is identical. (The difference is that in a single quoted
strung, you can use double quote characters without quoting, and
vice-versa. There's yet more to sting literals that this - raw stings,
triple-quoted strings, unicode strings - see
<http://docs.python.org/ref/strings.html> for details.)

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Code for checking whether an input string is a palindrome or not.

2006-10-13 Thread Simon Brunning
def pal(spam): return spam == spam[::-1]

;-)

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] need some class / module help

2006-10-20 Thread Simon Brunning
On 10/20/06, shawn bright <[EMAIL PROTECTED]> wrote:
> oh, one more thing.
> these objects are going to be created at the rate of about 20 / minute in a
> thread.
> at some point is this going to be a problem ? do they go away over time?
> Or do i need to write something that will kill them?

If you don't keep references too them (i.e. by having names that are
bound to them, or by keeping them in collections) then they'll go away
- usually as soon as the last reference to them is gone.

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] OOP and Python.. a gentle remark

2006-10-25 Thread Simon Brunning
On 10/25/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
>  Why is it necessary to explicity use self argument in the class functions
> ?? I feel the language/interpreter should figure out which object has called
> the function? Isnt it ? (the use of 'self' keyword really confuses me. and
> to make matter worse the variables can be accessed from outside teh class.
> Isnt it a violation of the OOP principle of ENCAPSULATION)



> Also please let me know hwo can we declare PRIVATE VARIABLES in Python...??



-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] problem importing class

2006-10-26 Thread Simon Brunning
On 10/26/06, shawn bright <[EMAIL PROTECTED]> wrote:
> import site

Try this for a clue:

print site.__file__

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Cal command in python...

2006-11-02 Thread Simon Brunning
On 11/2/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
> In the Python standard library. Much of the library is written in Python
> and supplied as source. On Windows it will be something like
> C:\Python25\Lib\calendar.py. On other platforms I don't know the path
> but it will be part of the Python installation.

If you do:

import calendar
print calendar.__file__

That will tell you where it is on your system. Works for any module.

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Which is the latest version of Python for windows

2006-11-09 Thread Simon Brunning
On 11/9/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
> Hi Folks,
>
> Can someone tell me which is teh latest version of Python on windows
> platform?

Version 2.5

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Which is the latest version of Python for windows

2006-11-09 Thread Simon Brunning
On 11/9/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
> I am so sorry to disturb you. I hope u dont mind.
> I cannot find the version 2.5 for Active Python.

http://www.google.com/search?q=python+2.5+windows+download

> Is it possible to use two versions at the same time..??

Yup. Install however many versions you want. Install the version that
you want to use by default (i.e. the version that gets used when you
double-click on a .py file) *last*.

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A strange problem--Django

2006-11-16 Thread Simon Brunning
On 11/16/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
> I am trying to view this URL:
> http://www.developeriq.com/aboutus.php3.
>
> But my browser (IE 7) is giving me the following message;
>
>
> It worked!
> Congratulations on your first Django-powered page.
> Of course, you haven't actually done any work yet. Here's what to do next:

It look like whoever is running the http://www.developeriq.com site
has set up a Django site, but not yet configured it.

If that "whoever" is you, check out the Django tutorial - it's excellent.

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A strange problem--Django

2006-11-16 Thread Simon Brunning
On 11/16/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
> Its not me and I dont know what is Django.  :)-

Google does: . ;-)

But anyway, it looks like there's a problem at developeriq's end, so
you'll have to contact them to get it fixed.

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to connect to the SOAP server and make a request..........

2006-11-28 Thread Simon Brunning
On 11/28/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
> I am using SOAPpy module to make SOAP requests.
>
> Can someone point me documentation that has list of functions that can be
> used for carrying out various tasks.



-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What is the meaning of using single underscore in front of variable name

2006-11-28 Thread Simon Brunning
On 11/28/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
> What does this mean?
>
> _url = 'http://api.google.com/search/beta2'
> _namespace = 'urn:GoogleSearch'
>
> Single underscore as a prefix in variable naming...?? whats it for??

It means "private by convention" - see
.

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] WHy use SOAPpy if we can do the things using httplib moduleRe: How to connect to the SOAP server and make a request..........

2006-11-28 Thread Simon Brunning
On 11/28/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
>
> I read the URL suggested by Simon, In that URL, it is given how to create
> the SOAP ENVELOPE using
> httplib, so why bother about using SOAPpy...??

The article discusses two ways of doing SOAP; by hand, and using
SOAPpy. Building the SOAP message by hand is part of the first
section, using SOAPpy is the second.

There's also a number of other article in the series:


-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] WHy use SOAPpy if we can do the things using httplibmoduleRe: How to connect to the SOAP server and make arequest..........

2006-11-29 Thread Simon Brunning
On 11/28/06, Andreas Kostyrka <[EMAIL PROTECTED]> wrote:
> Wimp! You can do it in binary machine code.

Binary? You need ones *and* zeros? Loser.

;-)

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] getting all txt files in a folder

2006-12-12 Thread Simon Brunning
On 12/12/06, Toon Pieton <[EMAIL PROTECTED]> wrote:
> Is there any way to get all the txt files in a certain folder and all of its
> "sub"-folders? With sub-folder I mean all the folders inside the previously
> found folder. Any help would be greatly appreciated

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/499305

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python web dev

2007-01-04 Thread Simon Brunning
On 1/4/07, OkaMthembo <[EMAIL PROTECTED]> wrote:
> this is my first post.

Welcome!

> please could you tell me which is the best
> lightweight python web framework?

Best? That's a potentially contensious one. But I can tell you that if
you were to look at either Django or TurboGears you wouldn't be going
too far wrong. (I use Django, but I know that both are good.)

> also, which is the best templating
> language for python? (which can handle other data formats in addition to
> text). so far im lured by Cheetah, although i havent done any web dev with
> python yet.

Cheetah's good, but if you go with Django, it has its own which is
pretty good too. (I use both at times.)

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Set changing order of items?

2007-01-19 Thread Simon Brunning
On 1/19/07, Adam Cripps <[EMAIL PROTECTED]> wrote:
> I'm adding strings to a Set to prevent duplicates. However, the
> strings are meant to be in the correct order. When I add the string to
> the Set, the order seems to change (and I don't seem to be able to
> predict what order they are in).

Sets, like dictionaries, hold their items in an arbitrary order - see
.

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Variable Swap

2007-01-30 Thread Simon Brunning
On 1/30/07, Steve Nelson <[EMAIL PROTECTED]> wrote:
> > x, y = y, x
>
> Doesn't this use temporary variables?

Python doesn't really *have* variables, as such, so no. What it does
is to create a tuple referring to the objects (or just possibly one
object) referred to by the names 'y' and 'x', then re-binds the
objects from the tuple to the names 'x' and 'y' respectively.

Reset your brain! 

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor