Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread eryksun
On Thu, Jan 24, 2013 at 5:39 PM, Matthew Ngaha  wrote:
>
> D:\Data\Py\mywork>ftype Python.File
> Python.File="D:\Data\Py2.7\python.exe" "%1" %*

That's the file class created by the 2.7 installer in the HKLM (local
machine) Software hive.

Overview of the Windows Registry:
http://en.wikipedia.org/wiki/Windows_Registry

The cmd shell's assoc/ftype use HKLM classes. However, I see now that
the standalone launcher configures HKCU (current user) classes. These
take precedence over HKLM classes, so assoc and ftype aren't showing
the complete picture.

HKCR (classes root) is the merged view. The following shows the
current default command to open a Python.File:

reg query HKCR\Python.File\shell\open\command

> i dont quit understand when you say UserChoice is set to the Progid
> "Python.File"? what is Progid? i cant seem to locate that path
> HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py.

reg query 
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\UserChoice

If you've selected a default using the "Open With" dialog, there
should be a 'Progid' set to, for example, Python.File. Modify this
using the Explorer "Open With"/"Choose Default Program..." dialog. I
mention this because installers don't generally modify this key. It's
set manually by the user -- possibly to an editor or a specific Python
executable instead of the configured Python.File class.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Matthew Ngaha
> In a cmd shell, check that 'assoc .py' is "Python.File" and that
> 'ftype Python.File' points to py.exe in your Windows directory, e.g.
> "C:\Windows\py.exe "%1" %*'. If it's wrong, re-install. Or fix it
> manually using assoc and ftype in an elevated cmd shell, which updates
> the local machine registry keys in HKLM\Software\Classes.

i think this is ok, i got these results.
D:\Data\Py\mywork>assoc .py
.py=Python.File

D:\Data\Py\mywork>ftype Python.File
Python.File="D:\Data\Py2.7\python.exe" "%1" %*

> Also, Windows Explorer has an "Open With" dialog that configures
> per-user settings for multiple associations, including a default (i.e.
> the "Always use..." checkbox). These keys are stored in
> HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py.
> Make sure that UserChoice is set to the Progid "Python.File". You
> should be able to change this using the 'Open With->Choose Default
> Program...' dialog.
>

i dont quit understand when you say UserChoice is set to the Progid
"Python.File"? what is Progid? i cant seem to locate that path
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Matthew Ngaha
On Thu, Jan 24, 2013 at 9:35 PM, eryksun  wrote:
> On Thu, Jan 24, 2013 at 1:56 PM, Matthew Ngaha  wrote:
>>
>> py is not recognized and and it said "depending on how it was
>> installed". the problem is it didnt allow me to select a path when
>> installing.
>
> The simpler installer is launchwin.msi, which installs to the Windows
> directory. This directory should already be on the PATH.
>
> In a cmd shell, check that 'assoc .py' is "Python.File" and that
> 'ftype Python.File' points to py.exe in your Windows directory, e.g.
> "C:\Windows\py.exe "%1" %*'. If it's wrong, re-install. Or fix it
> manually using assoc and ftype in an elevated cmd shell, which updates
> the local machine registry keys in HKLM\Software\Classes.
>
> Also, Windows Explorer has an "Open With" dialog that configures
> per-user settings for multiple associations, including a default (i.e.
> the "Always use..." checkbox). These keys are stored in
> HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py.
> Make sure that UserChoice is set to the Progid "Python.File". You
> should be able to change this using the 'Open With->Choose Default
> Program...' dialog.
>
> You can customize pylauncher by editing its ini file in your profile.
> For example, run 'notepad %localappdata%\py.ini' to create/edit it.
> See the docs for the settings, such as changing the default
> interpreter and adding custom shebangs.

