Re: Possible bug in Tkinter for Python 2.6

2008-11-20 Thread Eric Brunel

On Wed, 19 Nov 2008 18:51:03 +0100, Terry Reedy [EMAIL PROTECTED] wrote:


Anton Vredegoor wrote:

On Wed, 19 Nov 2008 10:57:53 +0100
Eric Brunel [EMAIL PROTECTED] wrote:


I'm trying out Python 2.6 and I found what might be a bug in the
Tkinter module. How can I report it?

 maybe here:
http://bugs.python.org/issue3774


The fix will be in 2.6.1, which might be in December.


Thanks! Quite easy to fix anyway, but I prefer having an official version.
--
python -c print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])

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


Re: Python / Debian package dependencies

2008-11-20 Thread Stephane Bulot
Hi Steven,
This is a normal behaviour for dpkg. If there is a failing dependancy, dpkg
will not install dependancies, it will notify only and will not install the
package. Dependancies installations are managed by the front-end to dpkg
(aptitude or apt). This is not a python issue that you are facing to.
Cheers
Stephbul

2008/11/20 Steven Samuel Cole [EMAIL PROTECTED]

 Hi all,

 I am trying to build a debian package for my python modules using
 stdeb and dpkg-buildpackage. The package building itself works, I also
 managed to have an entry point created and I can use my python modules
 on the Ubuntu virtual machine I use to test the package.

 The problem is that my modules require the psycopg2 python package and
 the entry point seems to require setuptools.
 I can't figure out how to declare a dependency that actually results
 in the dependency Debian packages being installed.
 I tried adding these lines to setup.py:

 requires = ['psycopg2', 'setuptools'],
 requires = ['psycopg2 (=0.1)', 'setuptools (=0.1)'],
 install_requires = ['psycopg2', 'setuptools'],
 install_requires = ['psycopg2=0.1', 'setuptools=0.1'],

 and then run stdeb_run_setup and dpkg-buildpackage -rfakeroot -uc -us
 in the deb_dist/package name folder created, but when I copy the
 .deb file over to the virtual machine and do dpkg -i .deb file, none
 of them would actually install psycopg2 and setuptools.

 What am I doing wrong ? Am I actually somewhat on the right track or
 am I doing complete nonsense ?

 Thanks for your help!

 Cheers,

 Steve
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Hooking windowsmessages with python

2008-11-20 Thread Kevin Osthoff

Hi!

I'm trying to set a message hook with python to catch WM_DROPFILES.
The guiframework is Tkinter.
Here a code snippet:

 hwnd = eval(self.wm_frame()) 
 win32gui.DragAcceptFiles(hwnd,1) 
 wnd = win32ui.CreateWindowFromHandle(hwnd)
 wnd.HookMessage(self.test,w32con.WM_DROPFILES)

 def test(self):
print blala

The DragAcceptFiles-Call seems to be alright. When i drag a file over
the gui there is this drag-and-drop icon. But the problem is, that the 
callback-function (test) is never executed.
I also try different messages like Mousemove or Buttondown. So i think
there is a problem with the HookMessage function.
I read that you must compile Python with PYWIN_WITH_WINDOWPROC option
enabled. Is this the problem?

Can someone give me a short working code to hook a message so i can try
it on my workstation?

Thx in advance!



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


Re: Module Structure/Import Design Problem

2008-11-20 Thread Rafe
On Nov 20, 2:06 pm, Arnaud Delobelle [EMAIL PROTECTED] wrote:
 Rafe [EMAIL PROTECTED] writes:
  Hi,

  I am in a situation where I feel I am being forced to abandon a clean
  module structure in favor of a large single module. If anyone can save
  my sanity here I would be forever grateful.

  My problem is that classes in several modules share a common base
  class which needs to implement a factory method to return instances of
  these same classes.

  An example to help illustrate what I mean:
  Lets say I have the following modules with the listed classes:
   - baselib.py   with  BaseClass
   - types.py   with  TypeA, ...
   - special.py   with  SpecialTypeA, ...

  Which would be used a bit like this:
  type_a = any_type_instance.get_type(TypeA)
  special_type = type_a.get_type(SpecialTypeA)

  Again, I can get around this by dumping everything in to one module,
  but it muddies the organization of the package a bit. This seems like
  a problem that would come up a lot. Are there any design paradigms I
  can apply here?

 It's not very clear what your problem is.  I guess your factory
 functions are defined in baselib.py whereas types.py and special.py
 import baselib, therefore you don't know how to make the factory
 function aware of the types defined in special.py and types.py.

 You can use cyclic import in many cases.

 Or (better IMHO) you can make types register themselves with the factory
 function (in which case it would have some state so it would make more
 sense to make it a factory object).

 --
 Arnaud

hi Arnaud,

You got my problem right, sorry it wasn't more clear.

Can you elaborate on what you mean by 'register' with the factory
function?

Also...holy [EMAIL PROTECTED], I got a clean import working! I swear I tried 
that
before with unhappy results. I'll carefully try this in my real code.

Is this the right way to impliment the imports?

baselib.py
[1] class BaseClass(object):
[2] def factory(self):
[3] import typelib   # -- import inside function
[4] return typelib.TypeA()

typelib.py
[1] import baselib   # -- module level import
[2]
[3] class TypeA(baselib.BaseClass):
[4] def __init__(self):
[5] print TypeA : __init__()

 import typelib
 type = typelib.TypeA()
TypeA : __init__()
 another_type = type.factory()
TypeA : __init__()
 another_type
typelib.TypeA object at 0x00B45F10


I am curious (not directed at Arnaud), why not have an 'include'-like
import for special cases in python (or do I not understand includes
either?)

Thanks!

- Rafe
--
http://mail.python.org/mailman/listinfo/python-list


Re: Programming exercises/challenges

2008-11-20 Thread Edwin
On Nov 20, 12:39 am, Arnaud Delobelle [EMAIL PROTECTED] wrote:
 Edwin [EMAIL PROTECTED] writes:

 [...]

  a diary manager compatible with my Emacs diary file (sometimes I don't
  want to open Emacs for a quick note)

 You mean that you sometimes don't have emacs open?

 --
 Arnaud

heh... I believe in the potpourri style mate (and I don't mean petals
and spices).
After all I'm no expert.
--
http://mail.python.org/mailman/listinfo/python-list


Ip format

2008-11-20 Thread luca72
Hello i have this ip 1578568204

how socket function i can have the ip dotted-quad string?

i have try socket.inet_aton get no error but only this ^ETB FF

Thanks luca

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


Re: Ip format

2008-11-20 Thread Tim Chase

Hello i have this ip 1578568204

how socket function i can have the ip dotted-quad string?

i have try socket.inet_aton get no error but only this ^ETB FF



I've got the following program I threw together for one of my 
junior developers:


  from sys import argv, exit
  if len(argv)  2:
print Usage:
print \t%s ip_address % argv[0]
print \t%s int % argv[0]
print \nThe first form translates a dotted-quad format into 
int format
print \nThe second form translates from int form to a 
dotted-quad

exit(1)

  src = argv[1]

  if src.count('.') == 3:
a,b,c,d = map(lambda s: 0xff and int(s), src.split('.'))
print (
  (a  (8*3)) |
  (b  (8*2)) |
  (c  (8*1)) |
  d)
  else:
i = int(src)
a = 0xff  (i  (8*3))
b = 0xff  (i  (8*2))
c = 0xff  (i  (8*1))
d = 0xff  (i)
print '%s.%s.%s.%s' % (a,b,c,d)

The code you're looking for is in the bottom else: clause. 
Yes, that could be optimized to just c = 0xff  (i  8) in the 
3rd case, but it made it easier for my junior developer to 
understand what was going on.


There might be some library function to do these transformations 
for you, but after a quick look, I didn't find anything.


-tkc




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


strange permission issue with nosetests

2008-11-20 Thread Mr . SpOOn
Hi,
I'm trying the nose testing package. I've just started reading the
tutorial and I had a problem with the first simple example.

This is the test:

def test_b():
assert 'b' == 'b'

In the same directory I gave the command nosetests and it runs the test.

Then I try with nosetests -v, but it just says this:

--
Ran 0 tests in 0.003s

OK

I thought because I didn't change anything in the file, don't know.
Tried to change, but nothing. I moved on and wrote another test,
inside a class, but nothing. It just doesn't run tests.

Searching on google I found this: http://www.siafoo.net/article/61
He had the same issue and said to change permission of the file to 664.

I tried and it worked.
Is that normal? Why does it happen?
--
http://mail.python.org/mailman/listinfo/python-list


Re: credit kredite oesterreich ratenkredite online kredit ohne schufa in blitzkredite

2008-11-20 Thread [EMAIL PROTECTED]
On Nov 12, 2:06 pm, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 credit kredite oesterreich ratenkredite online kredit ohne schufa in
 blitzkredite

 +
 +
 +
 +
 +++ GUENSTIGE KREDITE ONLINE +++ KREDITE IM INTERNET OHNE SCHUFA +++
 +


http://www.fme.gov.ng/forum/forum_posts.asp?TID=4785PN=1
http://www.fme.gov.ng/forum/forum_posts.asp?TID=4785PN=1
http://www.fme.gov.ng/forum/forum_posts.asp?TID=4785PN=1
http://www.fme.gov.ng/forum/forum_posts.asp?TID=4785PN=1
http://www.fme.gov.ng/forum/forum_posts.asp?TID=4785PN=1
http://www.fme.gov.ng/forum/forum_posts.asp?TID=4785PN=1
http://www.fme.gov.ng/forum/forum_posts.asp?TID=4785PN=1
http://www.fme.gov.ng/forum/forum_posts.asp?TID=4785PN=1
http://www.fme.gov.ng/forum/forum_posts.asp?TID=4785PN=1
http://www.fme.gov.ng/forum/forum_posts.asp?TID=4785PN=1
http://www.fme.gov.ng/forum/forum_posts.asp?TID=4785PN=1
http://www.fme.gov.ng/forum/forum_posts.asp?TID=4785PN=1

 kredit privatkredite in Dietzenbach
 beamtenkredite darlehen ohne schufa in Marktoberdorf
 bargeld kredite bon kredit ohne schufa in Wittgenstein
 kredite schufa kredit umschuldung in Eberswalde
 online kredite ohne schufa beamtendarlehen ohne schufa in
 Schwarzenberg
 kredit online vergleich finanzierung in Bad Hersfeld
 kredite kreditvermittlung ohne schufa in Wolfenbüttel
 online kredit trotz schufa von bonkredit in Forst

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


teen home made p0rn

2008-11-20 Thread fernandena
http://sambuko.freetzi.com/old.htm homemade lesbian p0rn,homemade p0rn
pics
--
http://mail.python.org/mailman/listinfo/python-list


Re: strange permission issue with nosetests

2008-11-20 Thread Ben Finney
Mr.SpOOn [EMAIL PROTECTED] writes:

 Searching on google I found this: http://www.siafoo.net/article/61
 He had the same issue and said to change permission of the file to 664.
 
 I tried and it worked.
 Is that normal? Why does it happen?

If a file is meant to be run as a command or program, make it
executable. (It would be good to *also* make the file behave well when
imported as a module instead.)

If it's meant to be imported as a module, do *not* make it executable.

Unit test modules, which are primarily meant to be imported and have
the tests collected and *then* run by the unit test framework, should
be non-executable modules. I'm very glad nose enforces this.

