I used python to write an assignment last week, here is a code snippet
#
def departTime():
'''
Calculate the time to depart a packet.
'''
if(random.random < 0.8):
t = random.expovariate(1.0 / 2.5)
else:
t = random.expovariate(1.0
I installed psycopg2 by "easy_install psycopg2" on CentOS 5.3, no
error was reported, but when I tried "import psycopg2", I got :
exceptions.ImportError: /usr/lib/python2.4/site-packages/
psycopg2-2.0.9-py2.4-linux-i686.egg/psycopg2/_psycopg.so: undefined
symbol: TLSv1_method
What might cause
2 class, B contains C. When user want to use some service of C,
there are two choice:
First, more encapsulation:
=
class B:
def newMethod(self):
self.c.newMethod()
class C:
def newMethod(self):
#do something
pass
b.newMethod()
Hi,
( First, this is not a question about if we should use ORM. It's
question for these who are already using it. )
Usually, I only use ORM, like sqlalchemy just as an abstraction layer
of
database. So these mapping objects I wrote only contains data but not
behavior.
For example, if I have a
Do you have to show these data on GUI? If so, why not use the event
pattern?
As far as I know, it's the standard way wxPython works.
BTW : If it's not complicated, I think maybe some wysiwyg solution is
better.
I use python for almost every thing, except these related to GUI.
On Apr 5, 8:31 pm,
might
review them many times in my future work.
On Apr 4, 12:10 pm, Carl Banks wrote:
> On Apr 2, 11:25 pm, 一首诗 wrote:
>
>
>
> > Consolidate existing functions?
>
> > I've thought about it.
>
> > For example, I have two functions:
>
> > #===
improve it.
On Apr 4, 1:14 pm, Michele Simionato
wrote:
> On Apr 3, 7:34 pm, 一首诗 wrote:
>
>
>
> > #
> > # Choice 2
> > #
>
> > class UserManager:
>
> > users = []
>
> > @classmethod
> >
#This is a real world problem I met.
#
#We have a database containing serveral tables, like : user, role,
organization. Each 2 of them has m:n relationships. These relations
are stored in association tables.
#
#Not we have to load all these data in memory to gain higher
performances. We create 3
"XXX"):
pass
else if(type == "YYY"):
pass
#=
But isn't the first style more clear for my code's user?
That's one reason why my interfaces grow fast.
On Apr 3, 1:51 am, Carl Banks wrote:
> On Apr 2, 8:02 am, 一首诗
rote:
> On Apr 1, 12:44 am, 一首诗 wrote:
>
> > I got the same problem when writing C#/C++ when I have to provide a
> > lot of method to my code's user. So I create a big class as the entry
> > point of my code. Although these big classes doesn't contains muc
On Apr 1, 4:55 pm, Lawrence D'Oliveiro wrote:
> In message <48506803-a6b9-432b-acef-
>
> b75f76e90...@v23g2000pro.googlegroups.com>, 一首诗 wrote:
> > Until one day I find service has nearly 100 methods and 6000 lines of
> > code. I don't need to read any progr
I also think that's my best choice. Before I wrote my mail, I
already knew that this is not a good question. It lacks details, and
it is too big.
But I think the first step to resolve a problem is to describe it. In
that way, I might find the answer myself
On Apr 1, 6:40 pm, "andrew cooke"
Hi all,
I am a programmer who works with some different kinds of programming
languages, like python, C++(in COM), action script, C#, etc.
Today, I realized that, what ever language I use, I always meet a same
problem and I think I never solve it very well.
The problem is : how to break my app in
#
class MyError(Exception):
def __init__(self):
self.message = u'Some Chinese:中文'
def __str__(self):
return self.message.encode('utf8')
#
This is an exception that I defined.
ng another library means more chances of bugs?
On Feb 17, 9:24 pm, "Diez B. Roggisch" wrote:
> 一首诗 schrieb:
>
>
>
> > Hi all,
>
> > Recently I am studying some python ORM libraries, such as sqlalchemy.
>
> > These are very powerful technologies to handle d
Hi all,
Recently I am studying some python ORM libraries, such as sqlalchemy.
These are very powerful technologies to handle database. But I think
my project are not complicated to enough to benefit from a complete
ORM system.
What I really want, is some easy ways to load data from database, an
OK, I was wrong with construct!
I wrote to the author and he replied. It works!
I am really glad there IS a easy way to handle binary data in python.
>>> from construct import *
>>>
>>>
>>> point = Struct("point",
... SNInt32("x"), # Signed, Native byte-order, Int 32 bits
('int' is platfo
n.
On Nov 21, 6:30 pm, Aaron Brady <[EMAIL PROTECTED]> wrote:
> On Nov 21, 2:28 am, 一首诗 <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi all,
>
> > Recently I asked a question on this group:
>
> > >> What's your choice when handle complicated C
Hi all,
Recently I asked a question on this group:
>> What's your choice when handle complicated C structures.
I got these suggestion:
1) try construct
2) try ctypes
I spend half a day on construct and here's my conclusion:
1. It really good for parse(unpack) data structur
Hi all,
Recently I am writing more codes in python with vim so I made some
search for python auto completion plugins.
Finally I found pydcition:
http://www.vim.org/scripts/script.php?script_id=850
Anyway, it works. But I met one problem. After you have set
isk+=.,(
The dot "." becomes p
On Nov 10, 10:13 am, Ronn <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I have a list:
> suffix = ["aĉ", "ad", "aĵ", "an", "ar"]
>
> and I'm trying to check a word to see if any of the suffixes exist in
> the list for example:
> if word in suffix:
> print "A suffix exist in your word"
>
> w
On Nov 10, 10:29 am, "Geon." <[EMAIL PROTECTED]> wrote:
> hi everyone!
>
> when i install pysqlite i meet bellow error. ( use easy_install and
> source code building same problem )
>
> ld: Can't find library for -lpython2.5
>
> what mean this message? and what i do?
>
> my system is hp-ux 11i v3. a
On Nov 7, 6:54 am, Thomas Christensen <[EMAIL PROTECTED]>
wrote:
> This issue has been raised a couple of times I am sure. But I have yet
> to find a satisfying answer.
>
> I am reading from a subprocess and this subprocess sometimes hang, in
> which case a call to read() call will block indefinit
On Nov 7, 8:22 am, Michel Perez <[EMAIL PROTECTED]> wrote:
> Que vola a todos:
> I have an object abstraction layer that allows me to comunicate and
> interact with my DB server without much problems -am thinking in
> possibles contributors.
>
> In the stdlib xmlrpclib handles this in a common wa
On Nov 7, 4:55 am, Aaron Brady <[EMAIL PROTECTED]> wrote:
> On Nov 6, 7:50 am, 一首诗 <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi all,
>
> > Today I was writing a simple test app for a video decoder library.
>
> > I use python to parse video files and input
Hi all,
Today I was writing a simple test app for a video decoder library.
I use python to parse video files and input data to the library.
I got a problem here, I need a windows form, and send the form handle
to the library as a parameter, then it can output video on the form.
Here is my prob
Hi all,
Recently I am writing a small network application with python.
The protocol is binary based and defined in c header files.
Now I'm using the upack function of 'struct' module, but it's really
annoying to write fmt strings for complicated structures.
What will be your choice when handlin
Thanks! That's a more clear way!
On Nov 3, 9:38 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> Chris Rebert wrote:
> > On Mon, Nov 3, 2008 at 1:40 AM, 一首诗 <[EMAIL PROTECTED]> wrote:
> >> Hi all,
>
> >> Today I wrote some code like this:
>
> >
Hi all,
Today I wrote some code like this:
for m in self.messages:
if not m.finished:
continue
#process the message
fini = [m for m in self.messages if m.finished]
for m in fini:
self.messages.remove(m)
As you can, I w
Hi all,
I read this interesting post comparing Boost.Python with Pyd:
http://pyd.dsource.org/vsboost.html
What's your opinion about it?
What's your first choice when you have write a C/C++ module for Python?
--
http://mail.python.org/mailman/listinfo/python-list
Hi all,
I'm looking for an RPC system working with twisted.
1. Binary. I want it run faster than any xml based RPC.
2. Bidirectional. Unlike HTTP, on which the client has to poll the
sever for events, the server should "call" the client's method to
notify events.
3. C/Python support. Part o
I read this article on http://kortis.to/radix/python_ext/
And I decided to try if it's true.
I write the program in 4 ways:
1. Pure C
2. Python using C extension
3. Python using psycho
4. Pure Python
And then I used timeit to test the speed of these 4. Unsurprisingly,
the time they cost were:
Hi all,
The question is like this:
=
One computer, 2 ethernet adapter. Receving UDP packages and send them
out throught another adapter.
The one who's program could support the heavies traffic could win a
little bonus.
=
I am considerring tryin
Hi all!
Have u tried genaxmodule.py provided by wxPython to create a wrapper
module for an activex control?
For me, some times it works, but some times, it doesn't.
-
Traceback (most recent call last):
File "genaxmodule.py", line 42, in ?
main(s
Oh, I didn't make myself clear.
What I mean is how to convert a piece of html to plain text bu keep as
much format as possible.
Such as convert " " to blank space and convert to "\r\n"
Gary Herron wrote:
> 一首诗 wrote:
> > Is there any simple way to solve th
Is there any simple way to solve this problem?
--
http://mail.python.org/mailman/listinfo/python-list
D:\python24\Lib\idlelib>pyshell.py
Traceback (most recent call last):
File "D:\python24\Lib\idlelib\PyShell.py", line 1388, in ?
main()
File "D:\python24\Lib\idlelib\PyShell.py", line 1361, in main
if not flist.open_shell():
File "D:\python24\Lib\idlelib\PyShell.py", line 277, in open
37 matches
Mail list logo