sorry i didnt see this message. I havent read it yet although it looks
complicated. Thanks ill report back if i need help
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Matthew Ngaha
> Did you find the "control-panel-way" to modify the PATH (assuming py.exe
> wasn't already in there) ?  Without it, I'd be surprised if right-click
> would work correctly.
>
> And as for IDLE, there are two different IDLEs, one in each directory. So
> run the one that corresponds to the python you'll be using.  How to do that?
> I dunno, since I don't use IDLE, but I'd find or make batch files called
> something like IDLE2.bat and IDLE3.bat that know how to find and run the
> appropriate IDLE.
>
i didnt use the control panel way but the right click is now working,
it was an error that in the script i had a txt.file open() and the
right click way said "no such file" but the other ways found the txt
file which is weird but right clicking works for other files without a
txt file. i can live with that. i think it wise for me to try to
permanently add the path with control panel.

Thanks for all the help, its such a relief to now be able to run python 2 files
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread eryksun
On Thu, Jan 24, 2013 at 1:56 PM, Matthew Ngaha  wrote:
>
> py is not recognized and and it said "depending on how it was
> installed". the problem is it didnt allow me to select a path when
> installing.

The simpler installer is launchwin.msi, which installs to the Windows
directory. This directory should already be on the PATH.

In a cmd shell, check that 'assoc .py' is "Python.File" and that
'ftype Python.File' points to py.exe in your Windows directory, e.g.
"C:\Windows\py.exe "%1" %*'. If it's wrong, re-install. Or fix it
manually using assoc and ftype in an elevated cmd shell, which updates
the local machine registry keys in HKLM\Software\Classes.

Also, Windows Explorer has an "Open With" dialog that configures
per-user settings for multiple associations, including a default (i.e.
the "Always use..." checkbox). These keys are stored in
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py.
Make sure that UserChoice is set to the Progid "Python.File". You
should be able to change this using the 'Open With->Choose Default
Program...' dialog.

You can customize pylauncher by editing its ini file in your profile.
For example, run 'notepad %localappdata%\py.ini' to create/edit it.
See the docs for the settings, such as changing the default
interpreter and adding custom shebangs.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Oscar Benjamin
On 24 January 2013 20:14, Matthew Ngaha  wrote:
>>
> thanks Dave. the file was py.exe as you said and the temporary path is
> able to open both version 2 and 3's  python.exe. There seems to be a
> problem. python 2 seems to be the only version opening my files unless
> i do a few things. So with the shebang set:
>
> the python launcher, launches my python 3 files with the correct
> version if i double click the file or run it from a console. But it
> uses the wrong version if i run it from IDLE or if i right click the
> file and open with the Python Launcher. i guess i can live with that,
> but is there anyway around this?

Each version of Python has it's own version of IDLE. If you use the
IDLE that came with Python 2 it will always run in Python 2. I think
the same is true for the "Python launcher". Probably you have more
than one version of these programs installed. You could create
shortcuts (or something like that) to run the Python 3 versions. In
any case, this is the reason that the py.exe launcher was created, so
that you could have one launcher that would run each script in the
appropriate version of Python.


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


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Matthew Ngaha
> I'm not using it, since I'm not using Windows.  So these are guesses based
> on years stuck\b\b\b\b\b spent in the Windows environment.
>
> Clearly, the name of the program is py.exe, so that's what you should try
> searching for.  From the cmd prompt, try   dir /s  py.exe
>
> Or, you could just try searching under c:\windows  since that's where it's
> likely to be.
>
> To see your PATH, type  PATH   at the cmd prompt.
>
> To make temporary changes to your PATH (if py.exe is in an obscure place),
> just type
>   set PATH=c:\mydir;%PATH%
>
> To make permanent changes to PATH, you have to change the environment
> variables in the Control Panel.  I've done it many times, but don't recall
> just where it is.  Such permanent changes will affect any new runs of CMD,
> as well as affect any other program subsequently started.
>
thanks Dave. the file was py.exe as you said and the temporary path is
able to open both version 2 and 3's  python.exe. There seems to be a
problem. python 2 seems to be the only version opening my files unless
i do a few things. So with the shebang set:

the python launcher, launches my python 3 files with the correct
version if i double click the file or run it from a console. But it
uses the wrong version if i run it from IDLE or if i right click the
file and open with the Python Launcher. i guess i can live with that,
but is there anyway around this?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Dave Angel

On 01/24/2013 01:56 PM, Matthew Ngaha wrote:


Have you added shebang lines to those scripts yet?


yes i added them. i think the problem is at the start where it asks me to:

You should ensure the launcher is on your PATH - depending on how it was
installed it may already be there, but check just in case it is not.


From a command-prompt, execute the following command:

py
You should find that the latest version of Python 2.x you have installed is
started ..

py is not recognized and and it said "depending on how it was
installed". the problem is it didnt allow me to select a path when
installing. it just automatically did everything. i have searched my
PC for python launcher but it cant find it, so i dont know where its
location is. i see it in "control panel" to uninstall a program but
right clicking it doesnt give me an option to see its containing
folder



I'm not using it, since I'm not using Windows.  So these are guesses 
based on years stuck\b\b\b\b\b spent in the Windows environment.


Clearly, the name of the program is py.exe, so that's what you should 
try searching for.  From the cmd prompt, try   dir /s  py.exe


Or, you could just try searching under c:\windows  since that's where 
it's likely to be.


To see your PATH, type  PATH   at the cmd prompt.

To make temporary changes to your PATH (if py.exe is in an obscure 
place), just type

  set PATH=c:\mydir;%PATH%

To make permanent changes to PATH, you have to change the environment 
variables in the Control Panel.  I've done it many times, but don't 
recall just where it is.  Such permanent changes will affect any new 
runs of CMD, as well as affect any other program subsequently started.



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


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Matthew Ngaha
>
> Have you added shebang lines to those scripts yet?
>
yes i added them. i think the problem is at the start where it asks me to:

You should ensure the launcher is on your PATH - depending on how it was
installed it may already be there, but check just in case it is not.

>From a command-prompt, execute the following command:
py
You should find that the latest version of Python 2.x you have installed is
started ..

py is not recognized and and it said "depending on how it was
installed". the problem is it didnt allow me to select a path when
installing. it just automatically did everything. i have searched my
PC for python launcher but it cant find it, so i dont know where its
location is. i see it in "control panel" to uninstall a program but
right clicking it doesnt give me an option to see its containing
folder
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Dave Angel

On 01/24/2013 01:26 PM, Matthew Ngaha wrote:

yes the 2nd option (standalone pylauncher) sounds more convienient for
me. i just have to try and comprehend all the instructions given..
hopefully ill get there in the end


i managed to install the laucher. on the site when i click the correct
launcher 32bit, i chose "run" and it automatically installed rather
than asking me or allowing me to install it in cmd like their
directions showed. my python 3 files still open but python 2 files
still return errors like: print "string" is invalid syntax which tells
me its still using python 3 to open these files. when i right click
.py files a new option has been added to "open with" which is open
with Python Launcher for Windows. Even when i do this my python 2
files won't open


Have you added shebang lines to those scripts yet?



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


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Matthew Ngaha
> yes the 2nd option (standalone pylauncher) sounds more convienient for
> me. i just have to try and comprehend all the instructions given..
> hopefully ill get there in the end

i managed to install the laucher. on the site when i click the correct
launcher 32bit, i chose "run" and it automatically installed rather
than asking me or allowing me to install it in cmd like their
directions showed. my python 3 files still open but python 2 files
still return errors like: print "string" is invalid syntax which tells
me its still using python 3 to open these files. when i right click
.py files a new option has been added to "open with" which is open
with Python Launcher for Windows. Even when i do this my python 2
files won't open
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Matthew Ngaha
>
> You don't have to uninstall 3.1 but you would have to install all the
> downloaded modules or packages that you have in your 3.1 site packages
> folder to the 3.3 site packages folder.  Maybe it's easier to simply grab
> the standalone pylauncher as I suggested earlier.  Only you know what is the
> path of least resistance.
>
yes the 2nd option (standalone pylauncher) sounds more convienient for
me. i just have to try and comprehend all the instructions given..
hopefully ill get there in the end
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Mark Lawrence

On 24/01/2013 16:11, Matthew Ngaha wrote:


there was a lot of reading in the previous links, i got a bit lost as
i didnt recognize a lot of the words they were using. If i install
Pyhon 3.3 do i need to uninstall my current python 3.1 and reinstall
all the downloaded modules/packages i installed?



You don't have to uninstall 3.1 but you would have to install all the 
downloaded modules or packages that you have in your 3.1 site packages 
folder to the 3.3 site packages folder.  Maybe it's easier to simply 
grab the standalone pylauncher as I suggested earlier.  Only you know 
what is the path of least resistance.


--
Cheers.

Mark Lawrence

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


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Dave Angel

On 01/24/2013 11:11 AM, Matthew Ngaha wrote:


Python 3.3 for Windows comes with a "launcher", which will approximate (for
Python only) what Unix and Linux users have had for years for any scripting
language.  You can get it separately, as Mark Lawrence has said, but maybe
it's time to bring your 3.x current.


there was a lot of reading in the previous links, i got a bit lost as
i didnt recognize a lot of the words they were using. If i install
Pyhon 3.3 do i need to uninstall my current python 3.1 and reinstall
all the downloaded modules/packages i installed?


I don't really know, so all the rest of this message is a guess.  My 
guess is that 3.1 and 3.3 can coexist, but that you'd need to reinstall 
the modules/packages that you're using, and hope that they all can 
handle 3.3


When upgrading a minor upgrade (eg. from 3.1.1 to 3.1.2), I believe it'd 
go in the same place, and not require reinstalling the packages.




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


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Matthew Ngaha
>
> Python 3.3 for Windows comes with a "launcher", which will approximate (for
> Python only) what Unix and Linux users have had for years for any scripting
> language.  You can get it separately, as Mark Lawrence has said, but maybe
> it's time to bring your 3.x current.
>
there was a lot of reading in the previous links, i got a bit lost as
i didnt recognize a lot of the words they were using. If i install
Pyhon 3.3 do i need to uninstall my current python 3.1 and reinstall
all the downloaded modules/packages i installed?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Dave Angel

On 01/24/2013 08:46 AM, Matthew Ngaha wrote:

hi guys i am a python 3.1.1. user but really need to use python 2 to
be able to use certain libraries and frameworks. i have installed
python 2.7 but they cant run together as all .py and .pyw files are
opened with python 3. i can open simple python 2 files by right
clicking and finding pythons 2's python.exe, but these only works for
simple files with no imports because the import i think seems to look
in the python 3 directory and can't find the packages.

i have checked stackoverflow for answers but i get lost in all the
terms and keywords they use to solve this. is there a simple
straightfoward way to fix this that is easy for someone like me to
understand or follow?

thanks. i use windows vista



Python 3.3 for Windows comes with a "launcher", which will approximate 
(for Python only) what Unix and Linux users have had for years for any 
scripting language.  You can get it separately, as Mark Lawrence has 
said, but maybe it's time to bring your 3.x current.



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


Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Mark Lawrence

On 24/01/2013 13:46, Matthew Ngaha wrote:

hi guys i am a python 3.1.1. user but really need to use python 2 to
be able to use certain libraries and frameworks. i have installed
python 2.7 but they cant run together as all .py and .pyw files are
opened with python 3. i can open simple python 2 files by right
clicking and finding pythons 2's python.exe, but these only works for
simple files with no imports because the import i think seems to look
in the python 3 directory and can't find the packages.

i have checked stackoverflow for answers but i get lost in all the
terms and keywords they use to solve this. is there a simple
straightfoward way to fix this that is easy for someone like me to
understand or follow?

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



See http://www.python.org/dev/peps/pep-0397/ which leads to 
https://bitbucket.org/vinay.sajip/pylauncher


--
Cheers.

Mark Lawrence

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


Re: [Tutor] String formatting expression "g" conversion type case.

2013-01-24 Thread Barnaby Scott

On 24/01/2013 13:29, Krupkina Lesya Olegovna wrote:

Hello!
I’m newcomer to Python and I’m on documentation reading stage and trying some 
of examples.
I’m using Win7 x64 OS and Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC 
v.1500 64 bit (AMD64)].
I try to understand how string format expression (%)works. Everything is almost 
clear but except one case: using ofg(G) conversion type and # flag.
Let’s take a look at documentation here:
http://docs.python.org/release/2.7.3/library/stdtypes.html#sequence-types-str-unicode-list-tuple-bytearray-buffer-xrange
Document declares for g(G) conversion type in case of using # flag (4th note):
“The precision determines the number of significant digits before and after the 
decimal point and defaults to 6”.