-- 
 \“Humanity has advanced, when it has advanced, not because it |
  `\ has been sober, responsible, and cautious, but because it has |
_o__)been playful, rebellious, and immature.” —Tom Robbins |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list


Re: Hooking windowsmessages with python

2008-11-20 Thread Aaron Brady
On Nov 20, 3:52 am, Kevin Osthoff [EMAIL PROTECTED] wrote:
 Hi!

 I'm trying to set a message hook with python to catch WM_DROPFILES.
 The guiframework is Tkinter.
 Here a code snippet:

  hwnd = eval(self.wm_frame())
  win32gui.DragAcceptFiles(hwnd,1)
  wnd = win32ui.CreateWindowFromHandle(hwnd)
  wnd.HookMessage(self.test,w32con.WM_DROPFILES)
  def test(self):
     print blala

 The DragAcceptFiles-Call seems to be alright. When i drag a file over
 the gui there is this drag-and-drop icon. But the problem is, that the
 callback-function (test) is never executed.
 I also try different messages like Mousemove or Buttondown. So i think
 there is a problem with the HookMessage function.
 I read that you must compile Python with PYWIN_WITH_WINDOWPROC option
 enabled. Is this the problem?

 Can someone give me a short working code to hook a message so i can try
 it on my workstation?

 Thx in advance!

I've done some hooks in C.  If no one has a simpler way, I can help
you build a DLL to do it, and call it from Python.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Optional parameter object re-used when instantiating multiple objects

2008-11-20 Thread Aaron Brady
On Nov 19, 7:58 pm, alex23 [EMAIL PROTECTED] wrote:
 On Nov 20, 10:14 am, Aaron Brady [EMAIL PROTECTED] wrote:

  If you had a menu in a browser interface that had the items, say,
  'Stop' and 'Reload', what would you expect to happen if you clicked on
  them?

 If you had a keyword called 'def', which defined functions, would you
 expect it to define said functions when it executed, or on each
 function call?

At first, I would expect it to define them at compile-time.  Then,
when I learned there was no such thing, I would expect it to define
them at execute-time.  What does that have to do with evaluating a
default argument?
--
http://mail.python.org/mailman/listinfo/python-list


Re: strange permission issue with nosetests

2008-11-20 Thread Mr . SpOOn
On Thu, Nov 20, 2008 at 13:34, Ben Finney
[EMAIL PROTECTED] wrote:
 Mr.SpOOn [EMAIL PROTECTED] writes:

 Searching on google I found this: http://www.siafoo.net/article/61
 He had the same issue and said to change permission of the file to 664.

 Unit test modules, which are primarily meant to be imported and have
 the tests collected and *then* run by the unit test framework, should
 be non-executable modules. I'm very glad nose enforces this.

Mmm it seems strange to me. I mean, there isn't any reference to this
on the site. How would one imagine he needs to change permission? And
it is strange that the first time I didn't need to change anything.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Programming exercises/challenges

2008-11-20 Thread skip

 a diary manager compatible with my Emacs diary file (sometimes I
 don't want to open Emacs for a quick note)

Arnaud You mean that you sometimes don't have emacs open?

I am constantly amazed at work that people open a separate emacs for each
file they want to edit.  Most of them seem not to even know that find-file
exists.

Skip

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


Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-20 Thread Aaron Brady
On Nov 19, 7:22 pm, greg [EMAIL PROTECTED] wrote:
 Antoon Pardon wrote:
  You are changing your argument. In a follow up you
  made the point that call by value should be as it
  was intended by the writers of the algol 60 report.

 No, I was countering the argument that call by value
 is short for call by copying the value. I was pointing
 out that the inventors of the term didn't use any such
 words.

 Arguing that their words were intended to imply copying,
 as part of the essence of the idea, is making an even
 bigger assumption about their intentions, IMO.

 Rather it seems to me that the essence of the idea they
 had in mind is that call-by-value is equivalent to
 assignment.

 Furthermore, I don't seem to be alone in coming to that
 conclusion -- the designers of other dynamic languages
 appear to be using the same logic when they describe
 their parameter passing as call-by-value.

 Here's an example from The SNOBOL Programming Language,
 2nd Edition, by R. E. Griswold, J. F. Poage and I. P.
 Polonsky. On p. 15:

    Arguments are passed by value and may be arbitrarily
    complex expressions.

 and later on p. 95:

    When a call to a programmer-defined function is made, the
    arguments to the call are evaluated first. Before execution
    of the procedure begins ... new values are assigned to these
    variables as follows: ... (2) the formal arguments are
    assigned their values.

Tell me, what happens during a call to the following C++ function?

void f( std::vector int  x );

Is it the same as what happens during a call to the following Python
function?

def f( x ): ...

If not, which one is call-by-value?
--
http://mail.python.org/mailman/listinfo/python-list


Can't find Python Library packages in Ubuntu (Debian)

2008-11-20 Thread Jerzy Jalocha N
I'm new in this list (and to Python), so I'd like to start saying
hello to everyone first. I am really enjoying this new language!

I am trying to use the standard tests (like test_list.py or
test_dict.py) from the standard library (Python2.5), but they aren't
available on a standard Ubuntu Hardy or Ibex installation. Searching
in the official download, I found a rich test structure under
'Lib/test/', but in my installation, this directory doesn't contain
much. The dpkg-file script didn't find any packages for these specific
files either. I looked manually in any 'python-' package that seemed
reasonable, with no success, and Google didn't help this time.

So, the first question is: How do I install the complete Python test
framework under Ubuntu (Debian)?

Since I spend long times in a remote area without network connection,
I usually try to set-up everything I need (and might eventually need)
on my computer in advance, in order to avoid unpleasant surprises.
Thus, I would really try to make sure, I have a complete Python
installed on my notebook. But I couldn't find out for sure what parts
are missing in a standard Ubuntu installation, and what needs to be
added manually.

So, my second question: What (meta?-)package(s) do I have to install
under Ubuntu (Debian) in order to get a full (as in the official
release) Python installation?

Thank you in advance!

Jerzy
--
http://mail.python.org/mailman/listinfo/python-list


Re: strange permission issue with nosetests

2008-11-20 Thread Ben Finney
Mr.SpOOn [EMAIL PROTECTED] writes:

 Mmm it seems strange to me. I mean, there isn't any reference to this
 on the site. How would one imagine he needs to change permission? And
 it is strange that the first time I didn't need to change anything.

This seems now to have moved to be more about the specifics of ‘nose’,
rather than about Python. Perhaps it started there. Regardless, it's
probably best to take these questions to a more focused community,
such as the developers themselves.

-- 
 \ “Men never do evil so completely and cheerfully as when they do |
  `\it from religious conviction.” —Blaise Pascal (1623-1662), |
_o__)   Pensées, #894. |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list


imported method from module evaluates to None in some cases

2008-11-20 Thread Andrew

Hi:

I'm having a problem in some zope (2.10) code (HTTPResponse.py) where
a method that gets imported somehow evaluates to None in certain cases
which causes a TypeError exception to be raised (eg: TypeError:
'NoneType' object is not callable). The code excerpt is below where
the exception is raised on the line with the comment 'TypeError IS
RAISED HERE'. I've read that the thread stack size may be insufficient
but the I compiled a test pthreads program on the same system to get
the default. I used pthread_attr_getstacksize() and it returned
3657952 (3.5 mb?). I would imagine that's enough. Any ideas how this
could occur?

from PubCore.ZEvent import Wakeup

def close(self):
DebugLogger.log('A', id(self._request),
'%s %s' % (self._request.reply_code, self._bytes))
if not self._channel.closed:
self._channel.push(LoggingProducer(self._request,
self._bytes), 0)
self._channel.push(CallbackProducer(self._channel.done),
0)
self._channel.push(CallbackProducer(
lambda t=('E', id(self._request)): apply
(DebugLogger.log, t)), 0)
if self._shutdown:
self._channel.push(ShutdownProducer(), 0)
Wakeup()
else:
if self._close: self._channel.push(None, 0)
Wakeup()# TypeError IS RAISED HERE
else:
# channel closed too soon

self._request.log(self._bytes)
DebugLogger.log('E', id(self._request))

if self._shutdown:
Wakeup(lambda: asyncore.close_all())
else:
Wakeup()

self._channel=None #need to break cycles?
self._request=None


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


Re: Can't find Python Library packages in Ubuntu (Debian)

2008-11-20 Thread Diez B. Roggisch
Jerzy Jalocha N wrote:

 I'm new in this list (and to Python), so I'd like to start saying
 hello to everyone first. I am really enjoying this new language!
 
 I am trying to use the standard tests (like test_list.py or
 test_dict.py) from the standard library (Python2.5), but they aren't
 available on a standard Ubuntu Hardy or Ibex installation. Searching
 in the official download, I found a rich test structure under
 'Lib/test/', but in my installation, this directory doesn't contain
 much. The dpkg-file script didn't find any packages for these specific
 files either. I looked manually in any 'python-' package that seemed
 reasonable, with no success, and Google didn't help this time.
 
 So, the first question is: How do I install the complete Python test
 framework under Ubuntu (Debian)?
 
 Since I spend long times in a remote area without network connection,
 I usually try to set-up everything I need (and might eventually need)
 on my computer in advance, in order to avoid unpleasant surprises.
 Thus, I would really try to make sure, I have a complete Python
 installed on my notebook. But I couldn't find out for sure what parts
 are missing in a standard Ubuntu installation, and what needs to be
 added manually.
 
 So, my second question: What (meta?-)package(s) do I have to install
 under Ubuntu (Debian) in order to get a full (as in the official
 release) Python installation?

The one thing you will definitely need is the python-dev-package. It will
contain things such as headers and distutils that are needed to build and
install 3rd-party-packages. 

I don't have the slightest idea where the tests are - but you can of course
always install the source package :)

Diez
--
http://mail.python.org/mailman/listinfo/python-list


Re: imported method from module evaluates to None in some cases

2008-11-20 Thread Hrvoje Niksic
Andrew [EMAIL PROTECTED] writes:

 I'm having a problem in some zope (2.10) code (HTTPResponse.py) where
 a method that gets imported somehow evaluates to None in certain cases
 which causes a TypeError exception to be raised (eg: TypeError:
 'NoneType' object is not callable). The code excerpt is below where
 the exception is raised on the line with the comment 'TypeError IS
 RAISED HERE'.

Could the certain cases involve automatic invocation of the close
method at interpreter shutdown?  While the interpreter shuts down,
module-level variables are set to None.  This is documented in some
detail in http://www.python.org/doc/essays/cleanup/, steps C1-C3.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Hooking windowsmessages with python

2008-11-20 Thread Mike Driscoll
On Nov 20, 3:52 am, Kevin Osthoff [EMAIL PROTECTED] wrote:
 Hi!

 I'm trying to set a message hook with python to catch WM_DROPFILES.
 The guiframework is Tkinter.
 Here a code snippet:

  hwnd = eval(self.wm_frame())
  win32gui.DragAcceptFiles(hwnd,1)
  wnd = win32ui.CreateWindowFromHandle(hwnd)
  wnd.HookMessage(self.test,w32con.WM_DROPFILES)
  def test(self):
     print blala

 The DragAcceptFiles-Call seems to be alright. When i drag a file over
 the gui there is this drag-and-drop icon. But the problem is, that the
 callback-function (test) is never executed.
 I also try different messages like Mousemove or Buttondown. So i think
 there is a problem with the HookMessage function.
 I read that you must compile Python with PYWIN_WITH_WINDOWPROC option
 enabled. Is this the problem?

 Can someone give me a short working code to hook a message so i can try
 it on my workstation?

 Thx in advance!

I recommend re-posting to the PyWin32 mailing list where the creators
of this package lurk. They'll probably be able to give you some
advice:

http://mail.python.org/mailman/listinfo/python-win32

Mike
--
http://mail.python.org/mailman/listinfo/python-list


Problem with writing fast UDP server

2008-11-20 Thread Krzysztof Retel
Hi guys,

I am struggling writing fast UDP server. It has to handle around 1
UDP packets per second. I started building that with non blocking
socket and threads. Unfortunately my approach does not work at all.
I wrote a simple case test: client and server. The client sends 2200
packets within 0.137447118759 secs. The tcpdump received 2189 packets,
which is not bad at all.
But the server only handles 700 -- 870 packets, when it is non-
blocking, and only 670 – 700 received with blocking sockets.
The client and the server are working within the same local network
and tcpdump shows pretty correct amount of packets received.

I included a bit of the code of the UDP server.

class PacketReceive(threading.Thread):
def __init__(self, tname, socket, queue):
self._tname = tname
self._socket = socket
self._queue = queue
threading.Thread.__init__(self, name=self._tname)

def run(self):
print 'Started thread: ', self.getName()
cnt = 1
cnt_msgs = 0
while True:
try:
data = self._socket.recv(512)
msg = data
cnt_msgs += 1
total += 1
# self._queue.put(msg)
print  'thread: %s, cnt_msgs: %d' % (self.getName(),
cnt_msgs)
except:
pass


I was also using Queue, but this didn't help neither.
Any idea what I am doing wrong?

I was reading that Python socket modules was causing some delays with
TCP server. They recomended to set up  socket option for nondelays:
sock.setsockopt(SOL_TCP, TCP_NODELAY, 1) . I couldn't find any
similar option for UDP type sockets.
Is there anything I have to change in socket options to make it
working faster?
Why the server can't process all incomming packets? Is there a bug in
the socket layer? btw. I am using Python 2.5 on Ubuntu 8.10.

Cheers
K
--
http://mail.python.org/mailman/listinfo/python-list


C extension type gives type error in power operator

2008-11-20 Thread Paul Moore
I'm trying to implement an extension type with a power operator. The
operator is unusual in that I want to allow my objects to be raised to
an integer power:

   p = Pattern()
   p3 = p ** 3

I've implemented the code for a nb_power slot, it converts the other
argument to a C long using PyInt_AsLong().

static PyObject *
Pattern_pow (PyObject *self, PyObject *other, PyObject *modulo)
{
long n = PyInt_AsLong(other);
...
/* Ignore modulo argument - not meaningful */

if (n == -1  PyErr_Occurred())
return NULL;
...
}

However, when I try to use the operator, I get the following error:
TypeError: unsupported operand type(s) for ** or pow():
'_ppeg.Pattern' and 'int'

I'm not sure where this error is coming from, as I don't have any type
checks in my code. Is there something else I should add to allow mixed-
type operations? (This is Python 2.5, if it matters).

Oh, and is there a good reference for writing C extensions for Python
anywhere? The manuals aren't bad, but I keep hitting empty sections
(e.g., 10.5 Number Object Structures).

Thanks
Paul.
--
http://mail.python.org/mailman/listinfo/python-list


Air Force1 and Air Jordan shoes PAYPAL wholesale

2008-11-20 Thread air force1 shoes
Air Force1 and Air Jordan shoes PAYPAL wholesale

www.z-a-z-a.com
air force1 shoes. air force1 high shoes. air force1 light shoes .
we are professional produce air force1 and jordan shoes
supplier ,carry PAYPAL.main air force1-25th AF1-high AF1-low .air
jordan 1-14,air jordan 23,air force 1jordan 5,air
force1jordan12,air
jordan1jordan23 and so on   .We are sure you will make your business
very easily under our help.If you need any help, please do not
hesitate to contact with us at any time.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with writing fast UDP server

2008-11-20 Thread Hrvoje Niksic
Krzysztof Retel [EMAIL PROTECTED] writes:

 But the server only handles 700 -- 870 packets, when it is non-
 blocking, and only 670 – 700 received with blocking sockets.

What are your other threads doing?  Have you tried the same code
without any threading?
--
http://mail.python.org/mailman/listinfo/python-list


Re: imported method from module evaluates to None in some cases

2008-11-20 Thread Andrew
On Nov 20, 6:53 am, Hrvoje Niksic [EMAIL PROTECTED] wrote:
 Andrew [EMAIL PROTECTED] writes:
  I'm having a problem in some zope (2.10) code (HTTPResponse.py) where
  a method that gets imported somehow evaluates to None in certain cases
  which causes a TypeError exception to be raised (eg: TypeError:
  'NoneType' object is not callable). The code excerpt is below where
  the exception is raised on the line with the comment 'TypeError IS
  RAISED HERE'.

 Could the certain cases involve automatic invocation of the close
 method at interpreter shutdown?  While the interpreter shuts down,
 module-level variables are set to None.  This is documented in some
 detail inhttp://www.python.org/doc/essays/cleanup/, steps C1-C3.

That's possible. I didn't know that. Now I guess the question for me
is why and where did the interpreter shutdown? I don't see log entries
relating to it. Is it possible for me to intercept an interpreter
shutdown so I can find out the location and possibly the reason why
the interpreter abruptly shuts down?

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


Re: Air Force1 and Air Jordan shoes PAYPAL wholesale

2008-11-20 Thread Pierre-Alain Dorange
air force1 shoes [EMAIL PROTECTED] wrote:

 air force1 shoes. air force1 high shoes. air force1 light shoes
  File stdin, line 1
air force1 shoes. air force1 high shoes. air force1 light shoes
 ^
