Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Desktop/File management support on MS Windows

0 views
Skip to first unread message

rikl...@gmail.com

unread,
Dec 31, 2008, 12:08:46 PM12/31/08
to
Are there any Python libraries that can trash files (move to Trash,
not delete) or for example return a list of applications that can open
given file? I can't find anything related to this for Windows.

r

unread,
Dec 31, 2008, 12:23:15 PM12/31/08
to
On Dec 31, 11:08 am, "riklau...@gmail.com" <riklau...@gmail.com>
wrote:

> Are there any Python libraries that can trash files (move to Trash,
> not delete) or for example return a list of applications that can open
> given file? I can't find anything related to this for Windows.

try pywin32
http://python.net/crew/mhammond/win32/Downloads.html

Hamish McKenzie

unread,
Dec 31, 2008, 3:35:20 PM12/31/08
to pytho...@python.org
sometimes I want to be able to initialize an instance with a variety of different data types.

as an obvious example I might want to initialize a 4x4 matrix with either 16 floats, a list/tuple or 16 floats, another matrix or a quaternion.

is there any other way to do it other than putting case statements in the __init__ method of the class, or having a Matrix.FromQuaternion( quat )?

thx

Steven D'Aprano

unread,
Dec 31, 2008, 5:26:45 PM12/31/08
to
On Wed, 31 Dec 2008 12:35:20 -0800, Hamish McKenzie wrote:

> sometimes I want to be able to initialize an instance with a variety of
> different data types.

Type conversion is a bit of a misleading subject line. You're not really
converting different types, just initialising from different types.


> as an obvious example I might want to initialize a 4x4 matrix with
> either 16 floats, a list/tuple or 16 floats, another matrix or a
> quaternion.
>
> is there any other way to do it other than putting case statements in
> the __init__ method of the class, or having a Matrix.FromQuaternion(
> quat )?


You could have an external function qtom:

def qtom(quaternion):
a, b, c, d = quaternion
return Matrix([
a, 0, 0, 0,
0, b, 0, 0,
0, 0, c, 0,
0, 0, 0, d])


But the first two solutions seem reasonable to me, except of course
Python doesn't have a case statement you have to use an if...elseif block.


--
Steven

Thorsten Kampe

unread,
Jan 1, 2009, 11:50:39 AM1/1/09
to
* rikl...@gmail.com (Wed, 31 Dec 2008 09:08:46 -0800 (PST))>
> Are there any Python libraries that can trash files (move to Trash,
> not delete) or for example return a list of applications that can open
> given file? I can't find anything related to this for Windows.

http://timgolden.me.uk/python/winshell.html

Thorsten

Robert Kern

unread,
Jan 1, 2009, 5:40:32 PM1/1/09
to pytho...@python.org
Hamish McKenzie wrote:
> sometimes I want to be able to initialize an instance with a variety of different data types.
>
> as an obvious example I might want to initialize a 4x4 matrix with either 16 floats, a list/tuple or 16 floats, another matrix or a quaternion.
>
> is there any other way to do it other than putting case statements in the __init__ method of the class, or having a Matrix.FromQuaternion( quat )?

I recommend keeping the __init__() as dumb as possible. Ideally, it should just
assign to attributes. I would add a from<foo>() classmethod for each <foo> that
I wanted to support. If I really wanted an all-singing, all-dancing
initialization method, I would add another classmethod that would just dispatch
to the appropriate type-specific classmethod. I prefer classmethods to plain
functions because I can subclass.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

r

unread,
Jan 2, 2009, 2:54:36 AM1/2/09
to

Why are you busting into this thread? why have you not created your
own thread. Someone asked a question about recycle bin access and you
come in here, bust down the door and ask a completely off topic
question, which is OK if you start a new thread of your own. And the
most insane part to all of this, is that Steven just plays right
along?!?!? Come on Stevie, you know better than this!

PS (To OP) mark hammonds win32 package will not do what you ask, sorry

Robert Kern

unread,
Jan 2, 2009, 2:46:31 PM1/2/09
to pytho...@python.org
r wrote:
> On Jan 1, 4:40 pm, Robert Kern <robert.k...@gmail.com> wrote:
>> Hamish McKenzie wrote:
>>> sometimes I want to be able to initialize an instance with a variety of different data types.
>>> as an obvious example I might want to initialize a 4x4 matrix with either 16 floats, a list/tuple or 16 floats, another matrix or a quaternion.
>>> is there any other way to do it other than putting case statements in the __init__ method of the class, or having a Matrix.FromQuaternion( quat )?
>> I recommend keeping the __init__() as dumb as possible. Ideally, it should just
>> assign to attributes. I would add a from<foo>() classmethod for each <foo> that
>> I wanted to support. If I really wanted an all-singing, all-dancing
>> initialization method, I would add another classmethod that would just dispatch
>> to the appropriate type-specific classmethod. I prefer classmethods to plain
>> functions because I can subclass.
>>
>> --
>> Robert Kern
>>
>> "I have come to believe that the whole world is an enigma, a harmless enigma
>> that is made terrible by our own mad attempt to interpret it as though it had
>> an underlying truth."
>> -- Umberto Eco
>
> Why are you busting into this thread?

