how to call back a method ?

2014-08-03 Thread elearn

I want to call back a function which is the method of a class .

def callback(self.do,x):
return(self.do(x))

That is what i want to write,when i input

def callback(self.do,x):

error message:


  File "", line 1
def callback(self.do,x):
 ^
SyntaxError: invalid syntax


`do` is a method in my class ,how to write the code?
--
https://mail.python.org/mailman/listinfo/python-list


How to delete letters automatically with imaplib?

2014-08-06 Thread elearn
I have a gmail account 'x...@gmail.com' which subscripted python 
maillist. To take part in python discussion is the only target for my 
x...@gmail.com. There are so many emails in my x...@gmail.com,it is a good 
idea for me to auto delete all emails whose body contain no . I write 
some codes to do the job.


|import  imaplib
user="xxx"
password="yy"
con=imaplib.IMAP4_SSL('imap.gmail.com')
con.login(user,password)
con.select('INBOX')
status,  data=  con.search(None,  "ALL")
print(len(data[0].split()))
48
typ,  data=  con.search(None,  'Body',  '"x...@gmail.com"')

 data

[b'1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 32 33 34 35 36 37 44']

len(data[0].split())
36|

How can i delete 48-36=12 letters?

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


Re: How to delete letters automatically with imaplib?

2014-08-06 Thread elearn

and how to write the delete command with imaplib?
On 8/6/2014 5:14 PM, Ben Finney wrote:

elearn  writes:


status,  data=  con.search(None,  "ALL")
print(len(data[0].split()))
48
typ,  data=  con.search(None,  'Body',  '"x...@gmail.com"')

  data

[b'1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
  32 33 34 35 36 37 44']

len(data[0].split())
36

How can i delete 48-36=12 letters?

Set operations are designed for this::

 # Construct a set of all message numbers.
 status, data = con.search(None, "ALL")
 ids_of_all_messages = set(data[0].split())

 # Construct a set of messages mentioning the address.
 status, data = con.search(None, 'Body', '"x...@gmail.com"')
 ids_of_messages_containing_address = set(data[0].split())

 # Get the messages to delete.
 ids_of_messages_to_delete = (
 ids_of_all_messages - ids_of_messages_containing_address)



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


why i can not delete my email with imaplib?

2014-08-06 Thread elearn
I have a gmail account 'x...@gmail.com' which subscripted python 
maillist. I want to delete any emails which is sent to 
python-list@python.org .


|import  imaplib
user="xxx"
password="yy"
con=imaplib.IMAP4_SSL('imap.gmail.com')
con.login(user,password)
con.select('[Gmail]/&YkBnCZCuTvY-')
type,  data=  con.search(None,  "All")
type1,  data1=  con.search(None,  '(TO "python-list@python.org")')
ids_all=  set(data[0].split())
ids1=set(data1[0].split())

ids_deleted=set(ids_all-ids1)

for  numin  ids_deleted:
   con.store(num,  '+FLAGS',  '\\Deleted')


con.expunge()|

When i open my gmail with thunderbird ,the emails which are sent to 
python-list@python.org are still in my gmail,Why i can't delete them?


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


more simple to split the string?

2014-08-07 Thread elearn

str='(\\HasNoChildren \\Junk) "/" "[Gmail]/&V4NXPpCuTvY-"'
x=str.split(' "')
[i.replace('"','') for i in x]
['(\\HasNoChildren \\Junk)', '/', '[Gmail]/&V4NXPpCuTvY-']

x.strip(" ") will create four parts.

is there more simple to do that ?
--
https://mail.python.org/mailman/listinfo/python-list


How to get mac address of bluetooth with python in win7?

2014-08-07 Thread elearn

How to get  mac address of bluetooth  with python in win7?
--
https://mail.python.org/mailman/listinfo/python-list