SyntaxError: invalid syntax
 


-- 
Pierre-Alain Dorange

Ce message est sous licence Creative Commons by-nc-sa-2.0
http://creativecommons.org/licenses/by-nc-sa/2.0/fr/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Hooking windowsmessages with python

2008-11-20 Thread Kevin Osthof

Mike Driscoll schrieb:


I recommend re-posting to the PyWin32 mailing list where the creators
of this package lurk. They'll probably be able to give you some
advice:

http://mail.python.org/mailman/listinfo/python-win32



Ok. I will try this.


Mike

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


Re: strange permission issue with nosetests

2008-11-20 Thread Roel Schroeven

Mr.SpOOn schreef:

On Thu, Nov 20, 2008 at 13:34, Ben Finney
[EMAIL PROTECTED] wrote:

Mr.SpOOn [EMAIL PROTECTED] writes:


Searching on google I found this: http://www.siafoo.net/article/61
He had the same issue and said to change permission of the file to 664.

Unit test modules, which are primarily meant to be imported and have
the tests collected and *then* run by the unit test framework, should
be non-executable modules. I'm very glad nose enforces this.


Mmm it seems strange to me. I mean, there isn't any reference to this
on the site. How would one imagine he needs to change permission? And
it is strange that the first time I didn't need to change anything.


You can also nosetests --exe; with that option, nose will also include 
executable files (see the section nosetests usage on the website 
(http://somethingaboutorange.com/mrl/projects/nose/#usage, under 
Options)).


It took me a while too before I could figure what was wrong, and how to 
solve it.


--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
  -- Isaac Asimov

Roel Schroeven
--
http://mail.python.org/mailman/listinfo/python-list


Re: Hooking windowsmessages with python

2008-11-20 Thread Kevin Osthof

Aaron Brady wrote:


I've done some hooks in C.  If no one has a simpler way, I can help
you build a DLL to do it, and call it from Python.


Thx for the offer but i will try to do it in python first. ;)


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


Re: C extension type gives type error in power operator

2008-11-20 Thread Thomas Heller
Paul Moore schrieb:
 I'm trying to implement an extension type with a power operator. The
 operator is unusual in that I want to allow my objects to be raised to
 an integer power:
 
p = Pattern()
p3 = p ** 3
 
 I've implemented the code for a nb_power slot, it converts the other
 argument to a C long using PyInt_AsLong().
 
 static PyObject *
 Pattern_pow (PyObject *self, PyObject *other, PyObject *modulo)
 {
 long n = PyInt_AsLong(other);
 ...
 /* Ignore modulo argument - not meaningful */
 
 if (n == -1  PyErr_Occurred())
 return NULL;
 ...
 }
 
 However, when I try to use the operator, I get the following error:
 TypeError: unsupported operand type(s) for ** or pow():
 '_ppeg.Pattern' and 'int'

Try to set Py_TPFLAGS_CHECKTYPES in your extension type (in the tp_flags slot).

from object.h:
  /* PyNumberMethods do their own coercion */
  #define Py_TPFLAGS_CHECKTYPES (1L4)

 I'm not sure where this error is coming from, as I don't have any type
 checks in my code. Is there something else I should add to allow mixed-
 type operations? (This is Python 2.5, if it matters).
 
 Oh, and is there a good reference for writing C extensions for Python
 anywhere? The manuals aren't bad, but I keep hitting empty sections
 (e.g., 10.5 Number Object Structures).

I normally look into the newest python reference manual, even if I'm
programming for older versions.  But sometimes you have to took into
the header files, too.

Thomas
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with writing fast UDP server

2008-11-20 Thread Krzysztof Retel
On Nov 20, 3:34 pm, Hrvoje Niksic [EMAIL PROTECTED] wrote:
 Krzysztof Retel [EMAIL PROTECTED] writes:
  But the server only handles 700 -- 870 packets, when it is non-
  blocking, and only 670 – 700 received with blocking sockets.

 What are your other threads doing?  Have you tried the same code
 without any threading?

I have only this one thread, which I can run couple of times.
I tried without a threading and was the same result, not all packets
were processed.

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


Re: Getting fractional part from a float without using string operations

2008-11-20 Thread James Harris
On 20 Nov, 06:01, srinivasan srinivas [EMAIL PROTECTED] wrote:
 Yes it works for most of the cases.  But it doesn't for the following case:

  str(abs(int(1234567.89)-1234567.89))

 '0.88999898'

Well, that is 0.89 or about as near to it as the calculation can
represent. Like other numbers 0.89 evidently cannot be exactly
represented as a float in binary. The nearest number above it is

 0.89
0.89001


This is not a Python issue but a result of storing numbers in floating
binary form.

BTW, please post comments below existing ones rather than above them.
It is more familiar on Usenet and, as a consequence, easier to read.

James
--
http://mail.python.org/mailman/listinfo/python-list


Nokia N96 16GB -GSM- Cell Phone (Unlocked) Quad Band

2008-11-20 Thread windchen1214
7*24 hour On-line service:
MSN/Email:[EMAIL PROTECTED]
Our website: http://www.elec-bestseller.cn

Operating Frequency

* WCDMA2100/900 (HSDPA) / EGSM900, GSM850/1800/1900 MHz (EGPRS)
* Automatic switching between bands and modes
* DVB-H Class C, 470-750 MHz

Dimensions

* Volume: 92 cc
* Weight: 125 g
* Length: 103 mm
* Width: 55 mm
* Depth: 18 mm, locally up to 20 mm

Memory Functions*

* 16GB internal flash memory, plus microSD memory card slot (hot
swappable) for expandability and flexibility
* Approximate dynamic memory capacity indication with 16GB
storage:
  o Video: 40 hours**
  o Music: 12,000 tracks***
* 128MB RAM, 256MB system memory (operating system plus dynamic
user data area)

*Changes to product details are possible without prior notice.
Application offering may vary. Dynamic memory means that the available
memory is shared between dynamic memory functions. When any of these
functions is used, there is less available memory for other functions
which are also dependent on dynamic memory.

** Video capacity is based on H.264 768-kbps video at 320-by-240
resolution, combined with 96-kbps AAC audio. Music capacity is based
on 3:45 min per track and 48 kbps eAAC+ encoding.

*** Capacity based on 3:45 per song with 48 kbps eAAC+ (M4A) encoding
on the Nokia Audio Manager. Capacity with 128 kbps AAC encoding is up
to [12,000] songs.

Power Management*

* Battery: Nokia Battery BL-5F, 950 mAh
* Talk time: up to 150 / 220 minutes (WCDMA / GSM)
* Standby: up to 200 / 220 hours (WCDMA / GSM)
* Video playback: up to 5 hours (offline mode)
* Music playback: up to 14 hours (offline mode)
* TV playback: up to 4 hours (DVB-H)

* Operation times may vary depending on radio access technology used,
operator network configuration and usage.

Display and User Interface

* 2.8 QVGA (240 x 320 pixels) LCD TFT display with up to 16
million colors
* User Interface: S60 3rd edition, feature pack 2
* Active standby screen, Multimedia menu

Data Transfer

* WCDMA HSDPA 900/2100 MHz with simultaneous voice and packet data
(PS max speed DL/UL= 3.6Mbps/384kbps, CS max speed 64kbps)
* Dual Transfer Mode (DTM) support for simultaneous voice and
packet data connection in GSM/EDGE networks. Simple class A, multi
slot class 11, max speed DL/UL: 177.6/118.4kbps
* EGPRS class B, multi slot class 32, max speed DL/UL=
296/177.6kbps
* GPRS class B, multi slot class 32, max speed DL/UL= 107/64.2kbps

Video  TV

Video center

* Video center: central hub for video experiences
* Access to last played video and easy resume
* My videos: collection of stored videos
* Access to Internet Videos, compatible with RSS feeds and video
podcasts, with direct wireless updates and downloads
* Service catalog to discover new Internet Videos

Video Codecs and Formats

* MPEG-4 Part 2 (H.263/SP), up to VGA 30 fps, hardware-accelerated
codec, scaled to max QVGA on device screen, or max SDTV on TV-out
* MPEG-4 Part 10 (H.264/AVC), up to VGA 30 fps, hardware-
accelerated codec, scaled to max QVGA on device screen, or SDTV on TV-
out
* Windows Media Video (WMV9), up to CIF/QVGA 30 fps, hardware-
accelerated codec, scaled to max QVGA on device screen, or SDTV on TV-
out
* RealVideo QCIF at 30 fps
* Flash video support in browser
* DRM support: OMA DRM 1, OMA DRM 2, WM DRM

Live TV

* Broadcast Television (DVB-H) capable
  o DVB-H based mobile TV with internal antenna
  o DVB-H Class C, 470-750 MHz

Browser-based video access

* Support for download, streaming and progressive download
* Support for Flash video

http://www.elec-bestseller.cn/products.asp?id=972
--
http://mail.python.org/mailman/listinfo/python-list


Re: C extension type gives type error in power operator

2008-11-20 Thread Paul Moore
On 20 Nov, 15:43, Thomas Heller [EMAIL PROTECTED] wrote:
 Paul Moore schrieb:
  However, when I try to use the operator, I get the following
  error:
  TypeError: unsupported operand type(s) for ** or pow():
  '_ppeg.Pattern' and 'int'

 Try to set Py_TPFLAGS_CHECKTYPES in your extension type (in the
 tp_flags slot).

 from object.h:
   /* PyNumberMethods do their own coercion */
   #define Py_TPFLAGS_CHECKTYPES (1L4)

Excellent! That did exactly what I wanted. (I wonder how it affects my
other operations - I'll look into that, it probably helps in ways I
hadn't suspected).

  Oh, and is there a good reference for writing C extensions for
  Python anywhere? The manuals aren't bad, but I keep hitting
  empty sections (e.g., 10.5 Number Object Structures).

 I normally look into the newest python reference manual, even if
 I'm programming for older versions.  But sometimes you have to
 took into the header files, too.

This particular issue was in the 2.6 manual. I hadn't thought to check
there. Add browse the 2.6 manuals to my ever-increasing todo
list :-) Or maybe just get round to installing 2.6, and be done with
it.

Or there's always ask the experts on clp :-) (I did at least look in
the sources, but never thought of checking the type flags).

Thanks,
Paul
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with writing fast UDP server

2008-11-20 Thread bieffe62
On 20 Nov, 16:03, Krzysztof Retel [EMAIL PROTECTED]
wrote:
 Hi guys,

 I am struggling writing fast UDP server. It has to handle around 1
 UDP packets per second. I started building that with non blocking
 socket and threads. Unfortunately my approach does not work at all.
 I wrote a simple case test: client and server. The client sends 2200
 packets within 0.137447118759 secs. The tcpdump received 2189 packets,
 which is not bad at all.
 But the server only handles 700 -- 870 packets, when it is non-
 blocking, and only 670 – 700 received with blocking sockets.
 The client and the server are working within the same local network
 and tcpdump shows pretty correct amount of packets received.

 I included a bit of the code of the UDP server.

 class PacketReceive(threading.Thread):
     def __init__(self, tname, socket, queue):
         self._tname = tname
         self._socket = socket
         self._queue = queue
         threading.Thread.__init__(self, name=self._tname)

     def run(self):
         print 'Started thread: ', self.getName()
         cnt = 1
         cnt_msgs = 0
         while True:
             try:
                 data = self._socket.recv(512)
                 msg = data
                 cnt_msgs += 1
                 total += 1
                 # self._queue.put(msg)
                 print  'thread: %s, cnt_msgs: %d' % (self.getName(),
 cnt_msgs)
             except:
                 pass

 I was also using Queue, but this didn't help neither.
 Any idea what I am doing wrong?

 I was reading that Python socket modules was causing some delays with
 TCP server. They recomended to set up  socket option for nondelays:
 sock.setsockopt(SOL_TCP, TCP_NODELAY, 1) . I couldn't find any
 similar option for UDP type sockets.
 Is there anything I have to change in socket options to make it
 working faster?
 Why the server can't process all incomming packets? Is there a bug in
 the socket layer? btw. I am using Python 2.5 on Ubuntu 8.10.

 Cheers
 K

Stupid question: did you try removing the print (e.g. printing once
every 100 messages) ?

Ciao

FB
--
http://mail.python.org/mailman/listinfo/python-list


Re: redirecting stdout/err to mysql table

2008-11-20 Thread Nebur
I've had a similar requiredment and made a small tool for direct
logging into databases (see:
http://sourceforge.net/projects/rrlog/
)

It's origins are somewhat older than the Python 2.3 standard logging
framework, so it can be used without that (but can also be simply
integrated with it.) It even does some more than you currently need
(log rotation and remote logging).

 Ratsberg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Ip format

2008-11-20 Thread luca72
Many thanks for your help
I have also find the correct socket function:
ip 1578568204
ip = socket.inet_aton(ip)
ip_dot = socket.inet_ntoa(ip)


Thanks Luca


On 20 Nov, 12:36, Tim Chase [EMAIL PROTECTED] wrote:
  Hello i have this ip 1578568204

  how socket function i can have the ip dotted-quad string?

  i have try socket.inet_aton get no error but only this ^ETB FF

 I've got the following program I threw together for one of my
 junior developers:

    from sys import argv, exit
    if len(argv)  2:
      print Usage:
      print \t%s ip_address % argv[0]
      print \t%s int % argv[0]
      print \nThe first form translates a dotted-quad format into
 int format
      print \nThe second form translates from int form to a
 dotted-quad
      exit(1)

    src = argv[1]

    if src.count('.') == 3:
      a,b,c,d = map(lambda s: 0xff and int(s), src.split('.'))
      print (
        (a  (8*3)) |
        (b  (8*2)) |
        (c  (8*1)) |
        d)
    else:
      i = int(src)
      a = 0xff  (i  (8*3))
      b = 0xff  (i  (8*2))
      c = 0xff  (i  (8*1))
      d = 0xff  (i)
      print '%s.%s.%s.%s' % (a,b,c,d)

 The code you're looking for is in the bottom else: clause.
 Yes, that could be optimized to just c = 0xff  (i  8) in the
 3rd case, but it made it easier for my junior developer to
 understand what was going on.

 There might be some library function to do these transformations
 for you, but after a quick look, I didn't find anything.

 -tkc

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


