Desktop/File management support on MS Windows

R

riklaunim

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

Hamish McKenzie

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
 
S

Steven D'Aprano

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

Robert Kern

Hamish said:
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

r

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

Robert Kern

r said:
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.

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

r

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.

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

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

Hamish McKenzie

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




-----Original Message-----
From: python-list-bounces+hamish=valvesoftware.com@python.org [mailto:python-list-bounces+hamish=valvesoftware.com@python.org] On Behalf Of r
Sent: Friday, January 02, 2009 12:12 PM
To: (e-mail address removed)
Subject: Re: type conversion

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.

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

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

Steven D'Aprano

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

r

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 :)
 
L

Lie

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,299
Messages
2,571,546
Members
48,307
Latest member
LilaSumsum

Latest Threads

Top