I have noticed behavior that does not meet documentation declaration and looks 
like a bug in case when using g(G) conversion type with # flag
with  omitted  precision  and  zero integer part of the decimal. Could
someone, please comment the case it is a bug or right use case result? If it is 
correct, please explain why.

Steps to reproduce the case:

1.Start python interactive mode
2.Enter string with g(G) conversion type and using #flag like this: "%#g"%0.3 – 
precision parameter is omitted and integer part of the decimal is zero.
3.Watch the output results

Actual result:

Python outputs decimal as declared as but with more significant digits than 
default value of 6 - if integer part of the decimal is equal to zero.

"%#g"%0.3

'0.30'

"%#G"%0.3

'0.30'

"%#G"%0.004

'0.0040'




Expected results:
As declared in documentation – there will be 6 significant digits before and 
after decimal point by default.

Thanks,
Regards, Lesya.

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




My experience is that things that look odd at first sight are VERY 
rarely bugs - especially in something as mature as Python 2.7.


Maybe the documentation could be slightly clearer, but I see it as 
saying the following:


'#g' and '#G' both convert to exponential format (with some exceptions) 
with a default precision of 6 *significant figures*. It is certainly 
talking about significant figures, not decimal places. So your final 
example may look odd, but it really is doing what it says - there are 6 
s.f. shown, and it has not converted to exponential form because the 
exponent would not be less than -4.