Re: Problem with writing fast UDP server

2008-11-20 Thread Krzysztof Retel
On Nov 20, 4:00 pm, [EMAIL PROTECTED] wrote:
 On 20 Nov, 16:03, Krzysztof Retel [EMAIL PROTECTED]
 wrote:



  Hi guys,

  I am struggling writing fast UDP server. It has to handle around 1
  UDP packets per second. I started building that with non blocking
  socket and threads. Unfortunately my approach does not work at all.
  I wrote a simple case test: client and server. The client sends 2200
  packets within 0.137447118759 secs. The tcpdump received 2189 packets,
  which is not bad at all.
  But the server only handles 700 -- 870 packets, when it is non-
  blocking, and only 670 – 700 received with blocking sockets.
  The client and the server are working within the same local network
  and tcpdump shows pretty correct amount of packets received.

  I included a bit of the code of the UDP server.

  class PacketReceive(threading.Thread):
      def __init__(self, tname, socket, queue):
          self._tname = tname
          self._socket = socket
          self._queue = queue
          threading.Thread.__init__(self, name=self._tname)

      def run(self):
          print 'Started thread: ', self.getName()
          cnt = 1
          cnt_msgs = 0
          while True:
              try:
                  data = self._socket.recv(512)
                  msg = data
                  cnt_msgs += 1
                  total += 1
                  # self._queue.put(msg)
                  print  'thread: %s, cnt_msgs: %d' % (self.getName(),
  cnt_msgs)
              except:
                  pass

  I was also using Queue, but this didn't help neither.
  Any idea what I am doing wrong?

  I was reading that Python socket modules was causing some delays with
  TCP server. They recomended to set up  socket option for nondelays:
  sock.setsockopt(SOL_TCP, TCP_NODELAY, 1) . I couldn't find any
  similar option for UDP type sockets.
  Is there anything I have to change in socket options to make it
  working faster?
  Why the server can't process all incomming packets? Is there a bug in
  the socket layer? btw. I am using Python 2.5 on Ubuntu 8.10.

  Cheers
  K

 Stupid question: did you try removing the print (e.g. printing once
 every 100 messages) ?

:) Of course I did Nothing has changed

I wonder if there is a kind of setting for socket to allow no delays?
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to acces the block inside of a context manager as sourcecode

2008-11-20 Thread Daniel
Hi Aaron,

the dataStore combines both the printing and analysis (it will create a
report).
Unfortunately the end of the block already needs to be known in
__enter__, as the report starts to print during the measurement.
I decided to do it the following way:

__enter__ gets the start line number using the idea you proposed.
then the program reads the number of lines that are indented with
respect to the with block. This could cause problems for strange
indenting, but this should not happen in my application. Unfortunately I
could not use the ast module, because the comments are an important part
of the report.

Thank you for your ideas

Daniel




class CM( object ):
def __enter__(self):
self.startline= inspect.stack( )[ 1 ][ 0 ].f_lineno
print 'startline',self.startline
filename = inspect.stack( )[-1][1]

def getIndentation(line):
# TODO: handle comments and docstrings correctly
return len(line) - len(line.lstrip())

with open(filename,'r') as f:
lines=f.readlines()[self.startline-1:]
indent0=getIndentation(lines[0])
indent =[getIndentation(i)-indent0 for i in lines[1:]]
nlines = [n for l,n in zip(indent,xrange(1,100)) if l 
0][0]
self.callingCode = lines[:self.startline+nlines]

print self.callingCode


def __exit__(self, exc_type, exc_value, traceback):
   pass

if __name__ == '__main__':
with CM():
print 'in first'
a= 0
b= 1
c= 2
print 'end of first'

with CM():
d= 3
e= 4
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python / Debian package dependencies

2008-11-20 Thread Paul Boddie
On 20 Nov, 02:14, Steven Samuel Cole [EMAIL PROTECTED]
wrote:

 I am trying to build a debian package for my python modules using
 stdeb and dpkg-buildpackage. The package building itself works, I also
 managed to have an entry point created and I can use my python modules
 on the Ubuntu virtual machine I use to test the package.

 The problem is that my modules require the psycopg2 python package and
 the entry point seems to require setuptools.

Are you saying that psycopg2 needs setuptools for the setup.py script
to work? This isn't generally the case (or wasn't), but maybe the
entry point is a setuptools thing which would then demand that
software's presence.

 I can't figure out how to declare a dependency that actually results
 in the dependency Debian packages being installed.
 I tried adding these lines to setup.py:

 requires = ['psycopg2', 'setuptools'],
 requires = ['psycopg2 (=0.1)', 'setuptools (=0.1)'],
 install_requires = ['psycopg2', 'setuptools'],
 install_requires = ['psycopg2=0.1', 'setuptools=0.1'],

How does stdeb know which package provides psycopg2? I'm not really
familiar with stdeb - I write my own packaging files - but might it be
the case that you need to specify python-psycopg2 instead?

Paul
--
http://mail.python.org/mailman/listinfo/python-list


Re: More elegant way to try running a function X times?

2008-11-20 Thread Boris Borcic

Tim Chase wrote:


success = None
for i in range(5):
#Try to fetch public IP
success = CheckIP()
if success:
break
if not success:
print Exiting.
sys.exit()


Though a bit of an abuse, you can use

  if not any(CheckIP() for _ in range(5)):
print Exiting
sys.exit()


I don't see why you speak of abuse, bit of abuse would be, say if you replaced 
range(5) by '12345' to win a char; but otoh I think you misspelled any() for all().


Cheers BB

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


Re: More elegant way to try running a function X times?

2008-11-20 Thread Tim Chase

success = None
for i in range(5):
#Try to fetch public IP
success = CheckIP()
if success:
break
if not success:
print Exiting.
sys.exit()

Though a bit of an abuse, you can use

  if not any(CheckIP() for _ in range(5)):
print Exiting
sys.exit()


I don't see why you speak of abuse, bit of abuse would be, say if you replaced 
range(5) by '12345' to win a char; but otoh I think you misspelled any() for all().


The OP's code break'ed (broke?) upon the first success, rather 
than checking all of them.  Thus, it would be any() rather than 
all().  Using all() would require 5 successful calls to 
CheckIP(), rather than one-out-of-five successful calls.


As for abuse, the for _ in iterable always feels a little hokey 
to me.  It works, but feels warty.


-tkc



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


Re: Module Structure/Import Design Problem

2008-11-20 Thread Stef Mientki

Rafe wrote:

Hi,

I am in a situation where I feel I am being forced to abandon a clean
module structure in favor of a large single module. If anyone can save
my sanity here I would be forever grateful.

My problem is that classes in several modules share a common base
class which needs to implement a factory method to return instances of
these same classes.

An example to help illustrate what I mean:
Lets say I have the following modules with the listed classes:
 - baselib.py   with  BaseClass
 - types.py   with  TypeA, ...
 - special.py   with  SpecialTypeA, ...

Which would be used a bit like this:
  

type_a = any_type_instance.get_type(TypeA)
special_type = type_a.get_type(SpecialTypeA)




Again, I can get around this by dumping everything in to one module,
but it muddies the organization of the package a bit. This seems like
a problem that would come up a lot. Are there any design paradigms I
can apply here?

  

I'm not an expert, I even don't fully understand your problem,
but having struggled with imports in the past,
I've a solution now, which seems to work quit well.

cheers,
Stef

Cheers

- Rafe


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


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


Re: More elegant way to try running a function X times?

2008-11-20 Thread Steve Holden
Gilles Ganault wrote:
 Hello
 
 As a newbie, it's pretty likely that there's a smarter way to do this,
 so I'd like to check with the experts:
 
 I need to try calling a function 5 times. If successful, move on; If
 not, print an error message, and exit the program:
 
 =
 success = None
 
 for i in range(5):
   #Try to fetch public IP
   success = CheckIP()
   if success:
   break
 
 if not success:
   print Exiting.
   sys.exit()

Use the for statement's else clause: it's there to allow you to
specify code to be executed only when the loop terminates normally.

for i in range(5):
if CheckIP():
break
else:
sys.exit(Could not verify IP address)
... remainder of program ...

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: More elegant way to try running a function X times?

2008-11-20 Thread Banibrata Dutta
On Thu, Nov 20, 2008 at 11:58 PM, Steve Holden [EMAIL PROTECTED] wrote:

 Gilles Ganault wrote:
  Hello
 
  As a newbie, it's pretty likely that there's a smarter way to do this,
  so I'd like to check with the experts:
 
  I need to try calling a function 5 times. If successful, move on; If
  not, print an error message, and exit the program:
 
  =
  success = None
 
  for i in range(5):
#Try to fetch public IP
success = CheckIP()
if success:
break
 
  if not success:
print Exiting.
sys.exit()

 Use the for statement's else clause: it's there to allow you to
 specify code to be executed only when the loop terminates normally.

 for i in range(5):
if CheckIP():
break
 else:
sys.exit(Could not verify IP address)
 ... remainder of program ...


and possibly use 'xrange(5)' instead of 'range(5)' ...

-- 
regards,
Banibrata
http://www.linkedin.com/in/bdutta
http://octapod.wordpress.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Module Structure/Import Design Problem

2008-11-20 Thread Steve Holden
Rafe wrote:
 Hi,
 
 I am in a situation where I feel I am being forced to abandon a clean
 module structure in favor of a large single module. If anyone can save
 my sanity here I would be forever grateful.
 
 My problem is that classes in several modules share a common base
 class which needs to implement a factory method to return instances of
 these same classes.
 
 An example to help illustrate what I mean:
 Lets say I have the following modules with the listed classes:
  - baselib.py   with  BaseClass
  - types.py   with  TypeA, ...
  - special.py   with  SpecialTypeA, ...
 
 Which would be used a bit like this:
 type_a = any_type_instance.get_type(TypeA)
 special_type = type_a.get_type(SpecialTypeA)
 
 
 Again, I can get around this by dumping everything in to one module,
 but it muddies the organization of the package a bit. This seems like
 a problem that would come up a lot. Are there any design paradigms I
 can apply here?
 
Well a simple way to do this is to observe that even when a base class's
method is inherited by an instance of a subclass, when the method is
called the type of self is the subclass. And you can call the
subclass's type to create an instance. Perhaps the following  code would
make it more obvious:

$ cat baseclass.py
class Base(object):
def factory(self, arg):
return type(self)(arg)

[EMAIL PROTECTED] /c/Users/sholden/Projects/Python
$ cat subclass.py
from baseclass import Base

class sub(Base):
  def __init__(self, arg):
print Creating a sub with arg, arg

s = sub(Manual)

thing = s.factory(Auto)
print type(thing)


[EMAIL PROTECTED] /c/Users/sholden/Projects/Python
$ python subclass.py
Creating a sub with arg Manual
Creating a sub with arg Auto
class '__main__.sub'

Hope this helps.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: Module Structure/Import Design Problem

2008-11-20 Thread Steve Holden
Stef Mientki wrote:
 Rafe wrote:
 Hi,

 I am in a situation where I feel I am being forced to abandon a clean
 module structure in favor of a large single module. If anyone can save
 my sanity here I would be forever grateful.

 My problem is that classes in several modules share a common base
 class which needs to implement a factory method to return instances of
 these same classes.

 An example to help illustrate what I mean:
 Lets say I have the following modules with the listed classes:
  - baselib.py   with  BaseClass
  - types.py   with  TypeA, ...
  - special.py   with  SpecialTypeA, ...

 Which would be used a bit like this:
  
 type_a = any_type_instance.get_type(TypeA)
 special_type = type_a.get_type(SpecialTypeA)
 


 Again, I can get around this by dumping everything in to one module,
 but it muddies the organization of the package a bit. This seems like
 a problem that would come up a lot. Are there any design paradigms I
 can apply here?

   
 I'm not an expert, I even don't fully understand your problem,
 but having struggled with imports in the past,
 I've a solution now, which seems to work quit well.
 
That's not very helpful, is it? Were you planning to keep the solution
secret?

regards
 steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


SOAPpy SyntaxError

2008-11-20 Thread [EMAIL PROTECTED]
Hello,

I'm going through the SOAP Web Services portion of Mark Pilgrim's
tutorial and I'm getting this error when trying to build:

python setup.py build
Traceback (most recent call last):
  File setup.py, line 8, in module
from SOAPpy.version import __version__
  File /Users/username/Desktop/SOAPpy-0.12.0/SOAPpy/__init__.py,
line 5, in module
from Client  import *
  File /Users/username/Desktop/SOAPpy-0.12.0/SOAPpy/Client.py, line
46
from __future__ import nested_scopes
SyntaxError: from __future__ imports must occur at the beginning of
the file

I tried moving that line and it didn't help.

Thanks,

Jason
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python image library issue: domain users cannot save files?

2008-11-20 Thread [EMAIL PROTECTED]
I have no problem with the python builtin open which we use dayly.
Thanks for the hints.

Best,
V

On Nov 19, 5:56 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
 En Wed, 19 Nov 2008 13:43:07 -0200, [EMAIL PROTECTED]  
 [EMAIL PROTECTED] escribió:

  Has anyone try to use PIL in a windows domain environment? I am having
  a permission issue. If I am a domain user, even I have the permission
  to write a folder, when I tried to do simple things like Image.open
  (foo.tif).save(bar.tif), i am getting exception IOError (0,
  Error). I tried to set os.umask(0) before I saved the file but the
  same exception threw. But If I am the same domain user with local
  admin permission on a windows box, I have no problem with the same
  script. Does anyone ever have the same situation and know a work
  around for this? Thanks.

 Try using the builtin open() function to create/read/write files. If you  
 have the same issues then you can take away PIL from the question and  
 concentrate on setting the proper permissions for the user running the  
 script.

 --
 Gabriel Genellina

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


Re: Memory error due to the huge/huge input file size

