Re: Unshelving the data?

2011-06-02 Thread Uncle Ben
On Jun 2, 6:46 am, Adam Tauno Williams  wrote:
> On Wed, 2011-06-01 at 19:49 -0700, Uncle Ben wrote:
> > Shelving is a wonderfully simple way to get keyed access to a store of
> > items. I'd like to maintain this cache though.
>
> +1
>
> > Is there any way to remove a shelved key once it is hashed into the
> > system?  I could do it manually by removing the value and erasing the
> > key in the directory list. But is there a more elegant way?
>
> del shelve[key]
>
> > Or should I to go the full database route?  It is not a lage
> > application.
>
> Stick with shelves.  Much simpler.

Thanks.  And Chris, thanks for showing me 'pyco'. I had looked in six
thick books and had not found anything on removing keys.

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


mystery string code - help!

2011-04-20 Thread Uncle Ben
I found this in one of the online cookbooks:

#Raghunath Reddy Peesari 6 years, 3 months ago  # | flag
#There is more simple way. ###

a = 'abcdefghi'
a = a[::-1]

print a

>>> 'ihgfedcba'

As a newbie Pythoner, I understand [] -1]
but would some tell me how '::' does its magic?

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


Re: mystery string code - help!

2011-04-20 Thread Uncle Ben
On Apr 20, 1:01 pm, Dan M  wrote:
> > As a newbie Pythoner, I understand [] -1] but would some tell me how
> > '::' does its magic?
>
> > Uncle Ben
>
> The -1 is the "stride" or "step" argument. It's described 
> athttp://docs.python.org/release/2.3.5/whatsnew/section-slices.html
>
> Dan

Very helpful!

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


IDLE lost from Windows menu !

2011-04-28 Thread Uncle Ben
I have lost the convenient feature that to edit a .py file I could
right-click on the file name and reach the menu item "Edit with IDLE".

The workaround is not hard, but it wouild be nice to get this feature
back.

It happened when I was mungeing around and downloaded Python 2.3.3 in
addition to Python 2.71, and got into trojuble uintil I discovered
that I was involuntarily RUNNING the older version.  So I cleaned it
out, but still I have this aftermath.

Is there a Windows guru out there who can tell be how to add to the
right-click menu clicking on myfile.py?

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


Re: IDLE lost from Windows menu !

2011-04-28 Thread Uncle Ben
On Apr 28, 12:28 pm, Uncle Ben  wrote:
> I have lost the convenient feature that to edit a .py file I could
> right-click on the file name and reach the menu item "Edit with IDLE".
>
> The workaround is not hard, but it wouild be nice to get this feature
> back.
>
> It happened when I was mungeing around and downloaded Python 2.3.3 in
> addition to Python 2.7.1, and got into trouble until I discovered
> that I was involuntarily RUNNING the older version.  So I cleaned it
> out, but still I have this aftermath.
>
> Is there a Windows guru out there who can tell be how to add to the
> right-click menu clicking on myfile.py?
>
> Uncle Ben

It was suggested to me privately that I search for
HKEY_CLASSES_ROOT\*\shell,
right_click on "shell",
create a new key called "EDIT with IDLE"
and another called "command python.exe %1"

Problem:
  Searching on the HKEY group as above yields no "shell".

Did I not do it right, or is there another way?

(I would think that that command would execute my file, not edit it.
But maybe I will be surprised.)

(I am running Windows 7, 64-bit.)

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


Re: IDLE lost from Windows menu !

2011-04-28 Thread Uncle Ben
On Apr 28, 3:29 pm, MRAB  wrote:
> On 28/04/2011 20:11, Uncle Ben wrote:
>
>
>
> > On Apr 28, 12:28 pm, Uncle Ben  wrote:
> >> I have lost the convenient feature that to edit a .py file I could
> >> right-click on the file name and reach the menu item "Edit with IDLE".
>
> >> The workaround is not hard, but it wouild be nice to get this feature
> >> back.
>
> >> It happened when I was mungeing around and downloaded Python 2.3.3 in
> >> addition to Python 2.7.1, and got into trouble until I discovered
> >> that I was involuntarily RUNNING the older version.  So I cleaned it
> >> out, but still I have this aftermath.
>
> >> Is there a Windows guru out there who can tell be how to add to the
> >> right-click menu clicking on myfile.py?
>
> >> Uncle Ben
>
> > It was suggested to me privately that I search for
> > HKEY_CLASSES_ROOT\*\shell,
> > right_click on "shell",
> > create a new key called "EDIT with IDLE"
> > and another called "command python.exe %1"
>
> > Problem:
> >    Searching on the HKEY group as above yields no "shell".
>
> > Did I not do it right, or is there another way?
>
> > (I would think that that command would execute my file, not edit it.
> > But maybe I will be surprised.)
>
> > (I am running Windows 7, 64-bit.)
>
> Probably the simplest solution would be to install the appropriate
> version of Python again.- Hide quoted text -
>
> - Show quoted text -

Tried that.  No change.  Strange things are happening!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE lost from Windows menu !