With significant digits before the decimal point, it appears to convert 
to exponential form only if the number of them exceeds the precision.


Best

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


Re: [Tutor] String formatting expression "g" conversion type case.

2013-01-24 Thread Peter Otten
Krupkina Lesya Olegovna wrote:

> Python outputs decimal as declared as but with more significant digits
> than default value of 6 - if integer part of the decimal is equal to zero.
 "%#g"%0.3
> '0.30'

In this context "significant digits" are the first non-zero digit and any 
digits (including zero) that follow it.

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


[Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Matthew Ngaha
hi guys i am a python 3.1.1. user but really need to use python 2 to
be able to use certain libraries and frameworks. i have installed
python 2.7 but they cant run together as all .py and .pyw files are
opened with python 3. i can open simple python 2 files by right
clicking and finding pythons 2's python.exe, but these only works for
simple files with no imports because the import i think seems to look
in the python 3 directory and can't find the packages.

i have checked stackoverflow for answers but i get lost in all the
terms and keywords they use to solve this. is there a simple
straightfoward way to fix this that is easy for someone like me to
understand or follow?

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


[Tutor] String formatting expression "g" conversion type case.

2013-01-24 Thread Krupkina Lesya Olegovna
Hello!
I’m newcomer to Python and I’m on documentation reading stage and trying some 
of examples.
I’m using Win7 x64 OS and Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC 
v.1500 64 bit (AMD64)].
I try to understand how string format expression (%)works. Everything is almost 
clear but except one case: using ofg(G) conversion type and # flag.
Let’s take a look at documentation here:
http://docs.python.org/release/2.7.3/library/stdtypes.html#sequence-types-str-unicode-list-tuple-bytearray-buffer-xrange
Document declares for g(G) conversion type in case of using # flag (4th note):
“The precision determines the number of significant digits before and after the 
decimal point and defaults to 6”.

