[Tutor] Standalone Version]

Alan Gauld alan.gauld at btinternet.com
Fri Feb 22 00:58:16 CET 2008


> From: Artur Sousa <tucalipe at gmail.com>
> To: Kent Johnson <kent37 at tds.net>
>
> Sorry to bother again.
>
> Is there a way to distribute a Python program freely on a standalone
> version, in which the other person doesn't have to actually open the
> Command Line and execute the .py file?

If the OS is configured properly then a normal python file can be
run without opening a command prompt. Just dounble click in
Explorer(assuming Windoze).

However if you want to distribute a python program without Python
being installed there are several options, the best known of which
is py2exe - again for Windoze

> And please, excuse me, but as english is not my native language, I
> couldn't quite understand how to concatenate str and int with %
> (modulo).

In this context % is not the modulo operator but the string format 
operator.

The trick is to create a format string which defines the structure
of your output string by inserting markers into the format string.
The marker for an integer is %d (for decimal) so you could write:

fmtString = "%d is a number"

This creates a template to create a string containing a number:

print fmtString % 42

Here the number 42 is substituted into the format string.
You must provide as many values as thee are martkers
in the format string:

print "%d plus %d equals: %d"   % (22,7,22+7)

Note the string has 3 markers, all decimals and we
provide 3 numeric values.

There are many other marker types as well as ways of
specifying the space occuipied, justification, padding etc.

If you don't understand any of that please reply with specifics
to the list.


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
(still broke! :-(




>
> <code>
> ttaken = (quantity*3600)/phour
> str1 = "Para produzir "
> str2 = u" unidades desse recurso, serao necess\u00E1rios "
> if ttaken == 1:
>     str3 = " segundo, ou "
> else:
>     str3 = " segundos, ou "
> if ttaken/60 <= 1:
>     str4 = " minuto, ou "
> else:
>     str4 = " minutos, ou "
> if ttaken/3600 <= 1:
>     str5 = " hora."
> else:
>     str5 = " horas."
> print str1
> print quantity
> print str2
> print ""
> print ttaken
> print str3
> print ""
> print ttaken/60.0
> print str4
> print ""
> print ttaken/3600.0
> print str5
> </code>
>
> for quantity is an integer user input value and phour is another int
> based on a user inputted int.
>
> PS.: I'd also like to thank very much for all the support I've been
> receiving.
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 




More information about the Tutor mailing list