Re: how to make return(self.res) not to output the content of list ?

2014-09-24 Thread luofeiyu
You could write a separate method that just calls self.grow() and does not return the result, and call that method instead from the interactive interpreter. how can i change your meaning into python code? There is my code structure. class status(): def grow(self): self.res= a

Re: how to make return(self.res) not to output the content of list ?

2014-09-24 Thread luofeiyu
`sys.displayhook = lambda obj: None ` will block everything to be displayed on the interactive python console . i rewrite my code as the following : import sqlite3,os,jinja2 db = r'data.sqlite' con = sqlite3.connect(db) cur = con.cursor() class status(): def __init__(): import sy

how to make return(self.res) not to output the content of list ?

2014-09-24 Thread luofeiyu
There is a file named analyse.py in the D:\Python34\Lib\site-packages. import sqlite3,os,jinja2 db = r'F:\workspace\china\data\china.sqlite' con = sqlite3.connect(db) cur = con.cursor() class status(): def grow(self): self.res=cur.execute('select 代码,所属行业,注册资本,雇员人数,管 理人员人数 from prof

why can't open the file with browser?

2014-09-24 Thread luofeiyu
| import webbrowser webbrowser.open('f:\\test.html') why the file f:\\test.html is opened by notepad ,not by my firefox or chrome? | -- https://mail.python.org/mailman/listinfo/python-list

how to display the result in table with jinkoa2 temple?

2014-09-24 Thread luofeiyu
import sqlite3 db=r'F:\workspace\china\data\china.sqlite' con=sqlite3.connect(db) cur=con.cursor() res=cur.execute('select 代码,所属行业,注册资本,雇员人数,管理人员人数 from profile limit 20').fetchall() the result is a list. >>> for row in res: ... print(row) ... ('60', '银行', '187亿', 39340.0, 30.0) ('6000

Re: how to write a html to automatically display the dictionary?

2014-09-23 Thread luofeiyu
how can i create the proper html file with /Jinjia/2 or other temple? Joel Goldstick wrote: Generally, you would use a framework like django or others. -- https://mail.python.org/mailman/listinfo/python-list

how to write a html to automatically display the dictionary?

2014-09-23 Thread luofeiyu
x={'f1':1,'f2':2,'f3':3} how can i create the following html file automatically with python to display x ? f1 f2 f3 1 2 3 -- https://mail.python.org/mailman/listinfo/python-list

sqlite3.OperationalError: near ".": syntax error

2014-09-19 Thread luofeiyu
C:\Users\pengsir>d:\\sqlite3 F:\\workspace\\china\\data\\china.sqlite SQLite version 3.8.5 2014-06-04 14:06:34 Enter ".help" for usage hints. sqlite> .tables balance cash fi_di ipo profile quote capital dividend fund majority profit sqlite>

sqlite3.OperationalError: near ".": syntax error

2014-09-19 Thread luofeiyu
C:\Users\pengsir>sqlite3 F:\\workspace\\china\\data\\china.sqlite SQLite version 3.8.5 2014-06-04 14:06:34 Enter ".help" for usage hints. sqlite> .tables balance cash fi_di ipo profile quote capital dividend fund majority profit sqlite>

Re: the output in reference of descriptor.

2014-08-23 Thread luofeiyu
, owner) return self def foo(self, x): print(x) class C2(object): d = C() | On 8/23/2014 12:10 PM, Ian Kelly wrote: On Thu, Aug 21, 2014 at 7:25 PM, luofeiyu <mailto:elearn2...@gmail.com>> wrote: > >>> c2.d.a > __get__() is called <__main__.C2

Re: why the attribute be deleted still in dir(man)?

2014-08-23 Thread luofeiyu
Think for your remark " You didn't delete the name property, which is part of the class, not the instance." I fix my codes to get the target done. class Person(object): def addProperty(self, attribute): getter = lambda self: self._getProperty(attribute) setter

Re: why the attribute be deleted still in dir(man)?

2014-08-23 Thread luofeiyu
dear ChrisA ,dynamic is python feature, it is to create descriptor in run time , that is the meaning in the codes,and maybe it is a bug: the attribute can be displayed in dir(man) after be deleted. On 8/24/2014 6:56 AM, Chris Angelico wrote: On Sun, Aug 24, 2014 at 8:49 AM, luofeiyu

why the attribute be deleted still in dir(man)?

2014-08-23 Thread luofeiyu
class Person(object): def addProperty(self, attribute): getter = lambda self: self._getProperty(attribute) setter = lambda self, value: self._setProperty(attribute, value) deletter = lambda self:self.delProperty(attribute) setattr(se

Re: Why can not initialize the class?

2014-08-23 Thread luofeiyu
You can copy it into vim,and input :%< ,the codes will be changed into well formatted. -- https://mail.python.org/mailman/listinfo/python-list

Re: Why can not initialize the class?

2014-08-23 Thread luofeiyu
I edit it in the vim in well formatted form,when copied into email ,the format changed ,i don't know why. My email editor is thunderbird, you can try it as i say. I didn't mean to . By posting code with an extra indent, you make it imposible to run by just cutting and pasting. You should alre

Re: Why can not initialize the class?

2014-08-22 Thread luofeiyu
One final version: class Contact(object): def __init__(self, email="haha@haha"): self.email = email def _get_email(self): return self._the_secret_private_email def _set_email(self, value): self.self._the_secret_private_email = value email = property(_get_em

Re: Why can not initialize the class?

2014-08-22 Thread luofeiyu
>>> class Contact(object): ... def __init__(self, first_name=None, last_name=None, ... display_name=None, email="haha@haha"): ... self.first_name = first_name ... self.last_name = last_name ... self.display_name = display_name ... self.email = e

Re: Why can not initialize the class?

2014-08-22 Thread luofeiyu
how to fix the code then? On 8/22/2014 10:36 PM, Larry Martell wrote: The 'in' operator requires an iterable. When you do 'self.email = email' set_email gets called and value is None. -- https://mail.python.org/mailman/listinfo/python-list

Why can not initialize the class?

2014-08-22 Thread luofeiyu
System:win7+python34. class Contact(object): def __init__(self, first_name=None, last_name=None, display_name=None, email=None): self.first_name = first_name self.last_name = last_name self.display_name = display_name

when the method __get__ will be called?

2014-08-22 Thread luofeiyu
class C(object): a = 'abc' def __getattribute__(self, *args, **kwargs): print("__getattribute__() is called") return object.__getattribute__(self, *args, **kwargs) def __getattr__(self, name): print("__getattr__() is called ") return name + " from getatt

Re: what is the difference between name and _name?

2014-08-21 Thread luofeiyu
I fix a mistake in Steven D'Aprano interpretation. class Person(object): def __init__(self, name): self._name = name def getName(self): print('fetch') return self._name def setName(self, value): print('change...') self._name = value

the output in reference of descriptor.

2014-08-21 Thread luofeiyu
class C(object): a = 'abc' def __getattribute__(self, *args, **kwargs): print("__getattribute__() is called") return object.__getattribute__(self, *args, **kwargs) def __getattr__(self, name): print("__getattr__() is called ")

Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread luofeiyu
This man is crazy , he go on to send rubbish to waste our time ,i strongly strongly advise that python maillist administrator kick him off here. On 8/21/2014 9:25 PM, Everything You Need To Know wrote: On Thursday, 21 August 2014 01:06:37 UTC+9:30, Everything You Need To Know wrote: These

Distinguishing attribute name from varible name to make codes clear and definite

2014-08-21 Thread luofeiyu
I feel that self.x and x will be confused in the following codes. class MyDescriptor(object): def __init__(self, x): self.x = x def __get__(self, instance, owner): print('get from descriptor') return self.x def __set__(self, in

Re: what is the difference between name and _name?

2014-08-20 Thread luofeiyu
one more question,how can i get the doc info? class Person(object): def __init__(self, name): self._name = name def getName(self): print('fetch') return self._name def setName(self, value): print('change...') self._name = value def delNa

Re: How can I get the timezone time of a location?

2014-08-20 Thread luofeiyu
it is so sorry to tell you that youtube was banned by chinese government for about 6 years , everyone in china can not open https://www.youtube.com . https://www.youtube.com/watch?v=GBKqRhn0ekM The page describing the video also has a link to the

how to copy emails into local directory?

2014-08-20 Thread luofeiyu
import imaplib,email user="" password="" con=imaplib.IMAP4_SSL('imap.gmail.com') con.login(user,password) con.list() ('OK', [b'(\\HasNoChildren) "/" "INBOX"', b'(\\Noselect \\HasChildren) "/" "[Gma il]"', b'(\\HasNoChildren \\Junk) "/" "[Gmail]/&V4NXPpCuTvY-"', b'(\\HasNoChildr en \\Tras

Re: what is the difference between name and _name?

2014-08-20 Thread luofeiyu
So in this example: class Person(object): def __init__(self, name): self._name = name [...] name = property(getName, setName, delName, "name property docs") (3) name is the public attribute that other classes or functions are permitted to use. problem 1: ther

why no 2to3 in my python?

2014-08-20 Thread luofeiyu
why no 2to3 in my python34,how can i change python 2 into python3? >dir d:\Python34\Scripts Volume in drive D is soft Volume Serial Number is 6F34-9A10 Directory of d:\Python34\Scripts 08/18/2014 09:06 AM . 08/18/2014 09:06 AM .. 07/09/2014 09:01 AM95,

what is the difference between name and _name?

2014-08-20 Thread luofeiyu
When i learn property in python , i was confused by somename and _somename,what is the difference between them? class Person(object): def __init__(self, name): self._name = name def getName(self): print('fetch') return self._name def setName(self, value):

Re: How can I get the timezone time of a location?

2014-08-19 Thread luofeiyu
would you mind sending the video to my mailbox? There is no video in the web when i open it in my firefox. think you in advance. Even with perfect knowledge, you can't always do that. There are points on the globe which use two timezones. :) http://pyvideo.org/video/1765/blame-it-on-caesar-

why i can't get the sourcecode with inspect module?

2014-08-19 Thread luofeiyu
>>> import inspect >>> def changer(x,y): ... return(x+y) ... >>> dir() ['__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__ 'changer', 'inspect'] >>> inspect.getsource(changer) Traceback (most recent call last): File "", line 1, in File "D:\Python34\lib\inspect.py", l

Re: How to look up historical time zones by date and location

2014-08-19 Thread luofeiyu
>>> tz1 >>> repr(tz1) "" >>> x=repr(tz1) >>> x "" >>> import re >>> re.search("LMT.+\s",x).group() 'LMT+8:06:00 ' i got it ,thinks to all my friends . -- https://mail.python.org/mailman/listinfo/python-list

Re: How to look up historical time zones by date and location

2014-08-18 Thread luofeiyu
My dear friends here, all i want is get ` LMT+8:06:00` from the output of tz1 `` Shall we get back to the main point? If you are interested in it ,please say yes or no ,and how to do that ? import pytz,datetime tz1 = pytz.timezone('Asia/Shanghai') tz1 >>> str(tz1) 'Asia/Shanghai' -- ht

Re: How to look up historical time zones by date and location

2014-08-18 Thread luofeiyu
My dear friends here, all i want is get ` |LMT+8:06:00` from the output of tz1 `||`| Shall we get back to the main point? If you are interested in it ,please say yes or no ,and how to do that ? -- https://mail.python.org/mailman/listinfo/python-list

Re: How to look up historical time zones by date and location

2014-08-18 Thread luofeiyu
|I found that it is a concept LMT local mean time can express my meaning. import pytz,datetime tz1 = pytz.timezone('Asia/Shanghai') tz1 str(tz1) 'Asia/Shanghai' | ||tz2 = pytz.timezone('Asia/Urumqi')| tz2 the time difference between shanghai and Urumqi is about 2 hours in the form of LMT.

Re: How to look up historical time zones by date and location

2014-08-17 Thread luofeiyu
http://www.thefreedictionary.com/time+zone time zone Any of the 24 divisions of the Earth's surface used to determine the local time for any given locality. Each zone is roughly 15° of longitude in width, with local variations for economic and political convenience. Local time is one hour ahead

How can I get the timezone time of a location?

2014-08-17 Thread luofeiyu
The land area of China is 60-degree longitude from west to east. According to the demarcation of the world time zoning standard, the land area of China lies between the eastern fifth to ninth time zones, there are 5 time zones in china in fact. Currently, all the places in China have adopted the

timezone argument %z and %Z

2014-08-15 Thread luofeiyu
I feel it is necessary to start a new post to go on the discussion about timezone. In my system : win7+ python3.4 . related official material. https://docs.python.org/3.4/library/datetime.html#strftime-and-strptime %z UTC offset in the form +HHMM or -HHMM (empty string if the the object is na

timedelta problem

2014-08-14 Thread luofeiyu
In the python doc , https://docs.python.org/3.4/library/datetime.html A timedelta object represents a duration, the difference between two dates or times. /class /datetime.timedelta(/days=0/, /seconds=0/, /microseconds=0/,

problem on top-post

2014-08-14 Thread luofeiyu
when i search what top-post mean: *top-post*: n., v. [common] To put the newly-added portion of an email or Usenet response before the quoted part, as opposed to the more logical sequence of quoted portion first with original following. *bottom-post*: v.In a news or mail reply, to put the resp

Re: get the min date from a list

2014-08-14 Thread luofeiyu
_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) >>> time.strptime(t2,"%a, %d %b %Y %H:%M:%S %z") time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) >>> The %z does not work for me, how to adju

Re: get the min date from a list

2014-08-14 Thread luofeiyu
I finished it ,but how to make it into more pythonic way such as min (dates, key = converter) here is my code times=['Sat, 09 Aug 2014 07:36:46 -0700', 'Fri, 8 Aug 2014 22:25:40 -0400', 'Sat, 9 Aug 2014 12:46:43 +1000', 'Sat, 9 Aug 2014 12:50:52 +1000', 'Sat, 9 Aug 2014 02:51:01 + (UTC)', '

how to write a function to make operation as a argument in the function

2014-08-14 Thread luofeiyu
I want to write a function to make operation as a argument in the function. |def fun(op,x,y): return(x op y)| it is my target for the funciton: if op ="+" fun(op,3,9) =12 if op ="*" fun(op,3,9) =27 How to write it? -- https://mail.python.org/mailman/listinfo/python-list

Re: how to change the time string into number?

2014-08-14 Thread luofeiyu
>>> import sys >>> sys.version '3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)]' >>> import time >>> time.tzname ('China Standard Time', 'China Daylight Time') On 8/14/2014 3:25 PM, Cameron S

Re: a python console in bluestacks

2014-08-14 Thread luofeiyu
i want to run python on my android phone ,to install python on bluestacks is to emulate it . On 8/14/2014 2:56 PM, Cameron Simpson wrote: On 14Aug2014 08:25, Chris =?utf-8?B?4oCcS3dwb2xza2HigJ0=?= Warrick wrote: On Aug 14, 2014 4:30 AM, "luofeiyu" wrote: I have installed blu

Re: what is the "/" mean in __init__(self, /, *args, **kwargs) ?

2014-08-14 Thread luofeiyu
python3.4 On 8/14/2014 10:12 AM, Tim Chase wrote: On 2014-08-14 10:01, luofeiyu wrote: >>> help(int.__init__) Help on wrapper_descriptor: __init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. what is the "/" me

Re: how to change the time string into number?

2014-08-13 Thread luofeiyu
same result? >>> t3='Sat, 09 Aug 2014 07:36:46 +0400' >>> time.strptime(t3,"%a, %d %b %Y %H:%M:%S %z") time.struct_time(tm_year=2014, tm_mon=8, tm_mday=9, tm_hour=7, tm_min=36, tm_sec =46, tm_wday=5, tm_yday=221, tm_isdst=-1) The Directive %z has no any

a python console in bluestacks

2014-08-13 Thread luofeiyu
I have installed bluestacks(an android phone emulator) on my pc,and SL4A on it.Now i can run python thish way : 1.edit an file ending with |.py|, save it in /sdcard/sl4a/scripts/yourname.py. 2.open sl4a ,and click the file to make it run. Is there a python console to type python command to run

what is the "/" mean in __init__(self, /, *args, **kwargs) ?

2014-08-13 Thread luofeiyu
>>> help(int.__init__) Help on wrapper_descriptor: __init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. what is the "/" mean in __init__(self, /, *args, **kwargs) ? -- https://mail.python.org/mailman/listinfo/python-list

how to change the time string into number?

2014-08-13 Thread luofeiyu
s="Aug" how can i change it into 8 with some python time module? -- https://mail.python.org/mailman/listinfo/python-list

Re: why i can't copy mail with imaplib?

2014-08-10 Thread luofeiyu
ll) "/" "[Gmail]/&YkBnCZCuTvY-"', b'(\\HasNoChildren \\D rafts) "/" "[Gmail]/&g0l6Pw-"', b'(\\HasNoChildren \\Important) "/" "[Gmail]/&kc 2JgQ-"']) >>> x.con.select("inbox") ('OK'

why i can't copy mail with imaplib?

2014-08-10 Thread luofeiyu
Help on method copy in module imaplib: copy(message_set, new_mailbox) method of imaplib.IMAP4_SSL instance Copy 'message_set' messages onto end of 'new_mailbox'. (typ, [data]) = .copy(message_set, new_mailbox) self is an instance in my code."[Gmail]/&kc2JgQ-]" is the important mailbox.

get the min date from a list

2014-08-10 Thread luofeiyu
>>> date ['Sat, 09 Aug 2014 07:36:46 -0700', 'Fri, 8 Aug 2014 22:25:40 -0400', 'Sat, 9 Au g 2014 12:46:43 +1000', 'Sat, 9 Aug 2014 12:50:52 +1000', 'Sat, 9 Aug 2014 02:51 :01 + (UTC)', 'Sat, 9 Aug 2014 13:03:24 +1000', 'Sat, 09 Aug 2014 13:06:28 + 1000', 'Fri, 8 Aug 2014 20:48:44 -0700 (PDT

Re: how to get the subject of email?

2014-08-09 Thread luofeiyu
think you ,i get it . message = email.message_from_bytes(text) print(message['Subject']) #can get the subject But how can i get the body content of message? message['Body'] or message['Content'] can get none. On 8/9/2014 7:01 PM, John Gordon wrote: In

Re: how to get the subject of email?

2014-08-09 Thread luofeiyu
message = email.message_from_bytes(text) I get it , print(message['Subject']) #can get the subject But how can i get the body content of message? no , message['Body'] or message['Content'] On 8/9/2014 7:01 PM, John Gordon wrote: In luofeiyu writes: messa

how to get the subject of email?

2014-08-09 Thread luofeiyu
I am in python3.4 typ, data = x.con.fetch(b'1', '(RFC822)') #get the first email text = data[0][1] message = email.message_from_string(text).get('subject') Traceback (most recent call last): File "", line 1, in File "D:\Python34\lib\email\__init__.py", line 40, in message_from_string

Re: attendance system in pybluez

2014-08-09 Thread luofeiyu
dr in nearby_devices: print " %s - %s" % (addr, name) performing inquiry... found 2 devices Ray's Nokia - 00:12:D2:5A:BD:E4 Ray's MacBook - 00:1E:C2:93:DA:6F On 8/9/2014 4:53 AM, Steven D'Aprano wrote: luofeiyu wrote: I want to write a

attendance system in pybluez

2014-08-09 Thread luofeiyu
I want to write a program to help my teacher to take attendence. There are 300 students in a big room,everyone has android phone. I have matched them with my pc in win7 . when all of them seated on the classroom, import bluetooth nearby_devices = bluetooth.discover_devices(lookup_names = True) p

how to write file into my android phone?

2014-08-08 Thread luofeiyu
When i input usb line with my android phone into the pc , there are two disks j: and k: (type :removable disk) displayed in win7. i can get my android phone bluetooth mac address . import bluetooth nearby_devices = bluetooth.discover_devices(lookup_names = True) for addr, phoneName in nearby_d

Re: how to get the ordinal number in list

2014-08-08 Thread luofeiyu
>>> x=["x1","x3","x7","x5","x3"] >>> x.index("x3") 1 if i want the result of 1 and 4 ? On 8/8/2014 7:25 PM, Larry Martell wrote: On Sat, Aug 9, 2014 at 1:22 PM, luofeiyu wrote: x=["x1","x3",

how to print with given font and size?

2014-08-08 Thread luofeiyu
print("hallo") is so simple. how can print word "hallo" in console with courier New font 16 pound? -- https://mail.python.org/mailman/listinfo/python-list

how to get the ordinal number in list

2014-08-08 Thread luofeiyu
>>> x=["x1","x3","x7","x5"] >>> y="x3" how can i get the ordinal number by some codes? for id ,value in enumerate(x): if y==value : print(id) Is more simple way to do that? -- https://mail.python.org/mailman/listinfo/python-list

Re: more simple to split the string?

2014-08-08 Thread luofeiyu
Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AM D64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> str='(\\HasNoChildren \\Junk) "/" "[Gmail]/&V4NXPpCuTvY-"' >>> str.split(" ") ['(\\HasNoChildren', '\\Junk)', '"/"', '"[Gmail]

print range in python3.3

2014-01-04 Thread luofeiyu
>>> range(1,10) range(1, 10) >>> print(range(1,10)) range(1, 10) how can i get 1,2,3,4,5,6,7,8,9 in python3.3 ? -- https://mail.python.org/mailman/listinfo/python-list