2008-11-20 Thread tejsupra
On Nov 10, 4:47 pm, [EMAIL PROTECTED] wrote:
 Hello Everyone,

 I need to read a .csv file which has a size of 2.26 GB . And I wrote a
 Python script , where I need to read this file. And my Computer has 2
 GB RAM Please see the code as follows:

 
 This program has been developed to retrieve all the promoter sequences
 for the specified
 list of genes in the given cluster

 So, this program will act as a substitute to the whole EZRetrieve
 system

 Input arguments:

 1) Cluster.txt or DowRatClust161718bwithDummy.txt
 2) TransProCrossReferenceAndSequences.csv - This is the file that has
 all the promoter sequences
 3) -2000
 4) 500
 

 import time
 import csv
 import sys
 import linecache
 import re
 from sets import Set
 import gc

 print time.localtime()

 fileInputHandler = open(sys.argv[1],r)
 line = fileInputHandler.readline()

 refSeqIDsinTransPro = []
 promoterSequencesinTransPro = []
 reader2 = csv.reader(open(sys.argv[2],rb))
 reader2_list = []
 reader2_list.extend(reader2)

 for data2 in reader2_list:
    refSeqIDsinTransPro.append(data2[3])
 for data2 in reader2_list:
    promoterSequencesinTransPro.append(data2[4])

 while line:
    l = line.rstrip('\n')
    for j in range(1,len(refSeqIDsinTransPro)):
       found = re.search(l,refSeqIDsinTransPro[j])
       if found:
          promoterSequencesinTransPro[j]  
          print l

    line = fileInputHandler.readline()

 fileInputHandler.close()

 The error that I got is given as follows:
 Traceback (most recent call last):
   File RefSeqsToPromoterSequences.py, line 31, in module
     reader2_list.extend(reader2)
 MemoryError

 I understand that the issue is Memory error and it is caused because
 of the  line reader2_list.extend(reader2). Is there any other
 alternative method in reading the .csv file  line by line?

 sincerely,
 Suprabhath

Thanks a Lot James Mills. It worked

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


Re: Using eval, or something like it...

2008-11-20 Thread Scott David Daniels

r0g wrote:

John Machin wrote:

 You mention variables of a class but you then proceed to poke
at an instance of the class
Check out setattr (and getattr) in the docs.

The former i.e. the variables of an instance of a class. Thanks :-)


Careful here.  Your wording seems to indicate you misunderstand the
Python model.  The instance doesn't have variables (and your class built
nothing that could be called an instance variable).  Think of the
attributes of an instance (or a class) as values attached to (or
associated with) the instance.  If you don't you are setting yourself
up to discover a pile of bugs that you don't understand.

--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Module Structure/Import Design Problem

2008-11-20 Thread Stef Mientki


  
  

I'm not an expert, I even don't fully understand your problem,
but having struggled with imports in the past,
I've a solution now, which seems to work quit well.



That's not very helpful, is it? Were you planning to keep the solution
secret?
  

sorry slip of the keyboard ;-)
http://mientki.ruhosting.nl/data_www/pylab_works/pw_importing.html
cheers,
Stef

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


Fwd: Problem with writing a long line in a text file

2008-11-20 Thread Mohsen Akbari
--- I use notepad to view my txt file. It appears that way in this tool.
--- Here is the output of the debug lines that you mentioned:
 print *line*.find('\n')
-1

print len(*line*)
1528

print repr(line)
'0.0\t3.0\t10.0\t24.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t33.0\t40.0\t40.0\t40.0\t40.0\t32.0\t30.0\t32.0\t26.0\t23.0\t30.0\t32.0\t40.0\t40.0\t40.0\t40.0\t40.0\t40.0\t38.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t24.0\t10.0\t11.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t18.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t17.0\t20.0\t23.0\t30.0\t30.0\t30.0\t27.0\t20.0\t20.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t23.0\t20.0\t20.0\t20.0\t20.0\t10.0\t10.0\t14.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t27.0\t30.0\t30.0\t27.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t19.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t12.0\t10.0\t13.0\t13.0\t10.0\t2.0\t0.0\t3.0\t5.0\t10.0\t5.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t5.0\t0.0\t2.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t16.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t10.0\t18.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t27.0\t30.0\t30.0\t35.0\t40.0\t40.0\t31.0\t20.0\t20.0\t21.0\t30.0\t33.0\t46.0\t50.0\t50.0\t50.0\t48.0\t40.0\t43.0\t50.0\t50.0\t50.0\t56.0\t60.0\t60.0\t60.0\t61.0\t70.0\t70.0\t70.0\t70.0\t75.0\t80.0\t83.0\t90.0\t90.0\t92.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t93.0\t86.0\t80.0\t91.0\t100.0\t100.0\t100.0\t100.0\t98.0\t90.0\t90.0\t90.0\t94.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t90.0\t83.0\t87.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t'

thanks
Mohsen



-- Forwarded message --
From: Mohsen Akbari [EMAIL PROTECTED]
Date: Nov 19, 2008 5:27 PM
Subject: Problem with writing a long line in a text file
To: python-list@python.org

Dear guys,

I'm a newbie in python and I have this problem with the code that I'm
writing. There is a very long line which I wish to output it to a text
file.But when I do this, in the output file, the result appears in two
lines. I thought maybe that's because the maximum possible length of the
text file has been reached so I opened the file and I tried to put some
space at the end of the first line. It wasn't possible to do that for the
first line and the space was placed before the first character of the second
line. I kept pressing space bar to add more spaces and so the whole second
line was moved to the write till it exceeded the first line. I mean the
length of the second line became longer than the first line which means the
text file can accept longer lines.
As a second guess, I thought maybe I had '\n' somewhere in my input string
so I tried to check that by doing:
temp_ =  out_string.find('\n')
print temp_

The result was  -1 which I think means there is not '\n' in my output
string. Now I'm really confused and I don't know what to do. I really
appreciate it if somebody can help me out.

BTW, I'm using windows.

Regards,
Mohsen
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Problem with writing a long line in a text file

2008-11-20 Thread Steve Holden
Mohsen Akbari wrote:
 Dear guys,
 
 I'm a newbie in python and I have this problem with the code that I'm
 writing. There is a very long line which I wish to output it to a text
 file.But when I do this, in the output file, the result appears in two
 lines. I thought maybe that's because the maximum possible length of the
 text file has been reached so I opened the file and I tried to put some
 space at the end of the first line. It wasn't possible to do that for
 the first line and the space was placed before the first character of
 the second line. I kept pressing space bar to add more spaces and so the
 whole second line was moved to the write till it exceeded the first
 line. I mean the length of the second line became longer than the first
 line which means the text file can accept longer lines.
 As a second guess, I thought maybe I had '\n' somewhere in my input
 string so I tried to check that by doing:
 temp_ =  out_string.find('\n')
 print temp_
 
 The result was  -1 which I think means there is not '\n' in my output
 string. Now I'm really confused and I don't know what to do. I really
 appreciate it if somebody can help me out.
 
 BTW, I'm using windows.
 
Then, later:
 --- I use notepad to view my txt file. It appears that way in this tool.
 --- Here is the output of the debug lines that you mentioned:
 print *line*.find('\n')
 -1

 print len(*line*)
 1528

 print repr(line)

'0.0\t3.0\t10.0\t24.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t33.0\t40.0\t40.0\t40.0\t40.0\t32.0\t30.0\t32.0\t26.0\t23.0\t30.0\t32.0\t40.0\t40.0\t40.0\t40.0\t40.0\t40.0\t38.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t24.0\t10.0\t11.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t18.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t17.0\t20.0\t23.0\t30.0\t30.0\t30.0\t27.0\t20.0\t20.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t23.0\t20.0\t20.0\t20.0\t20.0\t10.0\t10.0\t14.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t27.0\t30.0\t30.0\t27.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t19.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t12.0\t10.0\t13.0\t13.0\t10.0\t2.0\t0.0\t3.0\t5.0\t10.0\t5.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t5.0\t0.0\t2.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t16.0\t20
.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t10.0\t18.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t27.0\t30.0\t30.0\t35.0\t40.0\t40.0\t31.0\t20.0\t20.0\t21.0\t30.0\t33.0\t46.0\t50.0\t50.0\t50.0\t48.0\t40.0\t43.0\t50.0\t50.0\t50.0\t56.0\t60.0\t60.0\t60.0\t61.0\t70.0\t70.0\t70.0\t70.0\t75.0\t80.0\t83.0\t90.0\t90.0\t92.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t93.0\t86.0\t80.0\t91.0\t100.0\t100.0\t100.0\t100.0\t98.0\t90.0\t90.0\t90.0\t94.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t90.0\t83.0\t87.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t'

 thanks
 Mohsen



There is only one line in your file. Notepad just can't display lines
beyond a certain length, is all, so it inserts a line break in the
window (but not in the file).

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: help with comparison

2008-11-20 Thread tekion
On Nov 19, 11:36 pm, George Sakkis [EMAIL PROTECTED] wrote:
 On Nov 19, 10:21 pm,tekion[EMAIL PROTECTED] wrote:



  Hi,
  Could some one take a look at the below code snipet which keep
  failing:

  import optparse
  p = optparse.OptionParser(description=script to do stuff,
  prog=myscript.py, )
  p.add_option(-c --compress, help=0 is noncompress)
  function1(options.compress)

  here's what the what function definition looks like:
  function1(zipfile) :
  if (zipfile == 1):
 do stuff here with for compress file
  else
 do stuff here

  when I call the script myscript.py 1, the above test keeps falling
  to the else clause.  I am thinking the object zipfile is not the same
  as 1. Any thoughts as how I should test if the argument being pass
  in and parse by optparse is 1 or 0?  Thanks.

 1 (without quotes) is not the same as 1 (with quotes); the first is
 an integer, the second a string. optparse returns strings by default,
 so the easiest change would be to make the check 'if zipfile == 1'.

 Even better, since it's a boolean option, pass action=store_true to
 p.add_option(). The test then is reduced to if zipfile and the
 program is to be called by myscript.py -c. Read the docs [1] for
 more details.

 HTH,
 George

 [1]http://docs.python.org/library/optparse.html#standard-option-actions

Thanks. This fixed it.
--
http://mail.python.org/mailman/listinfo/python-list


Re: More elegant way to try running a function X times?

2008-11-20 Thread Boris Borcic

Tim Chase wrote:

success = None
for i in range(5):
#Try to fetch public IP
success = CheckIP()
if success:
break
if not success:
print Exiting.
sys.exit()

Though a bit of an abuse, you can use

  if not any(CheckIP() for _ in range(5)):
print Exiting
sys.exit()


I don't see why you speak of abuse, bit of abuse would be, say if you 
replaced range(5) by '12345' to win a char; but otoh I think you 
misspelled any() for all().


The OP's code break'ed (broke?) upon the first success, rather than 
checking all of them.  Thus, it would be any() rather than all().  Using 
all() would require 5 successful calls to CheckIP(), rather than 
one-out-of-five successful calls.