Are you talking to me, or Hamish, who (presumably unintentionally) responded to
a message instead of making a new thread?

If you want to suggest that one should have more care about starting new
threads, that's fine, but please do not jump to the conclusion that there is
malintent. And don't chastise people for not being as rude as you.

r

unread,
Jan 2, 2009, 3:11:34 PM1/2/09
to

I am not so much chastising Hamish as i am Steven, Steven knows better
than this BS, and has preached to so many people about off topic post
that my ears are bleeding from his incessant rambling about it. Now,
he goes and does what he complains about soooo much. I'm just calling
him on it thats all. I can't speak for the other responders because i
know of none of them.

Hamish McKenzie

unread,
Jan 2, 2009, 6:49:25 PM1/2/09
to r, pytho...@python.org
I actually have no idea what ur talking about... aren't conversations threaded by subject?

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

Christian Heimes

unread,
Jan 2, 2009, 7:16:17 PM1/2/09
to pytho...@python.org
Hamish McKenzie schrieb:

> I actually have no idea what ur talking about... aren't conversations threaded by subject?

Nope, they are threaded by message id. The subject is used as fallback only.

Christian

Steven D'Aprano

unread,
Jan 2, 2009, 8:46:37 PM1/2/09
to
On Fri, 02 Jan 2009 15:49:25 -0800, Hamish McKenzie wrote:

> I actually have no idea what ur talking about... aren't conversations
> threaded by subject?

Not usually. When you hit Reply to a post, your post gets a hidden header
line that says "I'm a reply to post #12345" (whatever post number it is).
Just because you change the subject line doesn't change that.

Most newsreader programs thread by that header, not the subject.
Consequently most people who view posts in thread order will see:


Subject X Y Z
+-- Re: Subject X Y Z
+-- Re: Subject X Y Z
+-- Re: Subject X Y Z
+-- Re: Subject X Y Z
+-- Hello I'm changing the subject line
+-- Re: Hello I'm changing the subject line
+-- Re: Subject X Y Z
+-- Re: Subject X Y Z

This has the serious disadvantages that:

(1) It annoys people who do threading; and
(2) If people are ignoring a thread, they won't even see your post even
though you have changed the subject line.

It is considered rude to hijack a thread for a completely new subject,
although it is acceptable to change the subject line if the thread
gradually evolves to a new discussion:

Subject X Y Z
+-- Re: Subject X Y Z
+-- Re: Subject X Y Z
+-- Subject A B C [was Re: Subject X Y Z]
+-- Re: Subject A B C [was Re: Subject X Y Z]

Don't mistake the above for off-topic posting, which is something
completely different, nor for cross-posting, which is different again.
Off-topic posts are ones that don't have anything to do with the news
group they are sent to, e.g. a message about Ruby sent to a Python list.
It is barely acceptable to occasionally post brief off-topic messages
that are particularly amusing or important if you label them such with
[OT] or [off-topic] in the subject line.

Cross-posting is sending a single message to more than one newsgroup. If
you absolutely must cross-post, you should always set the Followup-To
header to *one* newsgroup. If you don't know how to set followups, then
don't cross-post.


--
Steven

r

unread,
Jan 2, 2009, 10:23:00 PM1/2/09
to
On Jan 2, 7:46 pm, Steven D'Aprano <st...@REMOVE-THIS-
cybersource.com.au> wrote:
...incessant rambling about a news reader , 101 excuses for butting
into a thread
[snip]

Throw your newsreader in the garbage and use Google groups, less
headache, more filling! No need to worry about
"hidden headers" And you may even get a star or 2 :)

> If people are ignoring a thread, they won't even see your post even though you have changed the subject line.

Yea NO $#Y, that makes a lot of sense, if i am ignoring something i
course i will not see it!
OK, Steven so you did not go off topic you simply high-jacked this
thread. I get it now :)

Lie

unread,
Jan 10, 2009, 6:07:55 PM1/10/09
to
On Jan 3, 10:23 am, r <rt8...@gmail.com> wrote:

> On Jan 2, 7:46 pm, Steven D'Aprano <st...@REMOVE-THIS-cybersource.com.au> wrote:
>
> ...incessant rambling about a news reader , 101 excuses for butting
> into a thread
> [snip]

... public display of ignorance of newsgroup ethics, 101 excuses for
not knowing proper terminologies.

> Throw your newsreader in the garbage and use Google groups, less
> headache, more filling!
>

Really? I found Google Groups lacking for many thing. Google Groups'
only advantage is being browser-based.

> No need to worry about
> "hidden headers" And you may even get a star or 2 :)

Don't you realize that even Google Groups handles those hidden headers
too. And that the hidden headers aren't really hidden, even in Google
Groups.

> > If people are ignoring a thread, they won't even see your post even though you have changed the subject line.
>
> Yea NO $#Y, that makes a lot of sense, if i am ignoring something i
> course i will not see it!
> OK, Steven so you did not go off topic you simply high-jacked this
> thread. I get it now :)

"Yea NO $#Y", that doesn't make sense. Yea or NO? or $#Y?

0 new messages