I have noticed behavior that does not meet documentation declaration and looks 
like a bug in case when using g(G) conversion type with # flag
with  omitted  precision  and  zero integer part of the decimal. Could
someone, please comment the case it is a bug or right use case result? If it is 
correct, please explain why.

Steps to reproduce the case:

1.Start python interactive mode
2.Enter string with g(G) conversion type and using #flag like this: "%#g"%0.3 – 
precision parameter is omitted and integer part of the decimal is zero.
3.Watch the output results

Actual result:

Python outputs decimal as declared as but with more significant digits than 
default value of 6 - if integer part of the decimal is equal to zero.
>>> "%#g"%0.3
'0.30'
>>> "%#G"%0.3
'0.30'
>>> "%#G"%0.004
'0.0040'
>>>

Expected results:
As declared in documentation – there will be 6 significant digits before and 
after decimal point by default.

Thanks,
Regards, Lesya.

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


Re: [Tutor] Small personal project to fill CDs/DVDs...

2013-01-24 Thread Alan Gauld

On 24/01/13 05:32, SCS Barry wrote:

Need to fill some DVDs.


Sounds like an interesting project.
Most of what you need is in the os module.


create a python application that works on many different platforms, but
can work without problems on Windows (ALL), Linux (ALL) using
Gtk/xfce/other (need suggestions), and Unix (really need suggestions).


Tkinter or even EasyGUI should work fine for this and is portable.


Full solution for me will accept start directory and -c or -d parm


How do you specify the size? CD Roms come in 650M, 800M and 900M 
variants (probably more!) Same with DVDs, single sided v double etc...



is not passed, there will be a "browse" interface to choose the
directory to start from (will determine OS from os call) and a media
drop-down selection. Will require a standard GUI environment like
windows/gtk/"something".


Any GUI framework will do that.


The main process will create a list of fully-qualified file names, file
sizes.


listdir or os.walk will do that combined with the file property 
functions to get size.



Then, it will build a grouped list of files, filling media as
effectively as possible.


Thats just standard programming. Wikipedia might have saome best-fit 
algorithms that can help.



Last, it will print on screen the lists of FQFNs and filesizes that will
go on each backup disk.


Again straight programming.

The trickiest bit might be the actual writing to the media. I'm not sure 
how you do that portably... More research there I suspect. Maybe the OS 
will do it transparently if you are lucky.


--
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