Here is a simple example:
[app]
[module]
__init__.py -- empty
a.py -- import b
b.py -- defined a function foo()
test.py
In the test.py, contains the below statement:
from module import a
Execute the test.py will get error:
Traceback (most
On Feb 27, 8:11 pm, 人言落日是天涯,望极天涯不见家 kelvin@gmail.com wrote:
Here is a simple example:
[app]
[module]
__init__.py -- empty
a.py -- import b
b.py -- defined a function foo()
test.py
In the test.py, contains the below statement:
from
On Feb 27, 8:40 pm, Ben Finney ben+pyt...@benfinney.id.au wrote:
人言落日是天涯,望极天涯不见家 kelvin@gmail.com writes:
Here is a simple example:
[app]
[module]
__init__.py -- empty
a.py -- import b
b.py -- defined a function foo()
test.py
On Feb 27, 9:22 pm, Frank Millman fr...@chagford.com wrote:
Ben Finney ben+pyt...@benfinney.id.au wrote in message
news:87ei6t646h@benfinney.id.au...
人言落日是天涯,望极天涯不见家 kelvin@gmail.com writes:
Here is a simple example:
[app]
[module]
__init__.py -- empty
On Feb 27, 9:38 pm, Frank Millman fr...@chagford.com wrote:
人言落日是天涯,望极天涯不见家 kelvin@gmail.com wrote in message
news:fa94323b-d859-4599-b236-c78a22b3d...@t19g2000prd.googlegroups.com...
On Feb 27, 9:22 pm, Frank Millman fr...@chagford.com wrote:
This behavior is by design or just a bug
On Sep 11, 1:14 pm, Benjamin Kaplan benjamin.kap...@case.edu wrote:
On Sat, Sep 11, 2010 at 12:38 AM, 人言落日是天涯,望极天涯不见家 kelvin@gmail.com
wrote:
Please look at below code snippet:
class test():
def __init__(self, a, dic={}):
self.a = a
self.dic = dic
print
On Sep 11, 1:55 pm, 人言落日是天涯,望极天涯不见家 kelvin@gmail.com wrote:
On Sep 11, 1:14 pm, Benjamin Kaplan benjamin.kap...@case.edu wrote:
On Sat, Sep 11, 2010 at 12:38 AM, 人言落日是天涯,望极天涯不见家 kelvin@gmail.com
wrote:
Please look at below code snippet:
class test():
def __init__(self
Please look at below code snippet:
class test():
def __init__(self, a, dic={}):
self.a = a
self.dic = dic
print('__init__ params:',a, dic)
def get(self):
self.dic[1] = 2
self.dic[4] = 5
def foo():
print('in foo function')
bar = test(1)
How could I format the float number like this: (keep 2 digit
precision)
1.002 = 1
1.12 = 1.12
1.00 = 1
1.567 = 1.57
2324.012 = 2324.01
I can not find any Formatting Operations is able to meet my
requirement.
Any suggestion will be appreciated.
--
Please see the follow code, I can not catch the exception IOError
raised from shutil.copyfile() , why?
try:
if (DEST_TYPE TYPE_FTP):
fn = oname
ftpc.UploadFile(f, fn)
else:
The follow statement comes from the Python 2.5 documentation
--
encode( [encoding[,errors]])
Return an encoded version of the string. Default encoding is the
current default string encoding. errors may be given to set a
different error handling scheme.
---
what's the
On 5月30日, 下午1时23分, Martin v. Lowis [EMAIL PROTECTED] wrote:
人言落日是天涯,望极天涯不见家 schrieb:
Who could explain the follow issue ?
print u'\u0394'
Δ
print u'\u20ac'
Traceback (most recent call last):
File stdin, line 1, in module
UnicodeEncodeError: 'gbk' codec can't encode character u
On 5月30日, 下午9时03分, Tijs [EMAIL PROTECTED] wrote:
??? wrote:
But the string contained the u'\u20ac' is get from remote host. Is
there any method to decode it to the local 'mbcs'?
remote_string = u'\u20ac'
try:
local_string = remote_string.encode('mbcs')
except:
# no
On 5月29日, 下午1时34分, Martin v. Lowis [EMAIL PROTECTED] wrote:
人言落日是天涯,望极天涯不见家 schrieb:
I lookup the utf-8 form of delta from the link.
http://www.fileformat.info/info/unicode/char/0394/index.htm
and then I want to print it in the python ( I work under windows)
#!/usr/bin/python
#coding
On 5月29日, 下午3时05分, Martin v. Lowis [EMAIL PROTECTED] wrote:
yes, it could print to the terminal(cmd.exe), but when I write these
string to file. I got the follow error:
File E:\Tools\filegen\filegen.py, line 212, in write
self.file.write(data)
UnicodeEncodeError: 'ascii' codec
Who could explain the follow issue ?
print u'Δ'
Δ
print u'�'
Traceback (most recent call last):
File stdin, line 1, in module
UnicodeEncodeError: 'gbk' codec can't encode character u'\x80' in
position 0: il
legal multibyte sequence
or I just put the unicode number
print u'\u0394'
Δ
print
I wanna print the log to both the screen and file, so I simulatered a
'tee'
class Tee(file):
def __init__(self, name, mode):
file.__init__(self, name, mode)
self.stdout = sys.stdout
sys.stdout = self
def __del__(self):
sys.stdout = self.stdout
I see. Many thanks to you!
--
http://mail.python.org/mailman/listinfo/python-list
I lookup the utf-8 form of delta from the link.
http://www.fileformat.info/info/unicode/char/0394/index.htm
and then I want to print it in the python ( I work under windows)
#!/usr/bin/python
#coding=utf-8
print \xce\x94
but the result is not the 'delta' but an unknown character.
--
I make a sample here for the more clearly explanation
s = . - this is a large string data - ...
def parser1(data)
# do some parser
...
# pass the remainder to next parser
parser2(data[100:])
def parser2(data)
# do some parser
...
# pass the remainder
I'm a python newbie. It seems the slice operation will do copy.
for example:
a = [1,2,3,4,5,6,7,8,9,0]
b = a[7:]
b
[8, 9, 0]
a.remove(9)
a
[1, 2, 3, 4, 5, 6, 7, 8, 0]
b
[8, 9, 0]
if the list have large members, the slice operations will consume many
times.
for instance, I have a long string
Please see the followed example:
class A:
def __init__(self):
pass
class X:
def __init__(self):
n = 200
if True:
j = 200
m = j
k = A()
print m, j
a = X()
# ?? what about the m, n and j? is it still alive?
del a
On Apr 30, 5:20 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote:
人言落日是天涯,望极天涯不见家 wrote:
Please see the followed example:
class A:
def __init__(self):
pass
class X:
def __init__(self):
n = 200
if True:
j = 200
m = j
k
On Apr 30, 5:47 pm, Soren [EMAIL PROTECTED] wrote:
Hi!
I have a string that contains some text and newline characters. I want
to parse the string so that the string just before a newline character
goes in as an element in the tuple.
ex:
text1 \n text2 \n text3 \n text4 -- (text1, text2,
I made a C/S network program, the client receive the zip file from the
server, and read the data into a variable. how could I process the
zipfile directly without saving it into file.
In the document of the zipfile module, I note that it mentions the
file-like object? what does it mean?
class
On Apr 29, 7:37 pm, Daniel Nogradi [EMAIL PROTECTED] wrote:
I made a C/S network program, the client receive the zip file from the
server, and read the data into a variable. how could I process the
zipfile directly without saving it into file.
In the document of the zipfile module, I note
On Apr 29, 7:37 pm, Daniel Nogradi [EMAIL PROTECTED] wrote:
I made a C/S network program, the client receive the zip file from the
server, and read the data into a variable. how could I process the
zipfile directly without saving it into file.
In the document of the zipfile module, I note
On Apr 29, 8:14 pm, Daniel Nogradi [EMAIL PROTECTED] wrote:
I made a C/S network program, the client receive the zip file from the
server, and read the data into a variable. how could I process the
zipfile directly without saving it into file.
In the document of the zipfile module,
first, I'm try the POINTER to convesion the pointer type. but failed.
class STUDENT(Structure):
_fields_ = [('name', c_int),
('id', c_int),
('addition',c_ubyte)]
buffer = c_byte * 1024
student_p = cast(buffer, POINTER(STUDENT))
The parameter of
On Apr 23, 5:42 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote:
人言落日是天涯,望极天涯不见家 wrote:
first, I'm try the POINTER to convesion the pointer type. but failed.
class STUDENT(Structure):
_fields_ = [('name', c_int),
('id', c_int),
('addition
How to generate a continuous string, like this
aaa
the number of characters is dynamic. Is there a module or function
implement this string ?
such as: duplicate_string(char, num)
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 11, 7:49 pm, Tim Golden [EMAIL PROTECTED] wrote:
On a whim, given the terseness of your post, I
cut-and-pasted your subject line into Google,
added python for good measure, and looked at
the results.
I suggest you might do the same. Granted, maybe
this will raise more questions, but
I define the class like this:
class AAA:
counter = 0
def __init__(self):
pass
def counter_increase():
AAA.counter += 1
print couter now :, AAA.counter
But how could I call the function counter_incrrease ?
Thanks !
--
On Apr 11, 11:19 am, 7stud [EMAIL PROTECTED] wrote:
On Apr 10, 9:08 pm, 人言落日是天涯,望极天涯不见家 [EMAIL PROTECTED] wrote:
I define the class like this:
class AAA:
counter = 0
def __init__(self):
pass
def counter_increase():
AAA.counter += 1
print couter
Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? The range() just can generate the numeric list.
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 9, 4:35 pm, Michael Bentley [EMAIL PROTECTED] wrote:
On Apr 9, 2007, at 3:29 AM, 人言落日是天涯,望极天涯不
见家 wrote:
Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? The range() just can generate the numeric list.
import string
list(string.lowercase)
Thanks
On Apr 9, 4:39 pm, Thomas Krüger [EMAIL PROTECTED] wrote:
人言落日是天涯,望极天涯不见家 schrieb:
Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? The range() just can generate the numeric list.
There is:
[ chr(i) for i in range(97, 123) ]
Thomas
Thanks you too! I'm
print r'\\.\'
This line will cause error. I just want to print the
\\.\
why the prefix character r isn't effective. Thanks!
--
http://mail.python.org/mailman/listinfo/python-list
38 matches
Mail list logo