2011-04-28 Thread Uncle Ben
On Apr 28, 3:11 pm, Uncle Ben  wrote:
> On Apr 28, 12:28 pm, Uncle Ben  wrote:
>
> > I have lost the convenient feature that to edit a .py file I could
> > right-click on the file name and reach the menu item "Edit with IDLE".
>
> > The workaround is not hard, but it wouild be nice to get this feature
> > back.
>
> > It happened when I was mungeing around and downloaded Python 2.3.3 in
> > addition to Python 2.7.1, and got into trouble until I discovered
> > that I was involuntarily RUNNING the older version.  So I cleaned it
> > out, but still I have this aftermath.
>
> > Is there a Windows guru out there who can tell be how to add to the
> > right-click menu clicking on myfile.py?
>
> > Uncle Ben
>
> It was suggested to me privately that I search for
> HKEY_CLASSES_ROOT\*\shell,
> right_click on "shell",
> create a new key called "EDIT with IDLE"
> and another called "command python.exe %1"
>
> Problem:
>   Searching on the HKEY group as above yields no "shell".
>
> Did I not do it right, or is there another way?
>
> (I would think that that command would execute my file, not edit it.
> But maybe I will be surprised.)
>
> (I am running Windows 7, 64-bit.)
>
> Uncle Ben

Thanks to all for good help.  I finally got what I need by altering
the original advice (A.W.) slightly.

The key to edit was "HKCR/Applications/python.exe/shell",
the item is put into the menu in a sub-key labelled "Edit with IDLE",
and the command sub-sub-key that works for me is "idle.bat %1"

I will keep Andrew Berg's note and use it when I encounter .pyw files.

Python's the ninth language I've had to learn. And I love it.

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


Re: IDLE lost from Windows menu !

2011-04-28 Thread Uncle Ben
On Apr 28, 5:17 pm, Andrew Berg  wrote:
> On 2011.04.28 02:11 PM, Uncle Ben wrote:> It was suggested to me privately 
> that I search for
> > HKEY_CLASSES_ROOT\*\shell,
> > right_click on "shell",
> > create a new key called "EDIT with IDLE"
> > and another called "command python.exe %1"
>
> The key you're looking for is HKCR\Python.File\shell. Add a subkey
> called Edit with IDLE. Create a subkey in there called command. Inside
> HKCR\Python.File\shell\Edit with IDLE\command, modify the default value
> to "C:\Python32\pythonw.exe" "C:\Python32\Lib\idlelib\idle.pyw" -e "%1"
> (changing the paths if necessary). Do the same with
> HKCR\Python.NoConFile\shell to get the command for .pyw files.

Thanks to all for good help.  I finally got what I need by altering
the original advice (A.T.) slightly.

The key to edit was "HKCR/Applications/python.exe/shell",
the item is put into the menu in a sub-key labelled "Edit with IDLE",
and the command sub-sub-key that works for me is "idle.bat %1"

I will keep Andrew Berg's note and use it when I encounter .pyw
files.

Python's the ninth language I've had to learn. And I love it.

Uncle Ben

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


Puzzled by list-appending behavior

2011-05-25 Thread Uncle Ben
In playing with lists of lists, I found the following:

(In 3.1, but the same happens also in 2.7)

list = [1,2,3]
list.append ( [4,5,6] )
x = list
x   ->
[1,2,3,[4,5,6]]
as expected.

But the shortcut fails:

list=[1,2,3]
x = list.append( [4,5,6] )
x   ->
   nothing

Can someone explain this to me?

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


Re: Puzzled by list-appending behavior

2011-05-26 Thread Uncle Ben
On May 26, 12:46 am, Uncle Ben  wrote:
> In playing with lists of lists, I found the following:
>
> (In 3.1, but the same happens also in 2.7)
>
> list = [1,2,3]
> list.append ( [4,5,6] )
> x = list
> x   ->
>     [1,2,3,[4,5,6]]
> as expected.
>
> But the shortcut fails:
>
> list=[1,2,3]
> x = list.append( [4,5,6] )
> x   ->
>    nothing
>
> Can someone explain this to me?
>
> Uncle Ben

Thank you all.  It is wonderful to have this community as a resource.

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


Re: Beginner needs advice

2011-05-28 Thread Uncle Ben
On May 27, 5:33 pm, Ethan Furman  wrote:
> Lew Schwartz wrote:
> > So, if I read between the lines correctly, you recommend Python 3? Does
> > the windows version install with a development environment?
>
> Dabo, last I checked, uses wxPython, which uses wxWidgets (sp?), which
> is not yet ported to Python 3.  So if you got that route you'll need to
> stay with 2.7.
>
> ~Ethan~

Just this past Tuesday, I blindly downloaded 3.1 and found that at the
level I am workloing, all it took to get my 2.7 code to run was to put
parens around the print arguments and double the slashes in integer
division. I didn't even use the 2to3 automation.

But I am a noob to Python, which is my tenth computer language.  Maybe
when I get more ambitious I will find more serious differences.
-- 
http://mail.python.org/mailman/listinfo/python-list


Unshelving the data?

2011-06-01 Thread Uncle Ben
Shelving is a wonderfully simple way to get keyed access to a store of
items. I'd like to maintain this cache though.

Is there any way to remove a shelved key once it is hashed into the
system?  I could do it manually by removing the value and erasing the
key in the directory list. But is there a more elegant way?

Or should I to go the full database route?  It is not a lage
application.

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