Right. So it could also be written  if all(not CheckIP()... . Perhaps more 
closely re-telling the OP's ?




As for abuse, the for _ in iterable always feels a little hokey to 
me.  It works, but feels warty.


I guess this means you did not learn Prolog before Python ?

Cheers, BB

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


Python 3 __cmp__ semantic change?

2008-11-20 Thread Johannes Bauer
Hello group,

I'm porting some code of mine to Python 3. One class has the __cmp__
operator overloaded, but comparison doesn't seem to work anymore with that:

Traceback (most recent call last):
  File ./parse, line 25, in module
print(x  y)
TypeError: unorderable types: IP()  IP()

Was there some kind of semantic change?

Kind regards,
Johannes

-- 
Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit,
verlästerung von Gott, Bibel und mir und bewusster Blasphemie.
 -- Prophet und Visionär Hans Joss aka HJP in de.sci.physik
 [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: spam update

2008-11-20 Thread News123
Hi,


Grant Edwards wrote:

 . . .  It does penalizes legitimate users who post
 from Google Groups.  They've made the choice to use the same
 posting conduit as spammers, and presumably they know the
 consequences.

Hmm I made the chooice to use google groups because sometimes I like to
write / read news from work (and there's no nntp access)

I didn't know aboug gmane.

Finding a solution which doesn't penalize gmail users is still a good
idea I think.

When having time to play I'll look into gmane though


bye


N
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread Inyeol . Lee
On Nov 20, 1:18 pm, Johannes Bauer [EMAIL PROTECTED] wrote:
 Hello group,

 I'm porting some code of mine to Python 3. One class has the __cmp__
 operator overloaded, but comparison doesn't seem to work anymore with that:

 Traceback (most recent call last):
   File ./parse, line 25, in module
     print(x  y)
 TypeError: unorderable types: IP()  IP()

 Was there some kind of semantic change?

Overload __lt__ method.

Inyeol
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Problem with writing a long line in a text file

2008-11-20 Thread Matthew Barnett

Steve Holden wrote:

Mohsen Akbari wrote:

Dear guys,

I'm a newbie in python and I have this problem with the code that I'm
writing. There is a very long line which I wish to output it to a text
file.But when I do this, in the output file, the result appears in two
lines. I thought maybe that's because the maximum possible length of the
text file has been reached so I opened the file and I tried to put some
space at the end of the first line. It wasn't possible to do that for
the first line and the space was placed before the first character of
the second line. I kept pressing space bar to add more spaces and so the
whole second line was moved to the write till it exceeded the first
line. I mean the length of the second line became longer than the first
line which means the text file can accept longer lines.
As a second guess, I thought maybe I had '\n' somewhere in my input
string so I tried to check that by doing:
temp_ =  out_string.find('\n')
print temp_

The result was  -1 which I think means there is not '\n' in my output
string. Now I'm really confused and I don't know what to do. I really
appreciate it if somebody can help me out.

BTW, I'm using windows.


Then, later:

--- I use notepad to view my txt file. It appears that way in this tool.
--- Here is the output of the debug lines that you mentioned:
print *line*.find('\n')
-1

print len(*line*)
1528

print repr(line)


'0.0\t3.0\t10.0\t24.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t33.0\t40.0\t40.0\t40.0\t40.0\t32.0\t30.0\t32.0\t26.0\t23.0\t30.0\t32.0\t40.0\t40.0\t40.0\t40.0\t40.0\t40.0\t38.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t24.0\t10.0\t11.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t18.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t17.0\t20.0\t23.0\t30.0\t30.0\t30.0\t27.0\t20.0\t20.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t30.0\t23.0\t20.0\t20.0\t20.0\t20.0\t10.0\t10.0\t14.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t27.0\t30.0\t30.0\t27.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t19.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t12.0\t10.0\t13.0\t13.0\t10.0\t2.0\t0.0\t3.0\t5.0\t10.0\t5.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t5.0\t0.0\t2.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t10.0\t16.0\t

20

.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t10.0\t18.0\t20.0\t20.0\t20.0\t20.0\t20.0\t20.0\t27.0\t30.0\t30.0\t35.0\t40.0\t40.0\t31.0\t20.0\t20.0\t21.0\t30.0\t33.0\t46.0\t50.0\t50.0\t50.0\t48.0\t40.0\t43.0\t50.0\t50.0\t50.0\t56.0\t60.0\t60.0\t60.0\t61.0\t70.0\t70.0\t70.0\t70.0\t75.0\t80.0\t83.0\t90.0\t90.0\t92.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t93.0\t86.0\t80.0\t91.0\t100.0\t100.0\t100.0\t100.0\t98.0\t90.0\t90.0\t90.0\t94.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t100.0\t90.0\t83.0\t87.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t90.0\t'

thanks
Mohsen




There is only one line in your file. Notepad just can't display lines
beyond a certain length, is all, so it inserts a line break in the
window (but not in the file).

Some text editors can display very long lines, others can't and just 
wrap them when displaying. Notepad can't.

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


Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread Johannes Bauer
[EMAIL PROTECTED] schrieb:
 On Nov 20, 1:18 pm, Johannes Bauer [EMAIL PROTECTED] wrote:
 Hello group,

 I'm porting some code of mine to Python 3. One class has the __cmp__
 operator overloaded, but comparison doesn't seem to work anymore with that:

 Traceback (most recent call last):
   File ./parse, line 25, in module
 print(x  y)
 TypeError: unorderable types: IP()  IP()

 Was there some kind of semantic change?
 
 Overload __lt__ method.

Well, of course I could do that, but the python doc says:

Called by comparison operations if rich comparison (see above) is not
defined.
http://www.python.org/doc/2.5.2/ref/customization.html

And my code works just fine with 2.5 - only on 3.0 it doesn't work
anymore. Why is that?

Regards,
Johannes

-- 
Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit,
verlästerung von Gott, Bibel und mir und bewusster Blasphemie.
 -- Prophet und Visionär Hans Joss aka HJP in de.sci.physik
 [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread Christian Heimes

Johannes Bauer wrote:

Hello group,

I'm porting some code of mine to Python 3. One class has the __cmp__
operator overloaded, but comparison doesn't seem to work anymore with that:


__cmp__ is gone

Christian

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


Re: spam update

2008-11-20 Thread Grant Edwards
On 2008-11-20, News123 [EMAIL PROTECTED] wrote:

 I didn't know aboug gmane.

The UI isn't as fancy as Google's, but it's a way of separating
yourself from the spammers.

 Finding a solution which doesn't penalize gmail users is still
 a good idea I think.

Of course.  One problem is that Google doesn't seem to be
interested in doing anything about the problem.

I tried to come up with filter patterns that would filter out
the spam coming from GoogleGroups, but it's a constantly moving
target: filters that work well today, don't work well tomorrow.

I finally gave up and filtered out anything posted from google. :/

-- 
Grant Edwards   grante Yow! Oh my GOD -- the
  at   SUN just fell into YANKEE
   visi.comSTADIUM!!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread Steve Holden
Johannes Bauer wrote:
 [EMAIL PROTECTED] schrieb:
 On Nov 20, 1:18 pm, Johannes Bauer [EMAIL PROTECTED] wrote:
 Hello group,

 I'm porting some code of mine to Python 3. One class has the __cmp__
 operator overloaded, but comparison doesn't seem to work anymore with that:

 Traceback (most recent call last):
   File ./parse, line 25, in module
 print(x  y)
 TypeError: unorderable types: IP()  IP()

 Was there some kind of semantic change?
 Overload __lt__ method.
 
 Well, of course I could do that, but the python doc says:
 
 Called by comparison operations if rich comparison (see above) is not
 defined.
 http://www.python.org/doc/2.5.2/ref/customization.html
 
 And my code works just fine with 2.5 - only on 3.0 it doesn't work
 anymore. Why is that?

Well the Python 2.5 documentation can't be regarded as a reliable guide
to what to expect in 3.0 ...

You will observe that __cmp__ no longer appears in the index:

http://docs.python.org/dev/3.0/genindex-_.html

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: Air Force1 and Air Jordan shoes PAYPAL wholesale

2008-11-20 Thread r0g
Pierre-Alain Dorange wrote:
 air force1 shoes [EMAIL PROTECTED] wrote:
 
 air force1 shoes. air force1 high shoes. air force1 light shoes
   File stdin, line 1
 air force1 shoes. air force1 high shoes. air force1 light shoes
  ^
 SyntaxError: invalid syntax
 
 

LOL! X0D
--
http://mail.python.org/mailman/listinfo/python-list


Tools for using virtual environments and PEP 370

2008-11-20 Thread Дамјан Георгиевски
Python 2.6 implemented PEP 370: Per-user site-packages Directory[1]

Now, are there any tools I could use to create and activate virtual 
environments like workingenv, virtualenv etc. but that will use 
PYTHONUSERBASE instead of hard-linking the python program.


[1]
http://docs.python.org/dev/whatsnew/2.6.html#pep-370-per-user-site-packages-directory


-- 
дамјан ( http://softver.org.mk/damjan/ )

When you do things right, people won't be sure if you did anything at all.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Programming exercises/challenges

2008-11-20 Thread r0g
Edwin wrote:
 On Nov 18, 6:39 pm, [EMAIL PROTECTED] wrote:
 Hi guys,

 I'm learning Python by teaching myself, and after going through several
 tutorials I feel like I've learned the basics. Since I'm not taking a
 class or anything, I've been doing challenges/programs to reinforce the
 material and improve my skills. I started out with stuff like Guess my
 number games, hangman, etc. and moved on to making poker and card
 games to work with classes. For GUIs I created games like minesweeper,
 and a GUI stock portfolio tracker. I am out of ideas and am looking 
 forprogrammingprojects, challenges, or programs that have helped you'll
 learn. I'm working on the project Euler problems, but I find that they
 don't really help myprogrammingskills; they are more math focused.
 Suggestions? What has been useful or interesting to you? I'd also
 welcome sources of textbook type problems, because the ones provided in
 tutorials tend to be repetitive.

 Thanks,
 Ben
 
 I'm also learning Python by myself, downloading open ebooks, reading
 tutorials, reading other people's code, etc. and in order to put my
 knowledge into practice I've been writing small programs to solve my
 everyday computer problems: a simple email client (because sometimes
 it seems to me that email clients now have so many features and
 preferences) that reads my fetchmailrc, a diary manager compatible
 with my Emacs diary file (sometimes I don't want to open Emacs for a
 quick note)... in general I try to solve problems related to my own
 workflow.
 
 I also try to play with some of my girlfriend's ideas on computer use:
 she came up with an idea for a calculator with which she could easily
 keep track of our bills (but found financial software a bit
 complicated for simple tasks, once again, too many features and
 preferences) so I started to code a small multi-touch app as
 intuitive as possible (and still working on it).
 
 What I'm saying is that I've found useful not to think about
 programming itself but just think of it as a medium to solve my own
 (common) problems.
 
 Best regards,
 E.

Spotted this on facebook t'other day, don't know if it's still active
and don't have time to check really.

http://www.facebook.com/jobs_puzzles/index.php

I've found writing your own servers can be an good hands on way of
learning languages and various internet protocols, just make sure you
have Wireshark to hand for debugging!

Roger.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread Ben Finney
Steve Holden [EMAIL PROTECTED] writes:

 You will observe that __cmp__ no longer appears in the index:
 
 http://docs.python.org/dev/3.0/genindex-_.html

I searched in vain for an official description of this changed
behaviour. Where can we find an official description of how
comparisons are different in Python 3.0?

-- 
 \  “[Entrenched media corporations will] maintain the status quo, |
  `\   or die trying. Either is better than actually WORKING for a |
_o__)  living.” —ringsnake.livejournal.com, 2007-11-12 |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread Steve Holden
Ben Finney wrote:
 Steve Holden [EMAIL PROTECTED] writes:
 
 You will observe that __cmp__ no longer appears in the index:

 http://docs.python.org/dev/3.0/genindex-_.html
 
 I searched in vain for an official description of this changed
 behaviour. Where can we find an official description of how
 comparisons are different in Python 3.0?
 
If it's not present then it would be worth reporting it as a 3.0 bug -
there's still time to get it in, as the release isn't due until early
December.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread Terry Reedy

Ben Finney wrote:

Steve Holden [EMAIL PROTECTED] writes:


You will observe that __cmp__ no longer appears in the index:

http://docs.python.org/dev/3.0/genindex-_.html


I searched in vain for an official description of this changed
behaviour. Where can we find an official description of how
comparisons are different in Python 3.0?


I was going to say look in What's New, but the __cmp__ removal is 
missing.  So I filed

http://bugs.python.org/issue4372

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


Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread Christian Heimes

Terry Reedy wrote:
I was going to say look in What's New, but the __cmp__ removal is 
missing.  So I filed

http://bugs.python.org/issue4372


The whatsnew section of Python 3.0 is still empty. Guido didn't had time 
to write it. http://bugs.python.org/issue2306


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


How to get the class instance of a passed method ?

2008-11-20 Thread Stef Mientki

hello,

if I pass a class method to a function,
is it possible to determine the class instance in that  function ?

class test ( object ) :
 def My_Method ( self ) :
   return 22

def do_something ( parameter ) :
 # here I want to determine My_Instance

My_Instance = test ()
do something ( My_Instance.My_Method )


thanks
Stef Mientki
--
http://mail.python.org/mailman/listinfo/python-list


How to get the class instance of a passed method ?

2008-11-20 Thread Stef Mientki

hello,

if I pass a class method to a function,
is it possible to determine the class instance in that  function ?

class test ( object ) :
 def My_Method ( self ) :
   return 22

def do_something ( parameter ) :
 # here I want to determine My_Instance

My_Instance = test ()
do something ( My_Instance.My_Method )


thanks
Stef Mientki
--
http://mail.python.org/mailman/listinfo/python-list


function parameter scope python 2.5.2

2008-11-20 Thread J Kenneth King

I recently encountered some interesting behaviour that looks like a bug
to me, but I can't find the appropriate reference to any specifications
to clarify whether it is a bug.

Here's the example code to demonstrate the issue:

class SomeObject(object):

def __init__(self):
self.words = ['one', 'two', 'three', 'four', 'five']

def main(self):
recursive_func(self.words)
print self.words

def recursive_func(words):
if len(words)  0:
word = words.pop()
print Popped: %s % word
recursive_func(words)
else:
print Done

if __name__ == '__main__':
weird_obj = SomeObject()
weird_obj.main()


The output is:

Popped: five
Popped: four
Popped: three
Popped: two
Popped: one
Done
[]

Of course I expected that recursive_func() would receive a copy of
weird_obj.words but it appears to happily modify the object.

Of course a work around is to explicitly create a copy of the object
property befor passing it to recursive_func, but if it's used more than
once inside various parts of the class that could get messy.

Any thoughts? Am I crazy and this is supposed to be the way python works?
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to get the class instance of a passed method ?

2008-11-20 Thread Christian Heimes

Stef Mientki wrote:

hello,

if I pass a class method to a function,
is it possible to determine the class instance in that  function ?

class test ( object ) :
 def My_Method ( self ) :
   return 22

def do_something ( parameter ) :
 # here I want to determine My_Instance

My_Instance = test ()
do something ( My_Instance.My_Method )




 class Example(object):

... def method(self):
... pass
...

example = Example()
example.method.im_self

__main__.Example object at 0x7fc3cdb5b650

example.method.im_class

class '__main__.Example'

example.method.im_func

function method at 0x7fc3cdb566e0

Christian

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


Re: function parameter scope python 2.5.2

2008-11-20 Thread J Kenneth King
J Kenneth King [EMAIL PROTECTED] writes:

 I recently encountered some interesting behaviour that looks like a bug
 to me, but I can't find the appropriate reference to any specifications
 to clarify whether it is a bug.

 Here's the example code to demonstrate the issue:

 class SomeObject(object):

 def __init__(self):
 self.words = ['one', 'two', 'three', 'four', 'five']

 def main(self):
 recursive_func(self.words)
 print self.words

 def recursive_func(words):
 if len(words)  0:
 word = words.pop()
 print Popped: %s % word
 recursive_func(words)
 else:
 print Done

 if __name__ == '__main__':
 weird_obj = SomeObject()
 weird_obj.main()


 The output is:

 Popped: five
 Popped: four
 Popped: three
 Popped: two
 Popped: one
 Done
 []

 Of course I expected that recursive_func() would receive a copy of
 weird_obj.words but it appears to happily modify the object.

 Of course a work around is to explicitly create a copy of the object
 property befor passing it to recursive_func, but if it's used more than
 once inside various parts of the class that could get messy.

 Any thoughts? Am I crazy and this is supposed to be the way python works?

Of course, providing a shallow (or deep as necessary) copy makes it
work, I'm curious as to why the value passed as a parameter to a
function outside the class is passed a reference rather than a copy.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to get the class instance of a passed method ?

2008-11-20 Thread Stef Mientki

Christian Heimes wrote:

thanks Christian,

cheers,
Stef

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


Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread Johannes Bauer
Steve Holden schrieb:

 If it's not present then it would be worth reporting it as a 3.0 bug -
 there's still time to get it in, as the release isn't due until early
 December.

Seems it was removed on purpose - I'm sure there was a good reason for
that, but may I ask why? Instead of the sleek __cmp__ function I had
earlier, I now have code like:


def __lt__(self, other):
return self.__cmp__(other)  0

def __le__(self, other):
return self.__cmp__(other)  0

def __gt__(self, other):
return self.__cmp__(other)  0

def __ge__(self, other):
return self.__cmp__(other) = 0

Does anyone know the reason why __cmp__ was discarded?

Kind regards,
Johannes

-- 
Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit,
verlästerung von Gott, Bibel und mir und bewusster Blasphemie.
 -- Prophet und Visionär Hans Joss aka HJP in de.sci.physik
 [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: function parameter scope python 2.5.2

2008-11-20 Thread alex23
On Nov 21, 9:40 am, J Kenneth King [EMAIL PROTECTED] wrote:
 Of course, providing a shallow (or deep as necessary) copy makes it
 work, I'm curious as to why the value passed as a parameter to a
 function outside the class is passed a reference rather than a copy.

You're passing neither a reference nor a copy, you're passing the
object (in this case a list) directly:

http://effbot.org/zone/call-by-object.htm
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread Terry Reedy

Christian Heimes wrote:

Terry Reedy wrote:
I was going to say look in What's New, but the __cmp__ removal is 
missing.  So I filed

http://bugs.python.org/issue4372


The whatsnew section of Python 3.0 is still empty. Guido didn't had time 
to write it. http://bugs.python.org/issue2306


What's New in Python 3.0 is incomplete but definitely not empty, and it 
is part of the doc set.


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


Re: Using eval, or something like it...

2008-11-20 Thread r0g
Scott David Daniels wrote:
 r0g wrote:
 John Machin wrote:
  You mention variables of a class but you then proceed to poke
 at an instance of the class
 Check out setattr (and getattr) in the docs.
 The former i.e. the variables of an instance of a class. Thanks :-)
 
 Careful here.  Your wording seems to indicate you misunderstand the
 Python model.  The instance doesn't have variables (and your class built
 nothing that could be called an instance variable).  Think of the
 attributes of an instance (or a class) as values attached to (or
 associated with) the instance.  If you don't you are setting yourself
 up to discover a pile of bugs that you don't understand.
 
 --Scott David Daniels
 [EMAIL PROTECTED]


OK now I'm confused, let me explain how I see things at the moment and
you can correct me...

A class is like a template which combines a complex data type (made from
a combination of other data types) and the methods that operate on that
data type.

You generally don't work with classes directly but you make instances of
them, each instance has it's own internal state and methods, initially
these are the same as the templates but can be changed or overridden
without affecting the state of any other instances you might have.

While the perceived wisdom is that you should encapsulate all the
methods you need to modify your classes' state within the class itself
Python does (for better or worse) permit you to reach inside a class and
futz with it's state directly from outside.

The bits of an instance's state one might futz with (from within or
without) i.e. the primitives that make up the complex object the class
is a representation of, I think of as it's variables.

It would seem from this setattr function that the proper term for these
is 'attributes'. That for many years I have considered pretty much any
named thing that may vary a 'variable' might be at the root of the
problem here as it's a very un-specific term...

So I gather you are saying that the fragments of state within a class
are so distinct from ordinary common or garden variables that it is
incorrect to think of them, or describe them, as variables, much like
quarks should not really be regarded as distinct particles, and they
should only be thought of and described as 'attributes' to avoid confusion?

Is this correct enough for me to avoid the aforementioned bug pile?

Also then, what _is_ an instance variable ?

Thanks,


Roger.

Q: How many pedants does it take to change a lightbulb?
A: Well actually you mean replace a lightbulb.
Q: Have you ever kissed a girl?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Optional parameter object re-used when instantiating multiple objects

2008-11-20 Thread alex23
On Nov 20, 10:42 pm, Aaron Brady [EMAIL PROTECTED] wrote:
 At first, I would expect it to define them at compile-time.  Then,
 when I learned there was no such thing, I would expect it to define
 them at execute-time.  What does that have to do with evaluating a
 default argument?

It has -everything- to do with it when we're talking about the
defining of functions, and certainly a lot more relevance than straw
man arguments on the behaviour of browser buttons.

You said that you would expect it to define them at execute-time. So
is that when the interpreter first hits the def or when the
interpreter hits every single function call? Because I personally
consider it to clearly occur at the point of definition and not at the
point of calling.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread skip

Johannes Seems it was removed on purpose - I'm sure there was a good
Johannes reason for that, but may I ask why? 

Start here:

http://www.mail-archive.com/[EMAIL PROTECTED]/msg11474.html

Also, a comment to this blog post suggests creating a CmpMixin:

http://oakwinter.com/code/porting-setuptools-to-py3k/

Skip
--
http://mail.python.org/mailman/listinfo/python-list


Re: Optional parameter object re-used when instantiating multiple objects

2008-11-20 Thread Aaron Brady
On Nov 20, 5:54 pm, alex23 [EMAIL PROTECTED] wrote:
 On Nov 20, 10:42 pm, Aaron Brady [EMAIL PROTECTED] wrote:

  At first, I would expect it to define them at compile-time.  Then,
  when I learned there was no such thing, I would expect it to define
  them at execute-time.  What does that have to do with evaluating a
  default argument?

 It has -everything- to do with it when we're talking about the
 defining of functions, and certainly a lot more relevance than straw
 man arguments on the behaviour of browser buttons.

 You said that you would expect it to define them at execute-time. So
 is that when the interpreter first hits the def or when the
 interpreter hits every single function call? Because I personally
 consider it to clearly occur at the point of definition and not at the
 point of calling.

Why, I would expect the interpreter to define the functions when it
first hits the def, that is, at the point of definition.
--
http://mail.python.org/mailman/listinfo/python-list


How to run a python app in the background?

2008-11-20 Thread kevintylr
I'm a beginning programmer writing a tiny app with a TkInter GUI.
Desired functionality:
When the user enters a time interval, I want the windows to disappear,
and the program to lie dormant until the scheduled time (currently
using sched module), when it would pop up another window and execute a
command.

Current functionality:
When the user clicks through a showinfo() window, root.quit() is
executed. As I understand it, the program will then complete the
commands that come after root.mainloop(), where I have put
schedule.entry(...) and schedule.run().
The problem is that the windows just hang until the schedule event
happens. The schedule is using time.sleep as the delay. And I have no
idea how I'd create a notification popup when the command runs.

Is there any obvious solution to this problem? Or a tricky solution?
Should I put the scheduler before root.mainloop()? Can I still kill
the main window if I do that?
I want the app to be totally silent during the interim period.

Thanks for your help
Kevin
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread Terry Reedy

Johannes Bauer wrote:

Steve Holden schrieb:


If it's not present then it would be worth reporting it as a 3.0 bug -
there's still time to get it in, as the release isn't due until early
December.


Seems it was removed on purpose - I'm sure there was a good reason for
that, but may I ask why? Instead of the sleek __cmp__ function I had
earlier, I now have code like:


def __lt__(self, other):
return self.__cmp__(other)  0

def __le__(self, other):
return self.__cmp__(other)  0

def __gt__(self, other):
return self.__cmp__(other)  0

def __ge__(self, other):
return self.__cmp__(other) = 0

Does anyone know the reason why __cmp__ was discarded?


See previous threads, including recent one about sorting.

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


Searching for Regular Expressions in a string WITH overlap

2008-11-20 Thread Ben
I apologize in advance for the newbie question.  I'm trying to figure
out a way to find all of the occurrences of a regular expression in a
string including the overlapping ones.

For example, given the string 123456789

I'd like to use the RE ((2)|(4))[0-9]{3} to get the following matches:

2345
4567

Here's what I'm trying so far:
code
#!/usr/bin/env python

import re, repr, sys

string = 123456789

pattern = '(((2)|(4))[0-9]{3})'

r1 = re.compile(pattern)

stringList = r1.findall(string)

for string in stringList:
print string type is:, type(string)
print string is:, string
/code

Which produces:
code
string type is: type 'tuple'
string is: ('2345', '2', '2', '')
/code

I understand that the findall method only returns the non-overlapping
matches.  I just haven't figured out a function that gives me the
matches including the overlap.  Can anyone point me in the right
direction?  I'd also really like to understand why it returns a tuple
and what the '2', '2' refers to.

Thanks for your help!
-Ben
--
http://mail.python.org/mailman/listinfo/python-list


Re: function parameter scope python 2.5.2

2008-11-20 Thread George Sakkis
On Nov 20, 6:40 pm, J Kenneth King [EMAIL PROTECTED] wrote:
 J Kenneth King [EMAIL PROTECTED] writes:



  I recently encountered some interesting behaviour that looks like a bug
  to me, but I can't find the appropriate reference to any specifications
  to clarify whether it is a bug.

  Here's the example code to demonstrate the issue:

  class SomeObject(object):

      def __init__(self):
          self.words = ['one', 'two', 'three', 'four', 'five']

      def main(self):
          recursive_func(self.words)
          print self.words

  def recursive_func(words):
      if len(words)  0:
          word = words.pop()
          print Popped: %s % word
          recursive_func(words)
      else:
          print Done

  if __name__ == '__main__':
      weird_obj = SomeObject()
      weird_obj.main()

  The output is:

  Popped: five
  Popped: four
  Popped: three
  Popped: two
  Popped: one
  Done
  []

  Of course I expected that recursive_func() would receive a copy of
  weird_obj.words but it appears to happily modify the object.

  Of course a work around is to explicitly create a copy of the object
  property befor passing it to recursive_func, but if it's used more than
  once inside various parts of the class that could get messy.

  Any thoughts? Am I crazy and this is supposed to be the way python works?

 Of course, providing a shallow (or deep as necessary) copy makes it
 work, I'm curious as to why the value passed as a parameter to a
 function outside the class is passed a reference rather than a copy.

Why should it be a copy by default ? In Python all copies have to be
explicit.

George
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread George Sakkis
On Nov 20, 6:58 pm, [EMAIL PROTECTED] wrote:

     Johannes Seems it was removed on purpose - I'm sure there was a good
     Johannes reason for that, but may I ask why?

 Start here:

     http://www.mail-archive.com/[EMAIL PROTECTED]/msg11474.html

 Also, a comment to this blog post suggests creating a CmpMixin:

    http://oakwinter.com/code/porting-setuptools-to-py3k/

 Skip

Dropping __cmp__ without providing implicit or at least easy explicit
[1] total ordering is (was?) a mistake; it opens the door to subtle
bugs or redundant boilerplate code.

[1] E.g. http://code.activestate.com/recipes/576529/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Searching for Regular Expressions in a string WITH overlap

2008-11-20 Thread Matimus
On Nov 20, 4:31 pm, Ben [EMAIL PROTECTED] wrote:
 I apologize in advance for the newbie question.  I'm trying to figure
 out a way to find all of the occurrences of a regular expression in a
 string including the overlapping ones.

 For example, given the string 123456789

 I'd like to use the RE ((2)|(4))[0-9]{3} to get the following matches:

 2345
 4567

 Here's what I'm trying so far:
 code
 #!/usr/bin/env python

 import re, repr, sys

 string = 123456789

 pattern = '(((2)|(4))[0-9]{3})'

 r1 = re.compile(pattern)

 stringList = r1.findall(string)

 for string in stringList:
         print string type is:, type(string)
         print string is:, string
 /code

 Which produces:
 code
 string type is: type 'tuple'
 string is: ('2345', '2', '2', '')
 /code

 I understand that the findall method only returns the non-overlapping
 matches.  I just haven't figured out a function that gives me the
 matches including the overlap.  Can anyone point me in the right
 direction?  I'd also really like to understand why it returns a tuple
 and what the '2', '2' refers to.

 Thanks for your help!
 -Ben

'findall' returns a list of matched groups. A group is anything
surrounded by parens. The groups are ordered based on the position of
the opening paren. so, the first result is matching the parens you
have around the whole expression, the second one is matching the
parens that are around '(2)|(4)', the third is matching '(2)', and the
last one is matching '(4)', which is empty.

I don't know of a way to find all overlapping strings automatically. I
would just do something like this:

 import re
 text = 0123456789
 p = re.compile(r(?:2|4)[0-9]{3}) # The (?:...) is a way of isolating the 
 values without grouping them.
 start = 0
 found = []
 while True:
... m = p.search(text, start)
... if m is None:
... break
... start = m.start() + 1
... found.append(m.group(0))
...
 found
['2345', '4567']


Matt
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using eval, or something like it...

2008-11-20 Thread Chris Rebert
On Thu, Nov 20, 2008 at 3:54 PM, r0g [EMAIL PROTECTED] wrote:
 Scott David Daniels wrote:
 r0g wrote:
 John Machin wrote:
  You mention variables of a class but you then proceed to poke
 at an instance of the class
 Check out setattr (and getattr) in the docs.
 The former i.e. the variables of an instance of a class. Thanks :-)

 Careful here.  Your wording seems to indicate you misunderstand the
 Python model.  The instance doesn't have variables (and your class built
 nothing that could be called an instance variable).  Think of the
 attributes of an instance (or a class) as values attached to (or
 associated with) the instance.  If you don't you are setting yourself
 up to discover a pile of bugs that you don't understand.

 --Scott David Daniels
 [EMAIL PROTECTED]


 OK now I'm confused, let me explain how I see things at the moment and
 you can correct me...

 A class is like a template which combines a complex data type (made from
 a combination of other data types) and the methods that operate on that
 data type.

 You generally don't work with classes directly but you make instances of
 them, each instance has it's own internal state and methods, initially
 these are the same as the templates but can be changed or overridden
 without affecting the state of any other instances you might have.

 While the perceived wisdom is that you should encapsulate all the
 methods you need to modify your classes' state within the class itself
 Python does (for better or worse) permit you to reach inside a class and
 futz with it's state directly from outside.

 The bits of an instance's state one might futz with (from within or
 without) i.e. the primitives that make up the complex object the class
 is a representation of, I think of as it's variables.

 It would seem from this setattr function that the proper term for these
 is 'attributes'. That for many years I have considered pretty much any
 named thing that may vary a 'variable' might be at the root of the
 problem here as it's a very un-specific term...

 So I gather you are saying that the fragments of state within a class
Within an instance
 are so distinct from ordinary common or garden variables that it is
 incorrect to think of them, or describe them, as variables, much like
 quarks should not really be regarded as distinct particles, and they
 should only be thought of and described as 'attributes' to avoid confusion?

 Is this correct enough for me to avoid the aforementioned bug pile?

Yes, I think so.


 Also then, what _is_ an instance variable ?

Metasyntatic variables:
  C - some class
  x - some instance
  y - the word after the dot in the expression: x.y


My working definitions based on my knowledge of Python:

Attribute - y is an attribute of x. Includes instance variables,
properties, and dynamically generated attributes. Since x.y really
ends up doing x.__getattribute__(y) behind the scenes, overriding
__getattribute__ lets you make attribute lookup more dynamic and have
it do interesting things. For example, you could write a class
overriding __getattribute__ so that x.y (for any valid Python name y)
opened a file with the name y and returned a file object for this file
(i.e. x.z returns file(z,w), x.q returns file(q,w), etc
without enumerating q, z, etc anywhere in the class).

Instance variable - In `x.y`, y is an instance variable of x if it's
stored in x.__dict__ or x.__slots__, it's not a method of x (though it
can be a function), and it's not a property.

Property - y is a property if x.y causes a method call and returns the
result of said method call. Basically, x.y becomes equivalent to x.z()
if y is a property. Properties can also allow `x.y = a` to be
equivalent to `x.z(a)` and `del x.y` to be equivalent to `x.z()`.
Properties are created using the built-in function property()

Class variable - Unless you're using metaclasses, in C.y, y is always
a class variable of C. Thus, methods are technically also class
variables. Using metaclasses, C is both a class itself and an instance
of another class D, in which case the definition of instance
variable (interpreted with regards to C being an instance of D)
applies to whether y is a class variable of C or not.

Class method - Created using the built-in function classmethod()

Essentially, attribute lookup is very dynamic in Python, which
complicates things a good bit, so the only thing we know for sure
about x.y is that y is an attribute of x.

Cheers,
Chris
-- 
Follow the path of the Iguana...
http://rebertia.com


 Thanks,


 Roger.

 Q: How many pedants does it take to change a lightbulb?
 A: Well actually you mean replace a lightbulb.
 Q: Have you ever kissed a girl?
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Test if list contains another list

2008-11-20 Thread str1442

Ali wrote:

Its funny, I just visited this problem last week.

http://dulceetutile.blogspot.com/2008/11/strange-looking-python-
statement_17.html

./Ali
--
http://mail.python.org/mailman/listinfo/python-list


  

That use of reduce is nice, but you better use all() / any().
--
http://mail.python.org/mailman/listinfo/python-list


Re: Tyrton ERP 1.0 released

2008-11-20 Thread erp software
On Nov 18, 3:26 pm, Hartmut Goebel [EMAIL PROTECTED] wrote:
 On behalf of the Tryton team I'm proud to announce Tryton 1.0,
 an Open Source application platform and ERP. It provides modularity,
 scalability and security.

 This is the first release of Tryton, a fork of OpenERP (formally known
 as TinyERP). This release is the result of 8 months of intensive work
 which consist of the rewrite of all modules (including contact, sale,
 purchase, invoice, analytic and general account and inventory
 management) and some parts of the core features. It is available in four
 languages (English, French, German and Spanish).

 :Homepage:    http://www.tryton.org/
 :Downloads:  http://www.tryton.org/downloads.html
 :Screenshots:http://www.tryton.org/screenshots.html

 Tryton is aspire to be a strong community-driven project. We are looking
 for contributors for translations, documentations and testings as long
 as business expertise and user feedbacks.

 What is Tryton?
 
 Tryton is a three-tiers high-level general purpose application platform
 under the license GPL-3 written in Python and use Postgresql as database
 engine. It is the core base of an Open Source ERP. It provides
 modularity, scalability and security.

 The target audience is the small and medium enterprises who are
 looking for a highly customizable and easy to use application platform
 and ERP. Tryton provides the ability to organizations to let their
 solution grow with their needs.

 Tryton Core
 --
 The core of Tryton (also called Tryton kernel) provide all the necessary
 functionalities for a complete application framework: data persistence
 (i.e an ORM with extensive modularity), users management
 (authentication, fine grained control for data access, handling of
 concurrent access of resources), workflow and report engines, web
 services and internationalization. Thus constituting a complete
 application platform which can be used for any relevant purpose.

 Base Modules
 -
 Currently, the main modules available for Tryton cover the following
 fields of activity:

      * Accounting
      * Invoicing
      * Sale Management
      * Purchase Management
      * Analytic Accounting
      * Inventory Management

 They establish a sane base and an easy to use abstraction of some of the
 key concepts for every business customization.

Good! inform the same information to http://www.open-source-erp-site.com,
so that more people will get to know about it.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using eval, or something like it...

2008-11-20 Thread Scott David Daniels

r0g wrote:

...
A class is like a template which combines a complex data type (made from
a combination of other data types) and the methods that operate on that
data type.

You generally don't work with classes directly but you make instances of
them, each instance has it's own internal state and methods, initially
these are the same as the templates but can be changed or overridden
without affecting the state of any other instances you might have.

Take the tutorial and do experiments.
The attribute lookup checks the class _and_ the instance (with the
instance over-riding the class).  Make sure you can explain the output
from this:

class Demo(object):
non_template = 43

d = Demo()
print d.non_template
Demo.non_template = 44
print d.non_template
d.non_template = 45
print d.non_template
Demo.non_template = 46
print d.non_template

Once you can do that, explain this:
class Demo2(object):
holder = []

e = Demo2()
print e.holder
Demo2.holder.append(44)
print e.holder
e.holder.append(45)
print e.holder
Demo2.holder.append(46)
print e.holder

# clue:
print d.holder is Demo.holder


Is this correct enough for me to avoid the aforementioned bug pile?

Also then, what _is_ an instance variable ?


Well, when you use the term variable, I suspect that you think it
represents storage.  OK, it kind of does, but only in the sense
that it can hold a reference to an object.  A more successful
way of thinking is that the attribute name is associated with the
value.  In fact the object typically has a dictionary doing exactly
that, associating attribute names with values.  Both the class and
the instance have such dictionaries, although there are a few specials
that don't work that way (setattr knows about checking for the 
exceptional cases).  The storage can be removed with the del

statement.  Try
del d.non_template
print d.non_template
del e.holder
print e.holder

--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using eval, or something like it...

2008-11-20 Thread George Sakkis
On Nov 20, 6:54 pm, r0g [EMAIL PROTECTED] wrote:

 It would seem from this setattr function that the proper term for these
 is 'attributes'. That for many years I have considered pretty much any
 named thing that may vary a 'variable' might be at the root of the
 problem here as it's a very un-specific term...

Exactly, refrain from using the term variable, or value for that
matter, in Python context as they are notorious for causing more
trouble than they deserve..

 So I gather you are saying that the fragments of state within a class
 are so distinct from ordinary common or garden variables that it is
 incorrect to think of them, or describe them, as variables, much like
 quarks should not really be regarded as distinct particles, and they
 should only be thought of and described as 'attributes' to avoid confusion?

 Is this correct enough for me to avoid the aforementioned bug pile?

No, a class can have attributes just like a instance can, and you can
use setattr() to set an attribute for a class just like you do it for
instances:

class Foo():
  bar = 1
  gum = 2

 setattr(Foo, 'bar', 3)
 Foo.bar
3

George
--
http://mail.python.org/mailman/listinfo/python-list


Re: SOAPpy SyntaxError

2008-11-20 Thread Jon-Pierre Gentil

[EMAIL PROTECTED] wrote:


I'm going through the SOAP Web Services portion of Mark Pilgrim's
tutorial and I'm getting this error when trying to build:

  File /Users/username/Desktop/SOAPpy-0.12.0/SOAPpy/Client.py, line
46
from __future__ import nested_scopes
SyntaxError: from __future__ imports must occur at the beginning of
the file

I tried moving that line and it didn't help.


I was able to successfully move that line to the very top of the file in 
each of the files it errored in.  There are quite a number of them and 
it must be done in all files that contain that line.


I really wish that SOAPpy wasn't so dead.  There are a few other bugs 
that I found as well revolving around namespace errors but I never had 
time to debug them properly to contribute a patch.


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


Re: Problem with writing fast UDP server

2008-11-20 Thread Gabriel Genellina
En Thu, 20 Nov 2008 14:24:20 -0200, Krzysztof Retel  
[EMAIL PROTECTED] escribió:

On Nov 20, 4:00 pm, [EMAIL PROTECTED] wrote:

On 20 Nov, 16:03, Krzysztof Retel [EMAIL PROTECTED]
wrote:

 I am struggling writing fast UDP server. It has to handle around 1
 UDP packets per second. I started building that with non blocking
 socket and threads. Unfortunately my approach does not work at all.
 I wrote a simple case test: client and server. The client sends 2200
 packets within 0.137447118759 secs. The tcpdump received 2189 packets,
 which is not bad at all.
 But the server only handles 700 -- 870 packets, when it is non-
 blocking, and only 670 – 700 received with blocking sockets.
 The client and the server are working within the same local network
 and tcpdump shows pretty correct amount of packets received.


I wonder if there is a kind of setting for socket to allow no delays?


I've used this script to test sending UDP packets. I've not seen any  
delays.


code
a very simple UDP test

Usage:

  %(name)s client remotehost message to send|length of message
  to continuously send messages to remotehost until Ctrl-C

  %(name)s server
  to listen for messages until Ctrl-C

Uses port %(port)d. Once stopped, shows some statistics.
Creates udpstress-client.csv or udpstress-server.csv with
pairs (size,time)


import os, sys
import socket
import time

PORT = 21758
BUFSIZE = 4096
socket.setdefaulttimeout(10.0)

def server(port):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('',port))
print Receiving at port %d % (port)
history = []
print Waiting for first packet to arrive...,
sock.recvfrom(BUFSIZE)
print ok
t0 = time.clock()
while 1:
try:
try:
data, remoteaddr = sock.recvfrom(BUFSIZE)
except socket.timeout:
print Timed out
break
except KeyboardInterrupt: # #1755388 #926423
raise
t1 = time.clock()
if not data:
break
history.append((len(data), t1-t0))
t0 = t1
except KeyboardInterrupt:
print Stopped
break
sock.close()
return history

def client(remotehost, port, data):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
history = []
print Sending %d-bytes packets to %s:%d % (len(data), remotehost,  
port)

t0 = time.clock()
while 1:
try:
nbytes = sock.sendto(data, (remotehost,port))
t1 = time.clock()
if not nbytes:
break
history.append((nbytes, t1-t0))
t0 = t1
except KeyboardInterrupt:
print Stopped
break
sock.close()
return history

def show_stats(history, which):
npackets = len(history)
bytes_total = sum([item[0] for item in history])
bytes_avg = float(bytes_total) / npackets
bytes_max = max([item[0] for item in history])
time_total = sum([item[1] for item in history])
time_max   = max([item[1] for item in history])
time_min   = min([item[1] for item in history])
time_avg = float(time_total) / npackets
speed_max = max([item[0]/item[1] for item in history if item[1]0])
speed_min = min([item[0]/item[1] for item in history if item[1]0])
speed_avg = float(bytes_total) / time_total
print Packet count   %8d % npackets
print Total bytes%8d bytes % bytes_total
print Total time %8.1f secs % time_total
print Avg size / packet  %8d bytes % bytes_avg
print Max size / packet  %8d bytes % bytes_max
print Max time / packet  %8.1f us % (time_max*1e6)
print Min time / packet  %8.1f us % (time_min*1e6)
print Avg time / packet  %8.1f us % (time_avg*1e6)
print Max speed  %8.1f Kbytes/sec % (speed_max/1024)
print Min speed  %8.1f Kbytes/sec % (speed_min/1024)
print Avg speed  %8.1f Kbytes/sec % (speed_avg/1024)
print
open(udpstress-%s.csv % which,w).writelines(
[%d,%f\n % item for item in history])

if len(sys.argv)1:
if client.startswith(sys.argv[1].lower()):
remotehost = sys.argv[2]
data = sys.argv[3]
if data.isdigit(): # means length of message
data = x * int(data)
history = client(remotehost, PORT, data)
show_stats(history, client)
sys.exit(0)
elif server.startswith(sys.argv[1].lower()):
history = server(PORT)
show_stats(history, server)
sys.exit(0)

print sys.stderr, __doc__ % {
name: os.path.basename(sys.argv[0]),
port: PORT}
/code

Start the server before the client.

--
Gabriel Genellina

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


Re: Python / Debian package dependencies

2008-11-20 Thread Steven Samuel Cole
Hi Stephane,

thanks for your reply! :-)

I do not get any notification or warning or whatever from dpkg, all
output I get when running
# sudo dpkg -i python-package name_0.0.1-4927-1_all.deb
is
   Selecting previously deselected package python-package name.
   (Reading database ... 15026 files and directories currently installed.)
   Unpacking python-package name (from python-package
name_0.0.1-4927-1_all.deb) ...
   Setting up python-package name (0.0.1-4927-1) ...

And my package name package itself does get installed, but the
'psycopg2' and 'setuptools' packages it depends on do not get
installed...

How would I install a package with apt-get if I don't have it in the
repository, but only have a local .deb file ?

Cheers,

Steve


2008/11/20 Stephane Bulot [EMAIL PROTECTED]:
 Hi Steven,
 This is a normal behaviour for dpkg. If there is a failing dependancy, dpkg
 will not install dependancies, it will notify only and will not install the
 package. Dependancies installations are managed by the front-end to dpkg
 (aptitude or apt). This is not a python issue that you are facing to.
 Cheers
 Stephbul

 2008/11/20 Steven Samuel Cole [EMAIL PROTECTED]

 Hi all,

 I am trying to build a debian package for my python modules using
 stdeb and dpkg-buildpackage. The package building itself works, I also
 managed to have an entry point created and I can use my python modules
 on the Ubuntu virtual machine I use to test the package.

 The problem is that my modules require the psycopg2 python package and
 the entry point seems to require setuptools.
 I can't figure out how to declare a dependency that actually results
 in the dependency Debian packages being installed.
 I tried adding these lines to setup.py:

 requires = ['psycopg2', 'setuptools'],
 requires = ['psycopg2 (=0.1)', 'setuptools (=0.1)'],
 install_requires = ['psycopg2', 'setuptools'],
 install_requires = ['psycopg2=0.1', 'setuptools=0.1'],

 and then run stdeb_run_setup and dpkg-buildpackage -rfakeroot -uc -us
 in the deb_dist/package name folder created, but when I copy the
 .deb file over to the virtual machine and do dpkg -i .deb file, none
 of them would actually install psycopg2 and setuptools.

 What am I doing wrong ? Am I actually somewhat on the right track or
 am I doing complete nonsense ?

 Thanks for your help!

 Cheers,

 Steve
 --
 http://mail.python.org/mailman/listinfo/python-list


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


  1   2   3   >