Mocker 0.8

2007-11-12 Thread Gustavo Niemeyer

Hello Pythonistas,

Mocker 0.8 is now public.

Where
-

http://labix.org/mocker

What


- Graceful platform for test doubles in Python (mocks, stubs,
  fakes, and dummies).
- Inspiration from real needs, and also from pmock, jmock,
  pymock, easymock, etc.
- Expectation of expressions defined by actually using mock objects.
- Expressions may be replayed in any order by default,
- Trivial specification of ordering between expressions when wanted.
- Nice parameter matching for defining expectations on method calls.
- Good error messages when expectations are broken.
- Mocking of many kinds of expressions (getting/setting/deleting
  attributes, calling, iteration, containment, etc)
- Graceful handling of nested expressions (e.g.
  person.details.get_phone().get_prefix())
- Mock proxies, which allow passing through to the real object on
  specified expressions (e.g. useful with os.path.isfile()).
- Mocking via temporary patching of existent classes and instances.
- Trivial mocking of any external module (e.g. time.time()) via
  proxy replacement.
- Mock objects may have method calls checked for conformance with
  real class/instance to prevent API divergence.
- Type simulation for using mocks while still performing certain
  type-checking operations.
- Nice (optional) integration with unittest.TestCase, including
  additional assertions (e.g. assertIs, assertIn, etc).
- More ...

-- 
Gustavo Niemeyer
http://niemeyer.net
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: Binary search tree

2007-11-12 Thread Michel Albert
On Nov 9, 11:45 pm, Bruno Desthuilliers
[EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] a écrit :

  Hi,

  I have to get list of URLs one by one and to find the URLs that I have
  more than one time(can't be more than twice).

  I thought to put them into binary search tree, this way they'll be
  sorted and I'll be able to check if the URL already exist.

 What about a set ?

 s = set()
 for url in urls:
if url in s:
  print already have , url
else:
  set.add(url)

Interesting. For this case I usually used dicts. As in:

d = {}
for url in urls:
   if url in d:
  print already have , url
   else:
  d[url] = 1

Now, I can see that this method has some superfluous data (the `1`
that is assigned to the dict). So I suppose this is less memory
efficient. But is this slower then? As both implementations use hashes
of the URL to access the data. Just asking out of curiosity ;)

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

Re: Binary search tree

2007-11-12 Thread Martin v. Löwis
 Now, I can see that this method has some superfluous data (the `1`
 that is assigned to the dict). So I suppose this is less memory
 efficient. But is this slower then? As both implementations use hashes
 of the URL to access the data. Just asking out of curiosity ;)

Performance-wise, there is no difference in the implementations.
What matters when comparing programs one-by-one is how many method
calls you need. In this example, the dictionary is slightly faster
in my measurements, since for the set, you need to perform a lookup
of .add, whereas the access to __setitem__ for the dict need no
additional dictionary lookup.

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


Re: python - an eggs...

2007-11-12 Thread thebjorn
On Nov 12, 1:12 am, bruce [EMAIL PROTECTED] wrote:
 Hi Diez...

 I've never used setuptools, (it's not on the box) and i don't have
 easy_install tools installed...

In the link you were given there is a section titled Installing
setuptools.  I'm reading it aloud for you now...

-- bjorn


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


Re: email.get_filename() with newline

2007-11-12 Thread Gabriel Genellina
En Fri, 09 Nov 2007 10:46:15 -0300, Thomas Guettler [EMAIL PROTECTED]  
escribi�:

 if I use part.get_filename() with the following email part:

 --_=_NextPart_001_01C81B11.52AB8006
 Content-Type: application/vnd.ms-excel;
   
 name==?iso-8859-1?Q?30102007=28aktualisiert=29=5FK=FCndigungen_enviaM=5FErdgas?=
   =?iso-8859-1?Q?_S=FCds__GmbH=2Exls?=
 Content-Disposition: attachment;
   
 filename==?iso-8859-1?Q?30102007=28aktualisiert=29=5FK=FCndigungen_enviaM=5FErdgas?=
   =?iso-8859-1?Q?_S=FCds__GmbH=2Exls?=
 Content-Description:  
 =?iso-8859-1?Q?30102007=28aktualisiert=29=5FK=FCndigungen_enviaM=5FErdgas?=
   =?iso-8859-1?Q?_S=FCds__GmbH=2Exls?=
 Content-Transfer-Encoding: base64

 0M8R4KGxGu...

 I get a filename which includes a newline character and the ?iso...  
 encoding
 is not resolved. But the mail user agent mutt does display the filename
 correct. I tried it with the latest email packages (4.0.2).

According to RFC2047, section 5:

+ An 'encoded-word' MUST NOT appear within a 'quoted-string'.

+ An 'encoded-word' MUST NOT be used in parameter of a MIME
  Content-Type or Content-Disposition field, or in any structured
  field body except within a 'comment' or 'phrase'.

so the above headers are invalid.

 Any hints how to parse this filename?

You may try joining the lines and unfolding them by hand, and perhaps then  
you could convince the decode_header function to work in this case...

-- 
Gabriel Genellina

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

Re: How to get a set of keys with largest values?

2007-11-12 Thread cokofreedom
On Nov 12, 10:07 am, Davy [EMAIL PROTECTED] wrote:
 Hi all,

 I have a dictionary with n elements, and I want to get the m(m=n)
 keys with the largest values.

 For example, I have dic that includes n=4 elements, I want m=2 keys
 have the largest values)
 dic = {0:4,3:1,5:2,7:8}
 So, the the largest values are [8,4], so the keys are [7,0].

 Is there any fast way to implement this algorithm?
 Any suggestions are welcome!

 Best regards,
 Davy

Have a look at http://docs.python.org//lib/module-heapq.html

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


Re: how to know if folder contents have changed

2007-11-12 Thread Jorge Godoy
[EMAIL PROTECTED] wrote:

 can someone suggest a better way? i know it is a general programming
 problem..but i wish to know if a python solution exists

Use pyfam.  I believe all docs are in fam but it integrates with that. 
-- 
http://mail.python.org/mailman/listinfo/python-list


comp.lang.python 2007

2007-11-12 Thread ashik
sdfg
dsv
vcjgsdgsy

http://www.freewebs.com/thuiss/
http://indianfriendfinder.com/go/g906725-pmem

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


Re: How to get a set of keys with largest values?

2007-11-12 Thread Duncan Booth
Davy [EMAIL PROTECTED] wrote:

 For example, I have dic that includes n=4 elements, I want m=2 keys
 have the largest values)
 dic = {0:4,3:1,5:2,7:8}
 So, the the largest values are [8,4], so the keys are [7,0].
 
 Is there any fast way to implement this algorithm?
 Any suggestions are welcome!
 

Don't implement it: just use it.

 dic = {0:4,3:1,5:2,7:8}
 from heapq import nlargest
 nlargest(2, dic, key=dic.__getitem__)
[7, 0]
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Binary search tree

2007-11-12 Thread Scott SA
On 11/12/07, Michel Albert ([EMAIL PROTECTED]) wrote:

On Nov 9, 11:45 pm, Bruno Desthuilliers
[EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] a Ècrit :

  Hi,

  I have to get list of URLs one by one and to find the URLs that I have
  more than one time(can't be more than twice).

  I thought to put them into binary search tree, this way they'll be
  sorted and I'll be able to check if the URL already exist.

 What about a set ?

 s = set()
 for url in urls:
if url in s:
  print already have , url
else:
  set.add(url)

Interesting. For this case I usually used dicts. As in:

d = {}
for url in urls:
   if url in d:
  print already have , url
   else:
  d[url] = 1

Now, I can see that this method has some superfluous data (the `1`
that is assigned to the dict). So I suppose this is less memory
efficient. But is this slower then? As both implementations use hashes
of the URL to access the data. Just asking out of curiosity ;)


I'm pretty new at python but found this recipie in a cookbook (thanks O'Reilly 
for a useful book). I also found it online later, when the cookbook wasn't 
handy:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66516
http://mail.python.org/pipermail/tutor/2005-March/036966.html
... google for more

It uses the 'setdefault' function and works _really_ well.

http://docs.python.org/lib/typesmapping.html

Basically looks like this:

unique_urls = {}
for url in urls:
unique_urls.setdefault(url)

['www.somewhere.com', 'www.somewherelse.com', 'www.somewherelse.com']

... creates a dict of None's*
{'www.somewhere.com': None, 'www.somewherelse.com': None}


and harvesting is trivial:
url_keys= unique_urls.keys()


If you would find an index and count useful, you could do something like this:

for idx in range(len(urls)):
unique_urls.setdefault(urls[idx],[]).append(idx)
...
   {'www.somewhere.com': [0], 'www.somewherelse.com': [1,2]}

later, the url's, their index values and counts could be found by:

url_keys= unique_urls.keys()
for url_key in url_keys:
url_idxs= unique_urls[url_key]
url_hits= len(url_idxs)

Depending upon the data you may have associated with your URLs, or whatever 
else you're working with, this is a very sweet 'shortcut'.

I hope this helps,

Scott

* To be trully Python-esque, 'habits' would be employed and the value would 
have been 'Nun', but I guess the namesake can only be carried so far (^8
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Using python as primary language

2007-11-12 Thread Martin Vilcans
On Nov 10, 2007 12:48 AM, Rhamphoryncus [EMAIL PROTECTED] wrote:
 On Nov 9, 1:45 pm, Terry Reedy [EMAIL PROTECTED] wrote:
  2. If micro-locked Python ran, say, half as fast, then you can have a lot
  of IPC (interprocess communition) overhead and still be faster with
  multiple processes rather than multiple threads.

 Of course you'd be faster still if you rewrote key portions in C.
 That's usually not necessary though, so long as Python gives a roughly
 constant overhead compared to C, which in this case would be true so
 long as Python scaled up near 100% with the number of cores/threads.

 The bigger question is one of usability.  We could make a usability/
 performance tradeoff if we had more options, and there's a lot that
 can give good performance, but at this point they all offer poor to
 moderate usability, none having good usability.  The crux of the
 multicore crisis is that lack of good usability.

Certainly. I guess it would be possible to implement GIL-less
threading in Python quite easily if we required the programmer to
synchronize all data access (like the synchronized keyword in Java for
example), but that gets harder to use. Am I right that this is the
problem?

Actually, I would prefer to do parallell programming at a higher
level. If Python can't do efficient threading at low level (such as in
Java or C), then so be it. Perhaps multiple processes with message
passing is the way to go. It just that it seems so... primitive.

-- 
[EMAIL PROTECTED]
http://www.librador.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python iPod challenge

2007-11-12 Thread Gabriel Genellina
En Sun, 11 Nov 2007 13:33:09 -0300, [EMAIL PROTECTED] escribi�:

it seems the problem you guys found appears...
when combining Windows OS and MSIE...
(apologies...  m_._m )

Or any other OS+browser with javascript disabled.
BTW, why do you require JS? Looks like it should be possible to do it with  
just HTTP POST and plain old forms...

 Dont know how to fix it .(I am a begginer...)
 if some soul wanna help out...  the code is here...
 http://test-iq.web.cern.ch/test-iq/piton_is_easy.tar

 Anyway it works fine with firefox :)

The HTML code is invalid, so it works fine just by accident.

-- 
Gabriel Genellina

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

How to get a set of keys with largest values?

2007-11-12 Thread Davy
Hi all,

I have a dictionary with n elements, and I want to get the m(m=n)
keys with the largest values.

For example, I have dic that includes n=4 elements, I want m=2 keys
have the largest values)
dic = {0:4,3:1,5:2,7:8}
So, the the largest values are [8,4], so the keys are [7,0].

Is there any fast way to implement this algorithm?
Any suggestions are welcome!

Best regards,
Davy

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


PyServlet Error

2007-11-12 Thread alwin
Hi

I was trying to write a simple web application using Tomcat 6.0.14,
Jython 2.2.1.

My web.xml is as follows
?xml version = '1.0' encoding = 'UTF-8'?
!DOCTYPE web-app PUBLIC
-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN
http://java.sun.com/dtd/web-app_2_3.dtd;
web-app
  display-nametest/display-name
  description/description

  servlet
servlet-namePyServlet/servlet-name
servlet-classorg.python.util.PyServlet/servlet-class
load-on-startup1/load-on-startup
  /servlet

  servlet-mapping
servlet-namePyServlet/servlet-name
url-pattern*.py/url-pattern
  /servlet-mapping

  servlet
servlet-nameJythonServlet/servlet-name
servlet-classJythonServlet/servlet-class
  /servlet
servlet-mapping
servlet-nameJythonServlet/servlet-name
url-pattern/JythonServlet/url-pattern
  /servlet-mapping

/web-app

I copied all the files from jython_home\Lib to context_root\WEB-INF\lib
\Lib

when i compile the file JythonServlet.py using jythonc everthng seems
to work fine but if i access it directly as localhost:8080/jython/
JythonServlet.py I get the following error

javax.servlet.ServletException: Traceback (innermost last):
  (no code object) at line 0
Traceback (innermost last):

  (no code object) at line 0

ImportError: no module named main


org.python.core.PyException: Traceback (innermost last):

  (no code object) at line 0

ImportError: no module named main



org.python.util.PyServlet.loadServlet(Unknown Source)
org.python.util.PyServlet.getServlet(Unknown Source)
org.python.util.PyServlet.service(Unknown Source)

root cause

Traceback (innermost last):
  (no code object) at line 0
Traceback (innermost last):

  (no code object) at line 0

ImportError: no module named main


org.python.core.PyException: Traceback (innermost last):

  (no code object) at line 0

ImportError: no module named main



org.python.core.Py.JavaError(Unknown Source)
org.python.core.PyInstance.makeProxy(Unknown Source)
org.python.core.PyInstance.__init__(Unknown Source)
org.python.core.PyClass.__call__(Unknown Source)
org.python.core.PyObject.__call__(Unknown Source)
org.python.util.PyServlet.loadServlet(Unknown Source)
org.python.util.PyServlet.getServlet(Unknown Source)
org.python.util.PyServlet.service(Unknown Source)

Thanks in advance.

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


Re: Extended date and time

2007-11-12 Thread Jeremy Sanders
John Machin wrote:

 What does dates in the past mean?? Please be more specific about the
 earliest date that you want to be able to handle. Python's datetime
 starts at 0001-01-01. Somebody mentioned the time module, which is
 implementation-dependent but typically starts at 1970-01-01 .
 
 What functionality do you need, other than two-way conversion between
 days_since_epoch and (proleptic Gregorian) date/time?

I want to convert between seconds from the epoch (let's say 1970 in floating
point) and date and time. I also want it to work across all platforms.

Is there any way to convert a datetime into seconds from a certain date? Is
the most robust way of doing it just to subtract two datetime objects and
turn the timedelta into a floating point number?

Thanks

Jeremy

-- 
Jeremy Sanders
http://www.jeremysanders.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why ctypes+dll gives a strange result

2007-11-12 Thread Gabriel Genellina
En Sun, 11 Nov 2007 08:21:25 -0300, oyster [EMAIL PROTECTED]  
escribi�:

 import ctypes
 mydll=ctypes.windll.LoadLibrary(mydll.dll)

 _TwoTimes=getattr(mydll,'[EMAIL PROTECTED]')
 _TwoTimes.argtypes=[ctypes.c_double]
 def TwoTimes(i):
 return _TwoTimes(i)

 in fact, twotimes function return double*2, but when I use
 print TwoTimes(10)
 in python, I get 2226880

I think you should declare the result type also, if it's not an integer.
_TwoTimes.restype=ctypes.c_double


-- 
Gabriel Genellina

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

Re: Using python as primary language

2007-11-12 Thread Hrvoje Niksic
Martin Vilcans [EMAIL PROTECTED] writes:

 But if Python gets slow when you add fine-grained locks, then most
 certainly it wouldn't get so slow if the locks were very fast,
 right?

Given the sheer number of increfs and decrefs happening, they should
be impossibly fast (meaning: nonexistent).  Even adding an additional
test to those macros slows down Python, let alone adding a lock.

 But that's not what my question was about. It was about whether it
 would make sense to, on the same python installation, select between
 the GIL and fine-grained locks at startup. Because even if the locks
 slows down the interpreter, if they let you utilize a 32 core CPU,
 it may not be so bad anymore.

Unfortunately the selection must be done at compile time, not at
run-time.  Even taking into account the possibility of selection, so
far no one has come up with a set of patches that remove the GIL that
would come close to being accepted.

This is a recent discussion about GIL removal that provides good
reading:
http://mail.python.org/pipermail/python-dev/2007-September/thread.html#74545
-- 
http://mail.python.org/mailman/listinfo/python-list


ODBC links?

2007-11-12 Thread Mr. Connolly
Lo' there. I'm a new user of Python, what I'm looking for is an easy way to 
create ODBC links to Access databases (obviously, Access isn't the best 
database out there I can use, but its easiest to just piece together for 
this quick project). What modules would I want to be looking for to create 
an ODBC link?

S. C 


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


RE: python - an eggs...

2007-11-12 Thread Diez B. Roggisch
bruce wrote:

 Hi Diez...
 
 I've never used setuptools, (it's not on the box) and i don't have
 easy_install tools installed...
 
 But in looking at your output, I have some questions...
 -The 1st, I'm assuming that easy_install works with python2.4.3?
 -The 2nd, In the output, is see the durus egg... with the durus path
 being relative to the egg... are the actual durus files in that dir??
 -3rd question.. in searching the 'net, it appears that i have to download
 setuptools in order to get easy_install. Am I missing something here, or
 is this correct?
 
 Thanks for your pointers on this!!

So far, you deliberately ignored the pointers. Otherwise, you wouldn't need
to ask above questions.

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


Re: ODBC links?

2007-11-12 Thread Johannes Findeisen
On Mon, 2007-11-12 at 10:13 +, Mr. Connolly wrote:
 Lo' there. I'm a new user of Python, what I'm looking for is an easy way to 
 create ODBC links to Access databases (obviously, Access isn't the best 
 database out there I can use, but its easiest to just piece together for 
 this quick project). What modules would I want to be looking for to create 
 an ODBC link?

Hi,

maybe pyodbc is what you are looking for:

http://pyodbc.sourceforge.net/

Regards,
Johannes Findeisen


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


Re: Populating a dictionary, fast

2007-11-12 Thread Hrvoje Niksic
Paul Rubin http://[EMAIL PROTECTED] writes:

 Michael Bacarella [EMAIL PROTECTED] writes:
 If only it were so easy.

 I think I know what's going on, the dictionary updates are sending the
 GC into quadratic behavior.  Try turning off the GC:

 import gc
 gc.disable()

This is becoming an FAQ on this newsgroup, having come up first with
lists and now with dictionaries.  It can also be considered a serious
implementation problem, since code like Michael's is expected to
perform in (close to) linear time and in fact did so in previous
versions of Python, and still does in Perl and other popular scripting
languages.  Neither introductory nor intermediate Python learning
materials don't cover the need to disable GC when building large data
structures.

Maybe the default GC strategy should be rethought.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using python as primary language

2007-11-12 Thread Marc 'BlackJack' Rintsch
On Mon, 12 Nov 2007 10:28:02 +0100, Martin Vilcans wrote:

 Actually, I would prefer to do parallell programming at a higher
 level. If Python can't do efficient threading at low level (such as in
 Java or C), then so be it. Perhaps multiple processes with message
 passing is the way to go. It just that it seems so... primitive.

Well, to me threads seem to be more primitive.  You have to be careful
with shared memory accesses and they don't scale so well if you want to go
from single machines to a cluster.

Take a look at XML-RPC or Pyro for higher level communication between
processes.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Extended date and time

2007-11-12 Thread John Machin
On Nov 12, 8:46 pm, Jeremy Sanders jeremy
[EMAIL PROTECTED] wrote:
 John Machin wrote:
  What does dates in the past mean?? Please be more specific about the
  earliest date that you want to be able to handle. Python's datetime
  starts at 0001-01-01. Somebody mentioned the time module, which is
  implementation-dependent but typically starts at 1970-01-01 .

  What functionality do you need, other than two-way conversion between
  days_since_epoch and (proleptic Gregorian) date/time?

 I want to convert between seconds from the epoch (let's say 1970 in floating
 point) and date and time. I also want it to work across all platforms.

 Is there any way to convert a datetime into seconds from a certain date? Is
 the most robust way of doing it just to subtract two datetime objects and
 turn the timedelta into a floating point number?


That seems to be robust enough:

C:\junktype epoch.py
import datetime
now = datetime.datetime(2007, 11, 12, 21, 20, 39, 859123)
for epoch_year in (1, 1970, 2070):
EPOCH = datetime.datetime(epoch_year, 1, 1)
print \nepoch, repr(EPOCH)
diff = now - EPOCH
print diff, repr(diff)
sdiff = diff.microseconds / 100. \
+ diff.seconds + diff.days * 24. * 3600.
print sdiff, repr(sdiff)
roundtrip = EPOCH + datetime.timedelta(seconds=sdiff)
print roundtrip, repr(roundtrip)
C:\junkepoch.py

epoch datetime.datetime(1, 1, 1, 0, 0)
diff datetime.timedelta(732991, 76839, 859123)
sdiff 63330499239.859123
roundtrip datetime.datetime(2007, 11, 12, 21, 20, 39, 859123)

epoch datetime.datetime(1970, 1, 1, 0, 0)
diff datetime.timedelta(13829, 76839, 859123)
sdiff 1194902439.859123
roundtrip datetime.datetime(2007, 11, 12, 21, 20, 39, 859123)

epoch datetime.datetime(2070, 1, 1, 0, 0)
diff datetime.timedelta(-22696, 76839, 859123)
sdiff -1960857560.140877
roundtrip datetime.datetime(2007, 11, 12, 21, 20, 39, 859123)

C:\junk

Cheers,
John

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


Re: PyQt with embedded python in Qt App

2007-11-12 Thread Bart.
Saturday 03 of November 2007 02:43:21 cgrebeld napisał(a):
 http://python.pastebin.com/m18c67b3a

Thank You, now I understand.
Now how to extend this interpreter 
with Qt Application classes/objects to do some usefull things with this 
embeded interpreter ?

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

Only one week left for PyCon proposals!

2007-11-12 Thread David Goodger
There is only one week left for PyCon tutorial  scheduled talk proposals.  If
you've been thinking about making a proposal, now's the time!

Tutorial details and instructions here:
http://us.pycon.org/2008/tutorials/proposals/

Scheduled talk details and instructions here:
http://us.pycon.org/2008/conference/proposals/

The deadline is Friday, November 16.  Don't put it off any longer!

PyCon 2008: http://us.pycon.org

-- 
David Goodger
PyCon 2008 Chair



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Populating a dictionary, fast

2007-11-12 Thread Steven D'Aprano
On Sun, 11 Nov 2007 11:42:08 -0700, Arkanes wrote:

 It takes about 20 seconds for me. It's possible it's related to int/long
 unification - try using Python 2.5. If you can't switch to 2.5, try
 using string keys instead of longs.

I'm getting similar behaviour to the Original Poster, and I'm using 
Python 2.5 under Linux.

Unlike him, my PC only has 1GB of RAM, and I've got a LOT of other apps 
running, so I'm not surprised it's taking about two minutes to build the 
dict. I put that down to low memory, and given the limitations of my 
system, I'm not worried about that.

But taking 30+ minutes to delete the dict, even with garbage collection 
off, that can't be good.



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


Comp. Lang. python

2007-11-12 Thread sskumartry
To see more python computer language click here.
http://www.geocities.com/bhauqz/
http://indianfriendfinder.com/go/g910673-pmem
http://bigchurch.com/go/g910673-pmem
http://www.bidvertiser.com/

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


Re: Populating a dictionary, fast

2007-11-12 Thread Steven D'Aprano
On Sun, 11 Nov 2007 08:25:15 -0800, Michael Bacarella wrote:

 Firstly, thank you for all of your help so far, I really appreciate it.
 
  So, you think the Python's dict implementation degrades towards
  O(N)
  performance when it's fed millions of 64-bit pseudo-random longs?
 
 No.
 
 Yes.
 
 I tried your code (with one change, time on feedback lines) and got the
  same terrible
 performance against my data set.

Hmmm... you're getting even worse performance than I do. I read the dict 
in pretty quickly considering the limited memory on my system, and only 
run into trouble when I try deleting the dict.

But still... no, Python dicts shouldn't degrade that badly. Whatever is 
going on, it almost certainly isn't a problem with the implementation of 
dicts.

Here's a thought... try reading the data into one big list of key-value 
pairs instead of a dict. If you still get terrible performance, I think 
that pretty much eliminates the dict as the culprit.



 To prove that my machine is sane, I ran the same against your generated
 sample file and got _excellent_ performance.  Start to finish in under a
 minute.

Not a fair comparison, because it is doing something completely 
different. But still valuable to see that your install isn't *completely* 
broken.


 Notice that the dict is completely read into memory in just two and a
 half minutes. The script then tries to delete the dict, and 32
 minutes
 later is still struggling. That's the point I got sick of waiting and
 interrupted the script.

 Conclusion: it's a memory issue, or maybe a garbage collection issue,
 not a problem with dicts.
 
 As you can see, not the case at all against my data set.

Yes, I see now that your problems are worse than my problems.


 (1) Presumably you don't want to run your app with the garbage
 collector turned off. You might still want to play around with the gc
 module to see what you can learn.
 
 As you can see, your version did no better. :(

Somewhat better, but still struggling.


 (2) More memory will help avoid paging. If you can't get more memory,
 try more virtual memory. It will still be slow, but at least the
 operating
 system doesn't have to try moving blocks around as much.
 
 The machine has 8GB, and is not doing anything else when I run this.

Yes, fair enough.


 (3) Are you sure you need all eight-million-plus items in the cache
 all at once?
 
 Yes.

I remain skeptical, but what do I know, I don't even know what you're 
doing with the data once you have it :-)


 (4) There are lots of algorithms out there for dealing with data too
 big to fit into main memory. Do some research.
 
 It DOES fit into main memory and a dictionary is exactly the right way
  to do this.

I agree now.


I think that you and I are experiencing anomalous results. I'm not even 
certain that it is specifically a Python problem -- I'd be a lot happier 
if somebody got the same terrible performance on a different OS.

What do we have in common? We're using different versions of Python (you 
2.3, me 2.5) and different versions of Linux.

I wonder if we happen to have the same hardware... what's your CPU?



$ cat /proc/cpuinfo
processor   : 0
vendor_id   : AuthenticAMD
cpu family  : 15
model   : 107
model name  : AMD Athlon(tm) 64 X2 Dual Core Processor 4400+
stepping: 1
cpu MHz : 1000.000
cache size  : 512 KB
...
processor   : 1
vendor_id   : AuthenticAMD
cpu family  : 15
model   : 107
model name  : AMD Athlon(tm) 64 X2 Dual Core Processor 4400+
stepping: 1
cpu MHz : 1000.000
cache size  : 512 KB
...




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


Re: How to get a set of keys with largest values?

2007-11-12 Thread Jeff
Why are you doing that with key-value pairs?  Why not with the array
module or lists?

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


PyGilState_Ensure interrupts python critical sections

2007-11-12 Thread billy . omahony
Hi,

I have a native windows thread in a c python module which calls into
python code and adds an item to a data structure (a home-grown
circular buffer). At the same time my main python application is
removing items from this data structure.

Unlike native python containers adding and removing items from the
circular buffer is not atomic. So I need to put access to it in a
critical section. Using threading.Lock will work for native python
threads competing for access. But when access is from a windows thread
this will not work. That is because my call to PyGilState_ensure will
preempt my native python thread ***even when it is inside the critical
section***.

What is going on looks something like this (I think).


   Py  Python   Windows   Py   threading.Lock
resource
  SchedThread   Thread   Code|  |
| || |  |
|Go (GIL)#|| |  |
|#|| |  |
|#|| |  |
|#...Doit.|...| |  |
|#||. acquire...|  |
|-PyGILState_Ensure--|| |  |
|   ...  ...  ...   ...
|Stop#
|---`|
|
|Ensure rtns-# PyObject_  ||
 |   :|CallMethod  | |  |
 |   :|.(Doit)... |. acquire...| DEADLOCK |
 :
 :
 :.how does python thread tell
PyScheduler not to give away
  Gil until we are done with
  critical section??

So my question is how in python do I tell the scheduler not to prempt
the current python thread. Especially how to tell it not to give the
GIL to any calls to PyGILState_ensure until further notice (i.e. until
I am outside my critical section?? It sounds like a reasonable request
- surely this exists already but I can't find it.

One thing that may work (though the documentation does not
specifically say so) is using setcheckinterval() to set the check
interval to a very large value, acessing my shared structure and then
setting the check interval back to the previous value. Provided my
access to the shared structure takes less byte codes than what I set
checkinterval to I should be okay. However that would be very
dependant on the exact fine detail of how the check interval works and
may not be compatible with other Python releases

Maybe someone familiar with the python source code would know for
sure?

I am using Python 2.4.3 on windows XP.

Thanks for any help/suggestions offered!
BR,
Billy.

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


Re: Coding Help

2007-11-12 Thread Billows
Maybe AutoFlowchart can help you!

 AutoFlowchart is a excellent source code flowcharting tool to
generate flowchart from source code. Its flowchart can expand and
shrink. and you can pre-define the  the  width , height,Horizontal
spacing and vertical spacing. Move and zoom is also very easy. It can
export the flowchart as a Microsoft Word file or a bitmap file. It can
help programmers understand, document and visualize source code.
  As a new product to replace AgFlowchart, it revised the bugs of
AgFlowchart and add many features.
  It supports C,C++,VC++(Visual C++ .NET),Delphi(Object Pascal).
  Maybe it can help you!

http://www.ezprog.com

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


Re: How to get a set of keys with largest values?

2007-11-12 Thread Duncan Booth
Jeff [EMAIL PROTECTED] wrote:

 Why are you doing that with key-value pairs?  Why not with the array
 module or lists?
 
The original poster asked about a problem with key-value pairs. I just 
answered his question.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Populating a dictionary, fast

2007-11-12 Thread Hrvoje Niksic
Michael Bacarella [EMAIL PROTECTED] writes:

 $ uname -a
 Linux xxx 2.6.9-22.ELsmp #1 SMP Sat Oct 8 21:32:36 BST 2005 x86_64 x86_64 
 x86_64 GNU/Linux

 We've also tried it on this version (on a different machine):

 $ uname -a
 Linux yyy 2.6.18-8.el5 #1 SMP Thu Mar 15 19:46:53 EDT 2007 x86_64 x86_64 
 x86_64 GNU/Linux

Note that both machines are x86_64.  Please try your test on a 32-bit
machine and report the results.  I suspect performance won't degrade
there.

Most of the people who tried your test couldn't repeat your result
(including me), but some did.  It is quite possible that those who did
were running on variants of x86_64, just like you.  My guess is you've
hit a bug that degrades performance of hashing of longs, or of large
dicts, only affecting 64-bit architectures.

As a workaround, you can try skipping the long() construction and
simply hashing strings.  (There should be no loss of information, and
string objects are probably just as compact as Python longs in that
range.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some pythonic suggestions for Python

2007-11-12 Thread Loic Mahe
Chris M write :
 Multi-return value lambda? Just so you know, there is no concept of
 returning more than one value from a function.

I wrote:
  * multi return value lambda

I meant: multiple return statement, not return multiple values

pseudo code here:

lambda x: if A return B, if C return D, if E return F ...

it could be nice if ou could write normal functions ... as lambda ones
and not being limited to a subset of the kewords ...

at least it would fit Frank Samuleson needs/wishes better...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which tool to use?

2007-11-12 Thread Yoram Hekma
On Sun, Nov 11, 2007 at 01:06:35PM -0500, Brian Blais wrote:
 Hello,

 I'm looking for a system for managing submissions of proposals, with 
 multiple parts, and possible updating of those parts by the user (so it 
 needs some basic version control).  There has to be some sort of 
 permissions enforcement, to distinguish submitters from committee members 
 reading/commenting on proposals.  I've looked at Plone, but am not sure if 
 it is the correct tool for this job: it's much more than I need.  I could 
 try to roll my own, but it seems like I'd be reinventing the wheel.  Is 
 there software out there already for this kind of thing, preferably 
 customizable in Python?  I can be more specific about my requirements if 
 that would help.


   thanks,

   Brian Blais

Brian,

Well, while it might be better to just try some systems and see which
one you like best, maybe Trac (in combination with SVN for the vcs part)
is something worth looking into.

See http://trac.edgewall.org/

Regards,
Yoram


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Some pythonic suggestions for Python

2007-11-12 Thread Hrvoje Niksic
Loic Mahe [EMAIL PROTECTED] writes:

 Chris M write :
 Multi-return value lambda? Just so you know, there is no concept of
 returning more than one value from a function.

 I wrote:
 * multi return value lambda

 I meant: multiple return statement, not return multiple values

 pseudo code here:

 lambda x: if A return B, if C return D, if E return F ...

You can do that with conditional expressions:

lambda x: B if A else D if C else F in E ...

 it could be nice if ou could write normal functions ... as lambda
 ones and not being limited to a subset of the kewords ...

It becomes natural if you think of lambda as a deferred expression
rather than as an anonymous function.
-- 
http://mail.python.org/mailman/listinfo/python-list


Moving from java to python.

2007-11-12 Thread [EMAIL PROTECTED]
Hi,

I have recently been learning python, and coming from a java
background there are many new ways of doing things that I am only just
getting to grips with.

I wondered if anyone could take a look at a few pieces of code I have
written to see if there are any places where I am still using java-
esque techniques, and letting me know the appropriate python way of
doing things.


Here is a node class I wrote for use in graph traversal algorithms:

#

class Node:

Node models a single piece of connected data.

Author: Peter Braden
Last Modified : Nov. '07


def __init__(self, connections = None, uid = None):

Args:
[connections - a list of (connected node, weight) 
tuples.   ]
[uid - an identifier for comparisons.]

self._connected = []
self._weights = []

if connections:
for i in connections:
self.connected.append(i[0])
self.weights.append(i[1])

if not uid:
self.id = id(self)
else:
self.id = uid

def __eq__(self, other):
return self.id == other.id

def getConnected(self):
return self._connected

def getWeights(self):
return self._weights

def getConnections(self):
connections = []
for i in range(len(connected)):
connections.append((self._connected[i],self._weight[i]))
return connections

connected = property(getConnected, None)
weights = property (getWeights, None)
connections = property(getConnections, None)

def addConnection(self, node, weight = 0):
self.connected.append(node)
self.weights.append(weight)

def removeConnection(self, node):
i = self._connected.index(node)
del self._connected[i]
del self._weights[i]

#===

Cheers,
Peter

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


Re: Moving from java to python.

2007-11-12 Thread Jarek Zgoda
[EMAIL PROTECTED] napisał(a):

   def getConnected(self):
   return self._connected

No need to use accessors. Just plain attribute lookup is sufficient.

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

We read Knuth so you don't have to. (Tim Peters)
-- 
http://mail.python.org/mailman/listinfo/python-list


regex that is equivalent to perl's syntax

2007-11-12 Thread Lee Sander
hi,
does python's re library have a similar capability of the perls
regular expression to
search for pattern that appears a variable number of times within the
lower and upper bounds given? For example, what is the python's
equivalent to the following perl's search string?
m/^\S{1,8}\.\S{0,3}/
which seeks to find all strings with 8 characters followed by a dot
and then three more characters as in filename.txt

Actually, i need to find a pattern such as ABCDXLMNO with the
character X
repeated 5 to 8 times.

thanks
lee

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


Re: Populating a dictionary, fast

2007-11-12 Thread Jeffrey Froman
Hrvoje Niksic wrote:

 Note that both machines are x86_64.  Please try your test on a 32-bit
 machine and report the results.  I suspect performance won't degrade
 there.

This theory seems to be supported by my findings. Running the test on a
32-bit machine took 45 seconds, while the same test on a 64-bit machine is
taking ... 30 minutes SO FAR (I'm getting impatient ;-)

Both machines are running Python2.3.4 under CentOS-4, and both have 1G of
RAM. The 64-bit machine has 2 processors weighing in at 2792.097 Mhz each,
while the 32-bit machine has only 1 1194.857 Mhz processor.


Jeffrey

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

Re: Moving from java to python.

2007-11-12 Thread Paul Hankin
On Nov 12, 3:25 pm, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Hi,

 I have recently been learning python, and coming from a java
 background there are many new ways of doing things that I am only just
 getting to grips with.

 I wondered if anyone could take a look at a few pieces of code I have
 written to see if there are any places where I am still using java-
 esque techniques, and letting me know the appropriate python way of
 doing things.

 Here is a node class I wrote for use in graph traversal algorithms:

 #

 class Node:
 
 Node models a single piece of connected data.

 Author: Peter Braden
 Last Modified : Nov. '07
 

 def __init__(self, connections = None, uid = None):
 
 Args:
 [connections - a list of (connected node, weight) 
 tuples.   ]
 [uid - an identifier for comparisons.]
 
 self._connected = []
 self._weights = []

 if connections:
 for i in connections:
 self.connected.append(i[0])
 self.weights.append(i[1])

 if not uid:
 self.id = id(self)
 else:
 self.id = uid

 def __eq__(self, other):
 return self.id == other.id

 def getConnected(self):
 return self._connected

 def getWeights(self):
 return self._weights

 def getConnections(self):
 connections = []
 for i in range(len(connected)):
 
 connections.append((self._connected[i],self._weight[i]))
 return connections

 connected = property(getConnected, None)
 weights = property (getWeights, None)
 connections = property(getConnections, None)

 def addConnection(self, node, weight = 0):
 self.connected.append(node)
 self.weights.append(weight)

 def removeConnection(self, node):
 i = self._connected.index(node)
 del self._connected[i]
 del self._weights[i]

There's no reason to make 'connected' and 'weights' properties: just
use them directly.

Make 'connections' default to [] rather than None, and replace the
slightly clumsy initialisation with more direct code:

self.connected = [i[0] for i in connections]
self.weights = [i[1] for i in connections]

getConnections can be much simpler...

def getConnections(self):
return zip(self.connected, self.weights)

The 'uid' business makes me suspicious: what's it for? If you need it,
you probably need to initialise with an explicit test for None rather
than just 'if uid' which will be wrong if you use a uid of 0...

self.id = uid if uid is not None else id(self)

HTH
--
Paul Hankin

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


Re: regex that is equivalent to perl's syntax

2007-11-12 Thread Marc 'BlackJack' Rintsch
On Mon, 12 Nov 2007 07:38:57 -0800, Lee Sander wrote:

 does python's re library have a similar capability of the perls
 regular expression to
 search for pattern that appears a variable number of times within the
 lower and upper bounds given? For example, what is the python's
 equivalent to the following perl's search string?
 m/^\S{1,8}\.\S{0,3}/

It is ``re.match(r'\S{1,8}\.\S{0,3}', string)``.  There's something called
documentation…

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: regex that is equivalent to perl's syntax

2007-11-12 Thread Tim Chase
 does python's re library have a similar capability of the perls
 regular expression to
 search for pattern that appears a variable number of times within the
 lower and upper bounds given? For example, what is the python's
 equivalent to the following perl's search string?
 m/^\S{1,8}\.\S{0,3}/
 which seeks to find all strings with 8 characters followed by a dot
 and then three more characters as in filename.txt
 
 Actually, i need to find a pattern such as ABCDXLMNO with the
 character X
 repeated 5 to 8 times.

You're interested in the re library, documented here[1] which, 
astonishingly, is the first result when I google for

   python re library

In your particular case, the syntax is identical to perl 
regexps[2] (the 2nd hit Google returns with the above query)

   import re
   r1 = re.compile(r'\S{1,8}\.\S{0,3}')
   r2 = re.compile(r'ABCDX{5,8}LMNO')
   # use r1/r2 for matching, substitution, taking over the world

Note the use of raw strings (doesn't matter so much in the 2nd 
version, as there's nothing escaped), as suggested in the docs.

-tkc


[1] http://docs.python.org/lib/module-re.html
[2] http://docs.python.org/lib/re-syntax.html





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


Re: Moving from java to python.

2007-11-12 Thread Hrvoje Niksic
[EMAIL PROTECTED] [EMAIL PROTECTED] writes:

   def __init__(self, connections = None, uid = None):

You can use connections=(), so you don't need the if below.  In
fact, you can further write:

for node, weight in connections:
self._connected.append(node)
self._weight.append(weight)

   def getConnected(self):
   return self._connected

I'd drop the getters and simply use self.connected, self.weights, etc.
It's not such a big deal in Python if someone can view the innards of
your objects; they can do so even if their name starts with _.

Also note that Python doesn't really use the camel-case naming
convention.  If you must have multi-word method/variable/property
names, use lower-case with underscores for separation.  For example:

   def getConnections(self):

Why not simply def connections(self) or, if you must, def
get_connections(self).

   connections = []
   for i in range(len(connected)):
   connections.append((self._connected[i],self._weight[i]))

Use xrange(len(...)) when iterating over the sequence; range
unnecessarily allocates the whole list.  Some will probably recommend
enumerate() or even itertools.izip(), but those are overkill for this
usage.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Moving from java to python.

2007-11-12 Thread Tim Chase
def __init__(self, connections = None, uid = None):
  
  Args:
[connections - a list of (connected node, weight) tuples.  ]
[uid - an identifier for comparisons.]
  
  self._connected = []
  self._weights = []
 
  if connections:
for i in connections:
  self.connected.append(i[0])
  self.weights.append(i[1])

I'd likely write this something like

   if connections:
 self.connected, self.weights = zip(*connections)

You also shift here between _connected and connected (same 
with weights).  This might bite you.

  if not uid:
self.id = id(self)
  else:
self.id = uid

A common way of writing this would be

   self.id = uid or id(self)

However, the need for anything other than the id() is suspect. 
Imaginable, but suspect.

def getConnected(self):
  return self._connected
 
def getWeights(self):
  return self._weights
connected = property(getConnected, None)
weights = property (getWeights, None)

No need for properties at this time...they can be added 
transparently later, if you need to do something programatic on 
access.

def getConnections(self):
  connections = []
  for i in range(len(connected)):
connections.append((self._connected[i],self._weight[i]))
  return connections
 
connections = property(getConnections, None)

And in an inverse of the __init__ method, I'd use something like

   def getConnections(self):
 return zip(self.connected, self.weights)

Just my first-pass thoughts...

-tkc




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


reading file objects in chunks

2007-11-12 Thread Martin Marcher
Hi,

I'm looking for something that will give me an iterator to a
file-(like)-object. I have large files with only a single line in it
that have fixed length fields like, record length is 26bytes, dataA is
10 bytes, dataB is 16 bytes.

Now when I made my parsing stuff but can't find anything that will let
me read those file efficiently (guess I'm just thinking too
complicated). I'd like to have something like:

f = file(datafile.dat, buffering=26)

for chunk in f.read_in_chunks():
  compute_data(chunk)

f.iter() looked promising at first but somehow it doesn't do the
right thing(tm). also itertools doesn't quite seem to be what I want.
Maybe I just need coffee but right now I'm in the dark.

I'd really like something nicer than

chunksize = 26
f = file(datafile.dat, buffering=chunksize)

chunk = f.read(chunksize)
while len(chunk) == chunksize:
  compute_data(chunk)
  f.read(chunksize)

I just don't feel comfortable with it for some reason I can't explain...

thanks
martin

-- 
http://noneisyours.marcher.name
http://feeds.feedburner.com/NoneIsYours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a good Python environment

2007-11-12 Thread VSmirk
On Nov 11, 4:39 pm, Paul Rubin http://[EMAIL PROTECTED] wrote:
 Russell Warren [EMAIL PROTECTED] writes:
  Wing now has multi-threaded debugging.

 Cool, is it windows-only?  I'm using Linux.

  A quick look at the current state of SPE shows that it now has multi-
  threaded debugging via WinPDB (what I used to use for debugging thread
  issues).  Interesting.  Worth a look to see if it is integrated well.

 Same issue: this also sounds windows-specific.  Thanks though.

Wing is actually not windows-specific.  They are Linux based as well,
and I believe a number of users are also MacOSX users.

The multi-threading debugging is a new feature with it's latest
release, but I have heard of no platform-specific issues related to it.

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


Re: PyGilState_Ensure interrupts python critical sections

2007-11-12 Thread Chris Mellon
On Nov 12, 2007 6:56 AM,  [EMAIL PROTECTED] wrote:
 Hi,

 I have a native windows thread in a c python module which calls into
 python code and adds an item to a data structure (a home-grown
 circular buffer). At the same time my main python application is
 removing items from this data structure.

 Unlike native python containers adding and removing items from the
 circular buffer is not atomic. So I need to put access to it in a
 critical section. Using threading.Lock will work for native python
 threads competing for access. But when access is from a windows thread
 this will not work. That is because my call to PyGilState_ensure will
 preempt my native python thread ***even when it is inside the critical
 section***.

 What is going on looks something like this (I think).


Py  Python   Windows   Py   threading.Lock
 resource
   SchedThread   Thread   Code|  |
 | || |  |
 |Go (GIL)#|| |  |
 |#|| |  |
 |#|| |  |
 |#...Doit.|...| |  |
 |#||. acquire...|  |
 |-PyGILState_Ensure--|| |  |
 |   ...  ...  ...   ...
 |Stop#
 |---`|
 |
 |Ensure rtns-# PyObject_  ||
  |   :|CallMethod  | |  |
  |   :|.(Doit)... |. acquire...| DEADLOCK |
  :
  :
  :.how does python thread tell
 PyScheduler not to give away
   Gil until we are done with
   critical section??

 So my question is how in python do I tell the scheduler not to prempt
 the current python thread. Especially how to tell it not to give the
 GIL to any calls to PyGILState_ensure until further notice (i.e. until
 I am outside my critical section?? It sounds like a reasonable request
 - surely this exists already but I can't find it.


It took me some time to understand the problem you were describing
because you've got some terms backward - there's no Python scheduler,
and calling PyGILState_ensure doesn't preempt anything. The Python
interpreter *releases* the GIL every so often to allow other threads
looking for it to run, but calling the python GIL functions has no
effect on preemption.

The problem is that the GIL is being released while your object lock
is held, a second thread (started from C) acquires the GIL and then
blocks on the object lock. What you seem to be seeing is that it
blocking on the object lock is preventing it from releasing the GIL,
which prevents the python thread from running and releasing the lock.

This shouldn't happen - blocking on a lock releases the GIL, so the
python thread should run, release the GIL, and eventually your C
thread should be able to acquire both locks at the same time. Are you
sure that you're correctly acquiring the GIL in your C code?


The data flow you *should* be seeing should look something like this:

GIL object lock (P=Python, C=C, *=released)
---
P   P   Python holds both locks
*   P   Python releases the GIL, inside critical section
C   P   C thread acquires the GIL and starts executing Python code
*   P   C thread tries to acquire object lock and blocks,
releasing the GIL
P   P   Python thread re-acquires the GIL
P   *   Python thread exits critical section and releases
the object lock
*   *   Python thread releases the GIL (can be in any
order with next state)
*   C   The C thread acquires the object lock and blocks on the GIL
C   C   C thread acquires the GIL and continues execution.

 One thing that may work (though the documentation does not
 specifically say so) is using setcheckinterval() to set the check
 interval to a very large value, acessing my shared structure and then
 setting the check interval back to the previous value. Provided my
 access to the shared structure takes less byte codes than what I set
 checkinterval to I should be okay. However that would be very
 dependant on the exact fine detail of how the check interval works and
 may not be compatible with other Python releases

 Maybe someone familiar with the python source code would know for
 sure?

 I am using Python 2.4.3 on windows XP.

 Thanks for any help/suggestions offered!
 BR,
 Billy.

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

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


Re: Moving from java to python.

2007-11-12 Thread Larry Bates
Paul Hankin wrote:
 On Nov 12, 3:25 pm, [EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote:
 Hi,

 I have recently been learning python, and coming from a java
 background there are many new ways of doing things that I am only just
 getting to grips with.

 I wondered if anyone could take a look at a few pieces of code I have
 written to see if there are any places where I am still using java-
 esque techniques, and letting me know the appropriate python way of
 doing things.

 Here is a node class I wrote for use in graph traversal algorithms:

 #

 class Node:
 
 Node models a single piece of connected data.

 Author: Peter Braden
 Last Modified : Nov. '07
 

 def __init__(self, connections = None, uid = None):
 
 Args:
 [connections - a list of (connected node, weight) 
 tuples.   ]
 [uid - an identifier for comparisons.]
 
 self._connected = []
 self._weights = []

 if connections:
 for i in connections:
 self.connected.append(i[0])
 self.weights.append(i[1])

 if not uid:
 self.id = id(self)
 else:
 self.id = uid

 def __eq__(self, other):
 return self.id == other.id

 def getConnected(self):
 return self._connected

 def getWeights(self):
 return self._weights

 def getConnections(self):
 connections = []
 for i in range(len(connected)):
 
 connections.append((self._connected[i],self._weight[i]))
 return connections

 connected = property(getConnected, None)
 weights = property (getWeights, None)
 connections = property(getConnections, None)

 def addConnection(self, node, weight = 0):
 self.connected.append(node)
 self.weights.append(weight)

 def removeConnection(self, node):
 i = self._connected.index(node)
 del self._connected[i]
 del self._weights[i]
 
 There's no reason to make 'connected' and 'weights' properties: just
 use them directly.
 
 Make 'connections' default to [] rather than None, and replace the
 slightly clumsy initialisation with more direct code:
 
 self.connected = [i[0] for i in connections]
 self.weights = [i[1] for i in connections]
 
 getConnections can be much simpler...
 
 def getConnections(self):
 return zip(self.connected, self.weights)
 
 The 'uid' business makes me suspicious: what's it for? If you need it,
 you probably need to initialise with an explicit test for None rather
 than just 'if uid' which will be wrong if you use a uid of 0...
 
 self.id = uid if uid is not None else id(self)
 
 HTH
 --
 Paul Hankin
 
Be VERY careful with using [] as default arguments.  Mutables are only 
evaluated 
once (not at every call).  This question comes up about once a week on this 
forum where people don't understand this.

I would recommend using (if you can):

def __init__(self, connected = None, weights=None, uid = None):
self.connected = connected or []
self.weights = weights or []


If you want to stay with single connections list do this:

def __init__(self, connections = None, uid = None):
 if connections is not None:
 self.connected=[c[0] for c in connections]
 self.weights=[c(1) for c in connections]

else:
 self.connected=[]
 self.weights=[]

Others have addressed the lack of need for accessors.

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


RE: python - an eggs...

2007-11-12 Thread bruce
diez...

i was being polite in thanking you for your input/thoughts... i actually had
read what you'd posted, as i stated.

in act, i did manage to get things working, thanks to you.

but your comment about ignoring pointers indicates that you are a jerk,
so... i now find your emails/tone offensive, and insulting. so, do me a
favor (and yourself). if you see any msgs from me, please just add me to
your spam folder/application.

but again, i thank you for your help!

thanks

peace


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Diez B. Roggisch
Sent: Monday, November 12, 2007 2:16 AM
To: python-list@python.org
Subject: RE: python - an eggs...


bruce wrote:

 Hi Diez...

 I've never used setuptools, (it's not on the box) and i don't have
 easy_install tools installed...

 But in looking at your output, I have some questions...
 -The 1st, I'm assuming that easy_install works with python2.4.3?
 -The 2nd, In the output, is see the durus egg... with the durus path
 being relative to the egg... are the actual durus files in that dir??
 -3rd question.. in searching the 'net, it appears that i have to download
 setuptools in order to get easy_install. Am I missing something here, or
 is this correct?

 Thanks for your pointers on this!!

So far, you deliberately ignored the pointers. Otherwise, you wouldn't need
to ask above questions.

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

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


Re: reading file objects in chunks

2007-11-12 Thread Marc 'BlackJack' Rintsch
On Mon, 12 Nov 2007 17:47:29 +0100, Martin Marcher wrote:

 I'd really like something nicer than
 
 chunksize = 26
 f = file(datafile.dat, buffering=chunksize)
 
 chunk = f.read(chunksize)
 while len(chunk) == chunksize:
   compute_data(chunk)
   f.read(chunksize)
 
 I just don't feel comfortable with it for some reason I can't explain...

chunksize = 26
f = open('datafile.dat', 'rb')
for chunk in iter(lambda: f.read(chunksize), ''):
compute_data(chunk)
f.close()

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to know if folder contents have changed

2007-11-12 Thread [EMAIL PROTECTED]
On Nov 11, 11:03 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 hi
 i am trying to create a cache of  digitized values of  around 100
 image files in a folder..In my program i would like to know from time
 to time if a new image has been added or removed from the folder..


Why not use the file creation/modification timestamps?

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


Re: how to know if folder contents have changed

2007-11-12 Thread Martin Marcher
2007/11/12, [EMAIL PROTECTED] [EMAIL PROTECTED]:
 Why not use the file creation/modification timestamps?

because you'd have to

a) create a thread that pulls all the time for changes or
b) test everytime for changes

fam informs in a notification like way.

Personally I'd create a hidden cache file parsable by configparser
and have filename = $favorite_checksum_algo - key value pairs in it if
it's not a long running process.

Otherwise I'd probably go with fam (or hal i think that's the other
thing that does that)

hth
martin

-- 
http://noneisyours.marcher.name
http://feeds.feedburner.com/NoneIsYours
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Populating a dictionary, fast [SOLVED]

2007-11-12 Thread Michael Bacarella
 id2name[key  40][key  0x100] = name

Oops, typo.  It's actually:

Id2name[key  40][key  0xff] = name


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


RE: Populating a dictionary, fast

2007-11-12 Thread Michael Bacarella
  and see it take about 45 minutes with this:
 
  $ cat cache-keys.py
  #!/usr/bin/python
  v = {}
  for line in open('keys.txt'):
  v[long(line.strip())] = True
 
 On my system (windows vista) your code (using your data) runs in:
 
 36 seconds with python 2.4
 25 seconds with python 2.5
 39 seconds with python 3000

*wow*

The win32 Python or the cygwin Python?

What CPU architecture?


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


Re: Using python as primary language

2007-11-12 Thread Rhamphoryncus
On Nov 12, 2:28 am, Martin Vilcans [EMAIL PROTECTED] wrote:
 On Nov 10, 2007 12:48 AM, Rhamphoryncus [EMAIL PROTECTED] wrote:

  On Nov 9, 1:45 pm, Terry Reedy [EMAIL PROTECTED] wrote:
   2. If micro-locked Python ran, say, half as fast, then you can have a lot
   of IPC (interprocess communition) overhead and still be faster with
   multiple processes rather than multiple threads.

  Of course you'd be faster still if you rewrote key portions in C.
  That's usually not necessary though, so long as Python gives a roughly
  constant overhead compared to C, which in this case would be true so
  long as Python scaled up near 100% with the number of cores/threads.

  The bigger question is one of usability.  We could make a usability/
  performance tradeoff if we had more options, and there's a lot that
  can give good performance, but at this point they all offer poor to
  moderate usability, none having good usability.  The crux of the
  multicore crisis is that lack of good usability.

 Certainly. I guess it would be possible to implement GIL-less
 threading in Python quite easily if we required the programmer to
 synchronize all data access (like the synchronized keyword in Java for
 example), but that gets harder to use. Am I right that this is the
 problem?

 Actually, I would prefer to do parallell programming at a higher
 level. If Python can't do efficient threading at low level (such as in
 Java or C), then so be it. Perhaps multiple processes with message
 passing is the way to go. It just that it seems so... primitive.

What you've got to ask is what is a message?  Can you define your
own class and use it as a message?  Doing so seems very useful.  If
you allow that you end up with something like Concurrent Pascal's
monitors (which enforce their boundary, so they lack the memory model
needed by java or C.)

Once you make message passing easy to use you end up with something
that looks very much like threads anyway, just lacking the shared-
state and the resulting memory model.

--
Adam Olsen, aka Rhamphoryncus

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


RE: Populating a dictionary, fast [SOLVED SOLVED]

2007-11-12 Thread Michael Bacarella
  You can download the list of keys from here, it's 43M gzipped:
  http://www.sendspace.com/file/9530i7
 
  and see it take about 45 minutes with this:
 
  $ cat cache-keys.py
  #!/usr/bin/python
  v = {}
  for line in open('keys.txt'):
  v[long(line.strip())] = True
 
 
 It takes about 20 seconds for me. It's possible it's related to
 int/long
 unification - try using Python 2.5. If you can't switch to 2.5, try
 using string keys instead of longs.

Yes, this was it.  It ran *very* fast on Python v2.5.

Terribly on v2.4, v2.3.

(I thought I had already evaluated v2.5 but I see now that the server
With 2.5 on it invokes 2.3 for 'python'.)

Thanks!

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


Rothschilds own half the worlds wealth directly and indirectly thru zionist proxies Re: Bill Gates was never the Richest man on earth

2007-11-12 Thread zionist . news
On Nov 11, 5:48 am, GOH, Kheng-Swee [EMAIL PROTECTED]
wrote:
 On Tue, 06 Nov 2007 17:53:01 -, [EMAIL PROTECTED] wrote:

 ...

 Using an innovative system of pigeons
 for communication and encoded letters, ...

 I didn't believe you until I read that part. It all makes sense now!   
 

You would learn a lot MORE if you listened to the videos whose links
are provided.
Please share these links anonymously with your friends, neighbors or
anyone whose email you know.

Spread quality knowledge.

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


Re: A JEW hacker in California admits distributing malware that let him steal usernames and passwords for Paypal accounts.

2007-11-12 Thread zionist . news
On Nov 10, 3:02 pm, ChairmanOfTheBored [EMAIL PROTECTED]
wrote:
 On Sat, 10 Nov 2007 22:10:15 -, [EMAIL PROTECTED] wrote:
 The mapping of Muslim communities

   You're a goddamned retard.

A Jew hacker in California admits distributing malware that let him
steal usernames and passwords for Paypal accounts.

http://www.pcworld.com/article/id,139507-c,cybercrime/article.html

The Jews and Israelis the top notch WHITE COLLAR CRIMINALS, YET, they
are harassing MOSLEMS in CALIFORNIA. Do you know why ? BECAUSE ALL THE
POLITICIANS ARE IN THEIR POCKET. Most senators and congressmen are the
same ASHKENAZI KHAZAR JEWS.
Tom Lantos and Diane Feinstein are two of the most crooked senators
from CALIFORNIA and both Ashkenazi and khazar.

LAPD to RACIALLY PROFILE MOSLEMS:
http://www.latimes.com/news/local/la-me-lapd9nov09,0,1646403.story?pa...

LAPD to build data on Muslim areas

Anti-terrorism unit wants to identify sites 'at risk' for extremism.
By Richard Winton, Jean-Paul Renaud and Paul Pringle, Los Angeles
Times Staff Writers
November 9, 2007
An extensive mapping program launched by the LAPD's anti-terrorism
bureau to identify Muslim enclaves across the city sparked outrage
Thursday from some Islamic groups and civil libertarians, who
denounced the effort as an exercise in racial and religious profiling.

Los Angeles Police Department Deputy Chief Michael P. Downing, who
heads the bureau, defended the undertaking as a way to help Muslim
communities avoid the influence of those who would radicalize Islamic
residents and advocate violent, ideologically-based extremism.

We are seeking to identify at-risk communities, Downing said in an
interview Thursday evening. We are looking for communities and
enclaves based on risk factors that are likely to become
isolated. . . . We want to know where the Pakistanis, Iranians and
Chechens are so we can reach out to those communities.

Downing added that the Muslim Public Affairs Council has embraced the
vaguely defined program in concept. The group's executive director,
Salam Al-Marayati, said Thursday that it wanted to know more about the
plan and had a meeting set with the LAPD next week.

We will work with the LAPD and give them input, while at the same
time making sure that people's civil liberties are protected, said
Al-
Marayati, who commended Downing for being very forthright in his
engagement with the Muslim community.

Others condemned the project, however.

We certainly reject this idea completely, said Shakeel Syed,
executive director of the Islamic Shura Council of Southern
California. This stems basically from this presumption that there is
homogenized Muslim terrorism that exists among us.

Syed said he is a member of Police Chief William J. Bratton's forum of
religious advisors, but had not been told of the community mapping
program. This came as a jolt to me, Syed said.

Hussam Ayloush, who leads the Los Angeles chapter of the Council on
American-Islamic Relations, said the mapping basically turns the LAPD
officers into religious political analysts, while their role is to
fight crime and enforce the laws.

During Oct. 30 testimony before Congress, Downing described the
program broadly as an attempt to mitigate radicalization. At that
time, he said law enforcement agencies nationwide faced a vicious,
amorphous and unfamiliar adversary on our land.

Downing and other law enforcement officials said police agencies
around the world are dealing with radical Muslim groups that are
isolated from the larger community, making potential breeding groups
for terrorism. He cited terror cells in Europe as well as the case of
some Muslim extremists in New Jersey arrested in May for allegedly
planning to bomb Ft. Dix.

We want to map the locations of these closed, vulnerable communities,
and in partnership with these communities . . . help [weave] these
enclaves into the fabric of the larger society, he said in his
testimony.

To do this, we need to go into the community and get to know peoples'
names, he said. We need to walk into homes, neighborhoods, mosques
and businesses.

To assemble the mapping data, Downing said in an interview Thursday,
the LAPD intends to enlist USC's Center for Risk and Economic Analysis
of Terrorism Events, which was founded four years ago with $12 million
in federal funds.

In 2003, university officials said the center would focus on threats
to power plants, telecommunications and transportation systems.

It recently was tapped to strengthen security at Los Angeles
International Airport.

Downing said the effort would not involve spying on neighborhoods. He
said it would identify groups, not individuals.

This has nothing to do with intelligence, he said, comparing it to
market research.

But in his congressional testimony, Downing said the LAPD hoped to
identify communities that may be susceptible to violent,
ideologically-based extremism and then use a full-spectrum approach
guided by an intelligence-led strategy.

Downing told lawmakers the 

why there is no pythonscript insine web browsers?

2007-11-12 Thread Timuçin Kızılay
I'm an old programmer coming from a cobol background and started to 
learn python. I'm using javasript for web based applications but after I 
started to learn python, the javascript language started to seem ugly to 
me. Now I'm wondering why there is java support on web browsers but no 
python support? there is even a vbscript support inside MS-IE but there 
is no python support. it would be really nice and easy for me to use 
python instead of javascript to write those ajax scripts.

Please tell me, is there a python substitude for JRE ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rothschilds own half the worlds wealth directly and indirectly thru zionist proxies Re: Bill Gates was never the Richest man on earth

2007-11-12 Thread Simon Spiegel
On 2007-11-12 18:57:07 +0100, [EMAIL PROTECTED] said:

 On Nov 11, 5:48 am, GOH, Kheng-Swee [EMAIL PROTECTED]
 wrote:
 On Tue, 06 Nov 2007 17:53:01 -, [EMAIL PROTECTED] wrote:
 
 ...
 
 Using an innovative system of pigeons
 for communication and encoded letters, ...
 
 I didn't believe you until I read that part. It all makes sense now!   
 
 
 You would learn a lot MORE if you listened to the videos whose links
 are provided.

Ah, good, we don't have to actually *watch* them ...

simon

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


RE: python - an eggs...

2007-11-12 Thread Diez B. Roggisch
bruce wrote:

 diez...
 
 i was being polite in thanking you for your input/thoughts... i actually
 had read what you'd posted, as i stated.

Really? Did you? Here your third question:

-3rd question.. in searching the 'net, it appears that i have to download
setuptools in order to get easy_install. Am I missing something here, or is
this correct?

And here something I posted yesterday:


setuptools is a package that installs  creates eggs. You find it 
documented here:

http://peak.telecommunity.com/DevCenter/setuptools

It comes with a few commandline-scripts after installation, such as

easy_install


So, can you explain me how actually had read what you'd posted goes
together with the above question that you asked after my post? 

And just putting easy_install setuptools into the google search bar on my
browser yields this

http://peak.telecommunity.com/DevCenter/EasyInstall

as fourth or so link. Besides the fact that the link I gave you to the
setuptools features above link in the third paragraph.

So I think calling you ignorant for not reading what I posted and not
reading what pointers I gave you is well justified. If that makes _me_ a
jerk - I'm ok with that then.

Diez


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


Re: why there is no pythonscript insine web browsers?

2007-11-12 Thread Diez B. Roggisch
Timuçin Kızılay wrote:

 I'm an old programmer coming from a cobol background and started to
 learn python. I'm using javasript for web based applications but after I
 started to learn python, the javascript language started to seem ugly to
 me. Now I'm wondering why there is java support on web browsers but no
 python support? there is even a vbscript support inside MS-IE but there
 is no python support. it would be really nice and easy for me to use
 python instead of javascript to write those ajax scripts.
 
 Please tell me, is there a python substitude for JRE ?

you can use jython (http://www.jython.org) to create applets in Python on
top of the JDK/JRE.

Diez

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

crawler in python and mysql

2007-11-12 Thread Fabian López
Hi,
I would like to write a code that needs to crawl an url and take all the
HTML code. I have noticed that there are different opensource webcrawlers,
but they are very extensive for what I need. I only need to crawl an url,
and don't know if it is so easy as using an html parser. Is it? Which
libraries would you recommend me?
Thanks!!
Fabian
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Rothschilds own half the worlds wealth directly and indirectly thru zionist proxies Re: Bill Gates was never the Richest man on earth

2007-11-12 Thread Robert J. Kolker
[EMAIL PROTECTED] wrote:

 
 You would learn a lot MORE if you listened to the videos whose links
 are provided.
 Please share these links anonymously with your friends, neighbors or
 anyone whose email you know.
 
 Spread quality knowledge.

That means the Goyim own the other half. So what are you complaining 
about. If the Jews were so bad they would own ALL the wealth and you 
would still be the same miserable asshole you are now.

If you Goyim were as smart as the Jews you would be just as well off. 
Merit has its rewards.  God loves the Jews more than he loves you, 
because the Jews are smarter than you.

Bob Kolker

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


RE: python - an eggs...

2007-11-12 Thread bruce
hey dietz...

if you give me your email i'll correspond with you directly..
but yeah, you are a jerk. in that you make assumptions that may/may not be
correct, but you appear to have a holier than thou mentality...

i did download the setuptools tar file i read through the txt files that
came with it... i couldn't fing anything that stated exactly how to get the
easy_install app...

i'm fully aware of what the site states, as i read it. you ignorant slut
assume that i didn't.

in my mind, the docs on the installation could use a little more
clarification, especially for those who aren't quite sure of how python
might work, and so don't want to risk screwing up a system.

but, as far as the setuptools site goes, can you point to the section that
states, to install (setuptools/easy_install), you do x:
 -download this file
 -run this command...

 i found the files to download... i couldn't find the command to run, (at
least is wasn't apparent to me.)

so, anyway, thanks!

peace

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Diez B. Roggisch
Sent: Monday, November 12, 2007 10:26 AM
To: python-list@python.org
Subject: RE: python - an eggs...


bruce wrote:

 diez...

 i was being polite in thanking you for your input/thoughts... i actually
 had read what you'd posted, as i stated.

Really? Did you? Here your third question:

-3rd question.. in searching the 'net, it appears that i have to download
setuptools in order to get easy_install. Am I missing something here, or is
this correct?

And here something I posted yesterday:


setuptools is a package that installs  creates eggs. You find it
documented here:

http://peak.telecommunity.com/DevCenter/setuptools

It comes with a few commandline-scripts after installation, such as

easy_install


So, can you explain me how actually had read what you'd posted goes
together with the above question that you asked after my post?

And just putting easy_install setuptools into the google search bar on my
browser yields this

http://peak.telecommunity.com/DevCenter/EasyInstall

as fourth or so link. Besides the fact that the link I gave you to the
setuptools features above link in the third paragraph.

So I think calling you ignorant for not reading what I posted and not
reading what pointers I gave you is well justified. If that makes _me_ a
jerk - I'm ok with that then.

Diez


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

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


Python-URL! - weekly Python news and links (Nov 12)

2007-11-12 Thread Gabriel Genellina
QOTW:  AOP is a programming paradigm in the same way indie is a genre of
film. - Carl Banks
http://groups.google.com/group/comp.lang.python/msg/224e922a3e1a8638

I really like Python's notion of having just one data type: the duck. -
itsme
http://groups.google.com/group/comp.lang.perl.misc/msg/91382afa214a8f40


Closures and scoping rules:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/ec6907f39151d238

Classes, instances and attributes explained for newbies:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/7eb568e7a2ab4042

Looking for a good Python IDE:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/1e0b0bb1d6dab52

Two bad performance problems: one creating a huge dict, another an array:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/77e5d747c4a727cb

http://groups.google.com/group/comp.lang.python/browse_thread/thread/5a44fdef46c8faf9

Call for volunteers to compile Python extensions on Windows:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/6d1eab91b0d62809



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

Just beginning with Python?  This page is a great place to start:
http://wiki.python.org/moin/BeginnersGuide/Programmers

The Python Papers aims to publish the efforts of Python enthusiats:
http://pythonpapers.org/
The Python Magazine is a technical monthly devoted to Python:
http://pythonmagazine.com

Readers have recommended the Planet sites:
http://planetpython.org
http://planet.python.org

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce

Python411 indexes podcasts ... to help people learn Python ...
Updates appear more-than-weekly:
http://www.awaretek.com/python/index.html

Steve Bethard continues the marvelous tradition early borne by
Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim
Lesher of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance.
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donate.html

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch

Although unmaintained since 2002, the Cetus collection of Python
hyperlinks retains a few gems.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://aspn.activestate.com/ASPN/Cookbook/Python

Many Python conferences around the world are in preparation.
Watch this space for links to them.

Among several Python-oriented RSS/RDF feeds available are
http://www.python.org/channews.rdf
http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi
http://python.de/backend.php
For more, see
http://www.syndic8.com/feedlist.php?ShowMatch=pythonShowStatus=all
The old Python To-Do List now lives principally in a
SourceForge 

Re: OT: concatenating targets for python with (eg.) Gnu make

2007-11-12 Thread Carl Banks
On Nov 12, 1:22 pm, Jon Nicoll [EMAIL PROTECTED] wrote:
 My question is, how can I specify a makefile rule so that *all* of the
 changed .A files are invoked on the AtoB command line - ie if 1.A, 2.A
 and 3.A are newer than 1.B, 2.B, 3.B, I want make to invoke

 AtoB.py 1.A 2.A 3.A 4.A

 rather than

 AtoB.py 1.A
 AtoB.py 2.A
 AtoB.py 3.A

 Thanks for your thoughts.


The typical idiom is to do something like this (where .Bstamp is an
empty file that timestamps the latest time AtoB was run):

AFILES = 1.A 2.A 3.A

.Bstamp: $(AFILES)
AtoB.py $(AFILES)
touch .Bstamp

It's a little bit harder if you want to run AtoB on just the files
that changed, but all the ones that changed in one command.


Now, since you asked an off-topic question here, I am forced to bring
the thread somewhat back on topic by suggesting Scons, which is
written in Python.  I find it to be more robust and versatile than GNU
Make for complex builds, though it's a little bit to learn at first.


Carl Banks

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


webbrowser.open still gives problem with file://

2007-11-12 Thread krishnakant Mane
hello,
some days bac I posted a problem about webbrowser.open() not opening
the file on the local machine.
I get a few responses and I tryed working it out.
I also refered to the cookbook example posted on that thread.
I still can't figure out why
webbrowser.open(file:///home/krishna/documents/tut.html) does not
open the file.
as I mentioned earlier the url in the addressbar of mozilla firefox 3
alpha is file:///home/krishna//home/krishna/documents/tut.html
which is indeed wrong.
I have only got a hint so far that I can use a module called
BaseHTTPServer but I have not yet understood how it will help me to
solve the problem.
is it going to give the correct file:/// to the webbrowser.open()?
if yes then how?
can some one post a simple example?
I don't need to create any class for this because some other code in
python is actually creating an html file and I just need to display it
in the browser.
so please help on this one.
with regards,
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Binary search tree

2007-11-12 Thread Scott SA
On 11/12/07, Scott SA ([EMAIL PROTECTED]) wrote:

Uhm sorry, there is a slightly cleaner way of running the second option I 
presented (sorry for the second post).

If you would find an index and count useful, you could do something like this:

for idx in range(len(urls)):
unique_urls.setdefault(urls[idx],[]).append(idx)

   for idx,url in enumerate(urls):
   unique_urls.setdefault(url,[]).append(idx)


I decided to test the speeds of the four methods:

set_example
s = set()
for url in urls:
if not url in s:
s.add(url)

dict_example
d = {}
for url in urls:
if url in d:
d[url] = 1

setdefault_idx_example
unique_urls   = {}
for idx in range(len(urls)):
unique_urls.setdefault(urls[idx],[]).append(idx)

setdefault_enum_example
unique_urls   = {}
for idx,url in enumerate(urls):
   unique_urls.setdefault(url,[]).append(idx)


Here are the results:

Starting tests with 50 simulated URLs run 3 times.

'set' example
run time: 0.5505 seconds
'dict' example
run time: 0.2521 seconds
'setdefault_idx' example
run time: 3.6476 seconds
'setdefault_enum' example
run time: 2.5606 seconds


For the simple quest of Find the unique URLs in a list, the 'dict' example is 
by far the quickest.

Buuut, if you need the indexes and possibly a 'hit count', then the enumerated 
example seems about the best (of the possibilities tested)

Scott

PS. For those interesed in my test suite, I submit the following:

import time

#  convenience methods 

def build_list(seed_list,base_count):

Make a bogus list of urls with duplicates 

return_list = []
for x in range(base_count):
temp_list = []
for i in range(1000):
for url in seed_list:   # add a unique set
temp_list.append(('www.%d_%s' % (i,url)))
return_list += temp_list

return return_list

def run_testscript(example_name, urls):

run the given script name

start_time  = time.time()
exec('%s_example(urls)' % example_name)
run_time = time.time() - start_time

return run_time

def run_tests(example_list, urls, iterations):

print Starting tests with %d simulated URLs run %d times.\n%s % \
(len(urls), iterations, 60 * '-')

for example_name in example_list:
time_value  = 0.0
for i in range(iterations):
time_value  += run_testscript(example_name, urls)

print '\'%s\' example\n%srun time: %0.4f seconds' % \
(example_name, 20 * ' ', time_value/iterations)
print 60*'-'

#  the various tests/examples 

def setdefault_idx_example(urls):
unique_urls   = {}
for idx in range(len(urls)):
unique_urls.setdefault(urls[idx],[]).append(idx)

def setdefault_enum_example(urls):
unique_urls   = {}
for idx,url in enumerate(urls):
   unique_urls.setdefault(url,[]).append(idx)

def set_example(urls):
s = set()
for url in urls:
if not url in s:
s.add(url)

def dict_example(urls):
d = {}
for url in urls:
if url in d:
d[url] = 1

#  run 'em all 

url_seedlist= 
['somewhere.com','nowhere.net','elsewhere.gov','here.ca','there.org']
dummy_urls  = build_list(url_seedlist,100) # number of duplicates
testscript_list = ['set','dict', 'setdefault_idx','setdefault_enum']

run_tests(testscript_list, dummy_urls, 3)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Information manager/organizer with tags question.

2007-11-12 Thread Aaron Watters
On Nov 11, 5:44 pm, [EMAIL PROTECTED] wrote:
 Hello,

 I would like to write an information manager/organizer type of app but
 first I'd like to ask if there is something like that already...

Your outline sounds like a killer app, and I don't know of anything
like
it (especially for free).  However, I have to plug nucular as a
possible
back end data store that may make it easier for you to implement the
app you outlined.  Please have a look:

  http://nucular.sourceforge.net

See the demos for examples of what you can do with it very easily.
   -- Aaron Watters

===
http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=unsuspecting+victim

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


Re: Populating a dictionary, fast [SOLVED]

2007-11-12 Thread Paul Rubin
Michael Bacarella [EMAIL PROTECTED] writes:
  id2name[key  40][key  0x100] = name
 Oops, typo.  It's actually:
   Id2name[key  40][key  0xff] = name

Are you saying this is a patch that appeared after python 2.3?
Somehow I don't think it's come up in this thread whether you've
tried any later versions.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: crawler in python and mysql

2007-11-12 Thread Adam Pletcher
In the standard Python install (Windows 2.5, at least), there's there's a 
couple example scripts you might find useful:

 

python\Tools\webchecker\webchecker.py

Crawls specified URL, checking for broken links.

 

python\Tools\webchecker\websucker.py

Variant on the above that archives the specified site locally.  Including 
images, but you could probably limit it to HTML easily enough.

 

I haven't used either extensively, but they appear to work as advertised.  It 
should be easy to modify one and tie it into the MySQLdb extensions:

http://sourceforge.net/projects/mysql-python

 

--

Adam Pletcher

Technical Art Director

Volition/THQ http://www.volition-inc.com/ 

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fabian López
Sent: Monday, November 12, 2007 12:33 PM
To: Python-list@python.org
Subject: crawler in python and mysql

 

Hi,
I would like to write a code that needs to crawl an url and take all the HTML 
code. I have noticed that there are different opensource webcrawlers, but they 
are very extensive for what I need. I only need to crawl an url, and don't know 
if it is so easy as using an html parser. Is it? Which libraries would you 
recommend me? 
Thanks!!
Fabian

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

Re: Python iPod challenge

2007-11-12 Thread jose Barcelona
Gabriel,

  Now it works fine with FIREFOX , SAFARI and MSIE.
  (MSIE didnt like the the way prototype.js deals with CR LF)

 BTW, why do you require JS?
  The python interpreter comunicates back and forth via a widget
  just like gmail XD. Sorry for that.

  Anyway we stil need volunteers...
  http://cern.ch/test-iq
  Thanks!
J.



On Nov 12, 10:35 am, Gabriel Genellina [EMAIL PROTECTED]
wrote:
 En Sun, 11 Nov 2007 13:33:09 -0300, [EMAIL PROTECTED] escribi?:

 it seems the problem you guys found appears...
 when combining Windows OS and MSIE...
 (apologies...  m_._m )

 Or any other OS+browser with javascript disabled.
 BTW, why do you require JS? Looks like it should be possible to do it with
 just HTTP POST and plain old forms...

  Dont know how to fix it .(I am a begginer...)
  if some soul wanna help out...  the code is here...
 http://test-iq.web.cern.ch/test-iq/piton_is_easy.tar

  Anyway it works fine with firefox :)

 The HTML code is invalid, so it works fine just by accident.

 --
 Gabriel Genellina


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


Override method name and original method access

2007-11-12 Thread Donn Ingle
In an unusual twist of code I have a subclass which overrides a method but
it also needs to call the original method:

class One:
 def add (self, stuff):
  self.stuff.append(stuff)

class Two(One):
 def __init__(self, otherstuff):
  MYSTERY(otherstuff) #otherstuff must go into list within the parent.
 #The override - totally different function in this context.
 def add (self, data):
  self.unrelated.append (data)

For:
MYSTERY
I have tried:
 self.One.add( otherstuff ) 
No go.
 super ( Two, self).add( otherstuff ) 
Gives this error:TypeError: super() argument 1 must be type, not classobj
(Which reminds me, how the heck does super work? I always get that error!)

I could just change the method name to adddata() or something. I could pass
parent references around, but want to avoid that. 

I thought I'd ask about it here.

\d



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


Transfer socket connection between programs

2007-11-12 Thread JamesHoward
Does anyone know any method to have one program, acting as a server
transfer a socket connection to another program?  I looked into
transferring the connection via xml rpc to no avail.  It seems to be a
problem of getting access to a programs private memory space and
giving another program access to that space.

Thanks in advance,
James Howard

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


Re: python - an eggs...

2007-11-12 Thread Diez B. Roggisch
bruce schrieb:
 hey dietz...
 
 if you give me your email i'll correspond with you directly..
 but yeah, you are a jerk. in that you make assumptions that may/may not be
 correct, but you appear to have a holier than thou mentality...
 
 i did download the setuptools tar file i read through the txt files that
 came with it... i couldn't fing anything that stated exactly how to get the
 easy_install app...


You mean you read the link I gave you and didn't find this:

http://peak.telecommunity.com/DevCenter/setuptools#installing-setuptools

Conveniently linked as second point in the table of contents?


 i'm fully aware of what the site states, as i read it. you ignorant slut
 assume that i didn't.

Well, it appears that we have different definitions of reading.

 
 in my mind, the docs on the installation could use a little more
 clarification, especially for those who aren't quite sure of how python
 might work, and so don't want to risk screwing up a system.

You think that

http://peak.telecommunity.com/DevCenter/EasyInstall#installation-instructions


Download ez_setup.py, and run it; this will download and install the 
appropriate setuptools egg for your Python version. (You will need at 
least Python 2.3.5, or if you are on a 64-bit platform, Python 2.4.) An 
easy_install script will be installed in the normal location for Python 
scripts on your platform. (Windows users, don't put ez_setup.py inside 
your Python installation; please put it in some other directory before 
running it.)



isn't clear? And the following paragraphs that detail some specific 
problems that _might_ occur, but most probably won't as you didn't have 
a setuptools installed already?


 but, as far as the setuptools site goes, can you point to the section that
 states, to install (setuptools/easy_install), you do x:
  -download this file
  -run this command...

I just did.

  i found the files to download... i couldn't find the command to run, (at
 least is wasn't apparent to me.)


I'm not sure how much more apparent things can be that are titled

Installing setuptools
Installing Easy Install

Bruce, you can give me whatever names you like - slut, jerk, dietz - but 
the fact remains that you did NOT carefully read my posts nor the links 
I pointed you to. Which I showed in the last post already, that you 
conveniently ignored to comment on.

For me, it's EOD here.

Diez

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


Re: Python-URL! - weekly Python news and links (Nov 12)

2007-11-12 Thread Laszlo Nagy
Gabriel Genellina wrote:
 QOTW:  AOP is a programming paradigm in the same way indie is a genre of
 film. - Carl Banks
 http://groups.google.com/group/comp.lang.python/msg/224e922a3e1a8638
   
I was following links and hit PEP 246 here:

http://www.python.org/dev/peps/pep-0246/


On that page, Guido wrote this:

I'm rejecting this PEP.  Something much better is about to happen; it's too 
early to say exactly what, but it's not going to resemble the proposal in this 
PEP too closely so it's better to start a new
PEP.  GvR.


This is so mysterious, and I'm so excited about adaptation. Now that I 
read PEP 246 and PEP 245, I want to know what can be better? Do any of 
you have any idea what will happen? I can't stand waiting! :-D

  Laszlo


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


Re: why there is no pythonscript insine web browsers?

2007-11-12 Thread Daniel Fetchinson
 I'm an old programmer coming from a cobol background and started to
 learn python. I'm using javasript for web based applications but after I
 started to learn python, the javascript language started to seem ugly to
 me. Now I'm wondering why there is java support on web browsers but no
 python support? there is even a vbscript support inside MS-IE but there
 is no python support. it would be really nice and easy for me to use
 python instead of javascript to write those ajax scripts.

 Please tell me, is there a python substitude for JRE ?

Java has nothing to do with javascript. I guess you are really asking
about javascript so let's forget about java.

Having a full python runtime in a browser would be a really bad idea
because imagine a website telling your browser to import os ;
os.unlink( 'your_secret_very_important_file' ). If you want to write
your browser client code nevertheless in python you can use pypy [1]
to translate it into javascript. This is also what I do and it works
pretty well in conjunction with MochiKit [2].

HTH,
Daniel

[1] http://codespeak.net/pypy/dist/pypy/doc/news.html
[2] http://mochikit.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: optional arguments with compact reporting in optparse

2007-11-12 Thread braver
Steve -- thanks for your pointer to argparse, awesome progress --
optional arguments.

However, I still wonder how I do reporting.  The idea is that there
should be a list with tuples of the form:

(short, long, value, help)

-- for all options, regardless of whether they were specified on the
command line or not.

Moreover, a way to create such list should be incremental -- in ruby I
define things around each option definition and add a new tuple to the
reporting list right after the block defining the option.

The idea is, -- help should report on all options with their actual or
default values, and everything pertaining to one option -- its
definition, callbacks, and adding it to the reporting list -- must be
in vicinity of each other, so I don't forget to output some stuff
about an option ten options below...  The snippet I've shown pretty
much does it in Ruby.

Ah, yeah, and another thing -- I want to define a module with about 10
options common for a project.  Then I'd import it in scripts, and
there should be three things doable with the preexisting default
options:

-- turn off any of them
-- supply new defaults to any of them
-- add new options in the same way

Wonder how brave pythonistas do that!
Cheers,
Alexy

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


Re: Transfer socket connection between programs

2007-11-12 Thread Grant Edwards
On 2007-11-12, JamesHoward [EMAIL PROTECTED] wrote:

 Does anyone know any method to have one program, acting as a
 server transfer a socket connection to another program?

The only way I know of is to use fork.  When you fork a
process, all open file-descriptors (including network
connections) are inherited by the child.

 I looked into transferring the connection via xml rpc to no
 avail.

I've no idea how that could work (even in theory) on any OS
with which I'm familiar.

 It seems to be a problem of getting access to a programs
 private memory space and giving another program access to that
 space.

Private memory has nothing to do with it.  The connection is a
data structure that lives in kernel space, not in user space.
Even if you could grant another process access to your private
memory space, it wouldn't help you transfer a socket
connection, since that connection is something the OSes
manages.

-- 
Grant Edwards   grante Yow! !  Everybody out of
  at   the GENETIC POOL!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python-URL! - weekly Python news and links (Nov 12)

2007-11-12 Thread Carl Banks
On Nov 12, 2:46 pm, Laszlo Nagy [EMAIL PROTECTED] wrote:
 Gabriel Genellina wrote:
  QOTW:  AOP is a programming paradigm in the same way indie is a genre of
  film. - Carl Banks
 http://groups.google.com/group/comp.lang.python/msg/224e922a3e1a8638

 I was following links and hit PEP 246 here:

 http://www.python.org/dev/peps/pep-0246/

 On that page, Guido wrote this:

 I'm rejecting this PEP.  Something much better is about to happen; it's too 
 early to say exactly what, but it's not going to resemble the proposal in 
 this PEP too closely so it's better to start a new
 PEP.  GvR.

 This is so mysterious, and I'm so excited about adaptation. Now that I
 read PEP 246 and PEP 245, I want to know what can be better? Do any of
 you have any idea what will happen? I can't stand waiting! :-D


See PEP 3119, Abstract Base Classes.


Carl Banks

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


Re: Override method name and original method access

2007-11-12 Thread Chris Mellon
On Nov 12, 2007 1:41 PM, Donn Ingle [EMAIL PROTECTED] wrote:
 In an unusual twist of code I have a subclass which overrides a method but
 it also needs to call the original method:

 class One:
  def add (self, stuff):
   self.stuff.append(stuff)

 class Two(One):
  def __init__(self, otherstuff):
   MYSTERY(otherstuff) #otherstuff must go into list within the parent.
  #The override - totally different function in this context.
  def add (self, data):
   self.unrelated.append (data)

 For:
 MYSTERY
 I have tried:
  self.One.add( otherstuff )
 No go.
  super ( Two, self).add( otherstuff )
 Gives this error:TypeError: super() argument 1 must be type, not classobj
 (Which reminds me, how the heck does super work? I always get that error!)


You need to be a new-style class (that is, you must inherit from
object) for super() to work. Other than that, you are using it
correctly here.

 I could just change the method name to adddata() or something. I could pass
 parent references around, but want to avoid that.

 I thought I'd ask about it here.

 \d



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

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


Re: Override method name and original method access

2007-11-12 Thread Laszlo Nagy
Donn Ingle wrote:
 In an unusual twist of code I have a subclass which overrides a method but
 it also needs to call the original method:

 class One:
  def add (self, stuff):
   self.stuff.append(stuff)

 class Two(One):
  def __init__(self, otherstuff):
   MYSTERY(otherstuff) #otherstuff must go into list within the parent.
  #The override - totally different function in this context.
  def add (self, data):
   self.unrelated.append (data)

 For:
 MYSTERY
 I have tried:
  self.One.add( otherstuff ) 
 No go.
  super ( Two, self).add( otherstuff ) 
 Gives this error:TypeError: super() argument 1 must be type, not classobj
 (Which reminds me, how the heck does super work? I always get that error!)
   
This is a typical error. You get this when you try to use super with 
old style classes. You should try it with new style classes.

See: class One(object): instead of class One:.

BTW you can always do a direct call:

def add(self,data):
One.add(self,otherstuff)


and super isn't always the good thing to use.

Best,

   Laszlo

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


Re: Transfer socket connection between programs

2007-11-12 Thread Paul Rubin
JamesHoward [EMAIL PROTECTED] writes:
 Does anyone know any method to have one program, acting as a server
 transfer a socket connection to another program?  I looked into
 transferring the connection via xml rpc to no avail.  

You have to use an out of band communication mechanism.  On Linux this
is the SCM_RIGHTS ancillary message over Unix domain sockets.  There
are similar things for Solaris and Windows.  Unfortunately, Python
doesn't support any of them at the moment, but there's was once an RFE
waiting for a patch:

 http://mail.python.org/pipermail/python-bugs-list/2003-September/020431.html

Actually I'm having trouble finding the RFE mentioned any more, but it
it looks like Heiko Wundram did a patch in a different item:

 http://bugs.python.org/issue1194378

See also:

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


Re: Transfer socket connection between programs

2007-11-12 Thread JamesHoward
On Nov 12, 12:50 pm, Grant Edwards [EMAIL PROTECTED] wrote:
 On 2007-11-12, JamesHoward [EMAIL PROTECTED] wrote:

  Does anyone know any method to have one program, acting as a
  server transfer a socket connection to another program?

 The only way I know of is to use fork.  When you fork a
 process, all open file-descriptors (including network
 connections) are inherited by the child.

  I looked into transferring the connection via xml rpc to no
  avail.

 I've no idea how that could work (even in theory) on any OS
 with which I'm familiar.

  It seems to be a problem of getting access to a programs
  private memory space and giving another program access to that
  space.

 Private memory has nothing to do with it.  The connection is a
 data structure that lives in kernel space, not in user space.
 Even if you could grant another process access to your private
 memory space, it wouldn't help you transfer a socket
 connection, since that connection is something the OSes
 manages.

 --
 Grant Edwards   grante Yow! !  Everybody out of
   at   the GENETIC POOL!
visi.com

Thanks Grant,

Does this mean that there is some way to transfer a pointer to that
kernel memory space from one program to another and have it be valid,
or is that kernel memory space protected and unusable from other
processes?


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


Re: Transfer socket connection between programs

2007-11-12 Thread Grant Edwards
On 2007-11-12, JamesHoward [EMAIL PROTECTED] wrote:

 Private memory has nothing to do with it.  The connection is a
 data structure that lives in kernel space, not in user space.
 Even if you could grant another process access to your private
 memory space, it wouldn't help you transfer a socket
 connection, since that connection is something the OSes
 manages.

 Does this mean that there is some way to transfer a pointer to that
 kernel memory space from one program to another and have it be valid,

No.

 or is that kernel memory space protected and unusable from other
 processes?

On Linux (I'm not sure how it works on Windows), there is a
table of file descriptors that the kernel keeps for each
process.  A table entry can be an open file on disk, a serial
port, a network connection, etc.

A file descriptor is just an index into that table. That table
can't be accessed by any other processes.  When you fork a
process the new process inherits a copy of that table (and
therefore inherits any open network connections).

-- 
Grant Edwards   grante Yow! I'm having an
  at   EMOTIONAL OUTBURST!!  But,
   visi.comuh, WHY is there a WAFFLE
   in my PAJAMA POCKET??
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python-URL! - weekly Python news and links (Nov 12)

2007-11-12 Thread Aurélien Campéas
Laszlo Nagy a écrit :
 Gabriel Genellina wrote:
 QOTW:  AOP is a programming paradigm in the same way indie is a genre of
 film. - Carl Banks
 http://groups.google.com/group/comp.lang.python/msg/224e922a3e1a8638
   
 I was following links and hit PEP 246 here:
 
 http://www.python.org/dev/peps/pep-0246/
 
 
 On that page, Guido wrote this:
 
 I'm rejecting this PEP.  Something much better is about to happen; it's 
 too early to say exactly what, but it's not going to resemble the 
 proposal in this PEP too closely so it's better to start a new
PEP.  GvR.
 
 
 This is so mysterious, and I'm so excited about adaptation. Now that I 
 read PEP 246 and PEP 245, I want to know what can be better? Do any of 
 you have any idea what will happen? I can't stand waiting! :-D
 
  Laszlo
 
 
 

PEP 3124, but there haven't been any news of progress for a while
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Information manager/organizer with tags question.

2007-11-12 Thread andrei . avk
On Nov 12, 2:24 pm, Aaron Watters [EMAIL PROTECTED] wrote:
 On Nov 11, 5:44 pm, [EMAIL PROTECTED] wrote:

  Hello,

  I would like to write an information manager/organizer type of app but
  first I'd like to ask if there is something like that already...

 Your outline sounds like a killer app, and I don't know of anything
 like
 it (especially for free).  However, I have to plug nucular as a
 possible
 back end data store that may make it easier for you to implement the
 app you outlined.  Please have a look:

  http://nucular.sourceforge.net

 See the demos for examples of what you can do with it very easily.
-- Aaron Watters

 ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=unsuspecting+v...

Sounds interesting and thanks for reply but I need something that will
work in windows also.. -andrei

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


Re: Transfer socket connection between programs

2007-11-12 Thread Laszlo Nagy
JamesHoward wrote:
 Does anyone know any method to have one program, acting as a server
 transfer a socket connection to another program?  I looked into
 transferring the connection via xml rpc to no avail.  It seems to be a
 problem of getting access to a programs private memory space and
 giving another program access to that space.
   
If you are using UNIX, you can create a pipe in the filesystem, and 
connect I/O on both ends. Of course this is not the same, because - for 
example - you cannot use setsockopt. But it works with already existing 
processes very well, and usually you can setup socket options in your 
server.

Under windows, I have no clue. It may be possible to use pipes under 
Windows but I don't know how. You can also use other nasty techniques, 
like loading a DLL into your another program, then make a code hook 
into your server. Brrr. :-) (Unstable, not portable even between 
Windows versions...)

Regards,

   Laszlo


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


Re: Questions about remembering and caching function arguments

2007-11-12 Thread Aurélien Campéas
thebjorn a écrit :
 On Nov 12, 1:05 am, Anand Patil [EMAIL PROTECTED]
 wrote:
 Hi all,

 I have two questions about a class, which we'll call MyWrapperClass,
 in a package to which I'm contributing.

 1) MyWrapperClass wraps functions. Each instance has an attribute
 called 'value' and a method called 'eval', which calls the wrapped
 function. An instance D that depends on instances A, B and C can be
 created as follows:

 @mywrapperclass
 def D(A, B, C):
 return foo(A.value, B.value, C.value)

 Now that D exists, the call D.eval() will work without any arguments
 (D remembers that the arguments are A, B and C and passes their values
 to foo). What is the standard terminology for such classes, and does
 anyone know of a package that implements them in a nice way? (It's
 easy enough to roll our own, but reading about other implementations
 might give us good ideas).

 2) D.eval() will frequently be called multiple times in succession
 before A.value, B.value or C.value has had the chance to change. It
 would be _extremely_ helpful to have D detect this situation and skip
 recomputation. I'm looking for the fastest safe way to do this.
 There's no restriction on what kind of object A.value, etc. are, so
 unfortunately they might be mutable.

 Our current solution is to have D compare A.value, B.value and C.value
 to an internal cache using the 'is' operator (and put a big warning in
 the docs about not changing 'value' attributes in-place). Not exactly
 safe, but the speed savings over comparison with '==' will be
 significant. Is this OK, bad or an abomination?

 Again it would be helpful to know the terminology associated with the
 behavior I'm looking for and any packages that implement it nicely.

 Many thanks in advance and apologies for the long post,
 Anand
 
 Cells (A dataflow extension to CLOS) seems like what you want:
 
   http://common-lisp.net/project/cells/
 
 I think there was talk of a Python version a while back...
 
 -- bjorn
 

pycells : http://pycells.pdxcb.net/

but also trellis : http://peak.telecommunity.com/DevCenter/Trellis

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


imaplib unexpected error

2007-11-12 Thread KeefTM
Hello, I am getting an odd error when trying to establish an IMAP
connection:

File /Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/
imaplib.py, line 904, in _get_response
raise self.abort(unexpected response: '%s' % resp)
imaplib.abort: unexpected response: '220 libertydistribution.com ESMTP
CommuniGate Pro 5.0.9 is glad to see you!'

I thought 220 was the correct response, so I don't understand why I am
getting the error. Thanks!

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


Re: Transfer socket connection between programs

2007-11-12 Thread marek . rocki
JamesHoward napisa (a):
 Does anyone know any method to have one program, acting as a server
 transfer a socket connection to another program? I looked into
 transferring the connection via xml rpc to no avail. It seems to be a
 problem of getting access to a programs private memory space and
 giving another program access to that space.

 Thanks in advance,
 James Howard

Under Windows you may want to use WSADuplicateSocket WinAPI function +
a named pipe (for example) to transfer the obtained socket data from
one process to the other.

Hope that helped,
Marek

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


Re: Transfer socket connection between programs

2007-11-12 Thread [EMAIL PROTECTED]
On Nov 12, 1:41 pm, JamesHoward [EMAIL PROTECTED] wrote:
 Does anyone know any method to have one program, acting as a server
 transfer a socket connection to another program?  I looked into
 transferring the connection via xml rpc to no avail.  It seems to be a
 problem of getting access to a programs private memory space and
 giving another program access to that space.

 Thanks in advance,
 James Howard

On Unix, you can use Unix Domain Sockets to pass file descriptors
between processes.  You need to create a Unix Socket, then use sendmsg
and recvmsg to pass the file descriptor between processes.

Linux Application Development includes an example of how to do this in
section 16.4.6.  The book is available through Amazon.com at
http://www.amazon.com/Linux-Application-Development-Michael-Johnson/dp/0321219147

I'm sure you can find other examples on the internet to follow.

Hope this points you in the right direction,

--Nathan Davis

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


Re: imaplib unexpected error

2007-11-12 Thread KeefTM
Nevermind. It always seems I figure out what I did wrong right after I
post. Turns out I was using the wrong port.



On Nov 12, 12:51 pm, KeefTM [EMAIL PROTECTED] wrote:
 Hello, I am getting an odd error when trying to establish an IMAP
 connection:

 File /Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/
 imaplib.py, line 904, in _get_response
 raise self.abort(unexpected response: '%s' % resp)
 imaplib.abort: unexpected response: '220 libertydistribution.com ESMTP
 CommuniGate Pro 5.0.9 is glad to see you!'

 I thought 220 was the correct response, so I don't understand why I am
 getting the error. Thanks!


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


Re: Populating a dictionary, fast

2007-11-12 Thread Istvan Albert
On Nov 12, 12:39 pm, Michael Bacarella [EMAIL PROTECTED] wrote:

 The win32 Python or the cygwin Python?

 What CPU architecture?

it is the win32 version, a dual core laptop with T5220 Core 2

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


Re: imaplib unexpected error

2007-11-12 Thread Laszlo Nagy
KeefTM wrote:
 Hello, I am getting an odd error when trying to establish an IMAP
 connection:

 File /Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/
 imaplib.py, line 904, in _get_response
 raise self.abort(unexpected response: '%s' % resp)
 imaplib.abort: unexpected response: '220 libertydistribution.com ESMTP
 CommuniGate Pro 5.0.9 is glad to see you!'

 I thought 220 was the correct response, so I don't understand why I am
 getting the error. Thanks!

   
You are connecting to an SMTP server. :-) Maybe it is using the IMAP 
port? More likely you tried to connect to port 25 which is - usually - 
reserved for SMTP.

Regards,

   Laszlo

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


Re: imaplib unexpected error

2007-11-12 Thread KeefTM
On Nov 12, 1:46 pm, Laszlo Nagy [EMAIL PROTECTED] wrote:
 KeefTM wrote:
  Hello, I am getting an odd error when trying to establish an IMAP
  connection:

  File /Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/
  imaplib.py, line 904, in _get_response
  raise self.abort(unexpected response: '%s' % resp)
  imaplib.abort: unexpected response: '220 libertydistribution.com ESMTP
  CommuniGate Pro 5.0.9 is glad to see you!'

  I thought 220 was the correct response, so I don't understand why I am
  getting the error. Thanks!

 You are connecting to an SMTP server. :-) Maybe it is using the IMAP
 port? More likely you tried to connect to port 25 which is - usually -
 reserved for SMTP.

 Regards,

Laszlo

That's what it was. I put the wrong port number in :) Thanks!

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


preparing data for visualization

2007-11-12 Thread Bryan . Fodness
I would like to have my data in a format so that I can create a
contour plot.

My data is in a file with a format, where there may be multiple fields

field = 1

1a  0
2a  0
3a  5
4a  5
5a  5
6a  5
7a  5
8a  5
9a  0
10a 0
1b  0
2b  0
3b  5
4b  5
5b  5
6b  5
7b  5
8b  5
9b  0
10b 0

field = 2

1a  0
2a  0
3a  0
4a  4
5a  4
6a  4
7a  4
8a  0
9a  0
10a 0
1b  0
2b  0
3b  0
4b  4
5b  4
6b  4
7b  4
8b  0
9b  0
10b 0

field = 3

1a  0
2a  0
3a  0
4a  0
5a  3
6a  3
7a  0
8a  0
9a  0
10a 0
1b  0
2b  0
3b  0
4b  0
5b  3
6b  3
7b  0
8b  0
9b  0
10b 0

where the value is how far from the center it will be displaced,

a b a
b  a b
10  00|00   00|00   00|
00
900|00   00|00   00|
00
801|10   00|00   00|
00
701|10   00|00   00|
00
601|10   00|00   000111|
111000
501|10   00|00   000111|
111000
401|10   00|00   00|
00
301|10   00|00   00|
00
200|00   00|00   00|
00
100|00   00|00   00|
00

I could possibly have many of these that I will add together and
normalize to one.

Also, there are 60 a and b blocks, the middle 40 are 0.5 times the
width of the outer 20.

I thought about filling an array, but there is not a one to one
symmetry.

I cannot seem to get my head around this. Can anybody help me get
started?

I have tried to use a dictionary, but cannot seem to get it to work
the way I want.

I try this,

-

f = open('TEST1.MLC')

fields = {}

for line in f:
   if line.split()[0] == 'Field':

   field = int(line.split()[-1])

   elif line.split()[0] == 'Leaf':
   fields[field] = line.split()[-1]
   else:
   line = f.next()

-

and get,

-

Traceback (most recent call last):
 File pyshell#1, line 1, in module
   line.split()[0]
IndexError: list index out of range

-

Here is my data file,

-

File Rev = G
Treatment = Dynamic Dose
Last Name = Fodness
First Name = Bryan
Patient ID = 0001
Number of Fields = 4
Number of Leaves = 120
Tolerance = 0.50

Field = 10
Index = 0.
Carriage Group = 1
Operator =
Collimator = 0.0
Leaf  1A =   0.00
Leaf  2A =   0.00
Leaf  3A =   0.00
Leaf  4A =   0.00
Leaf  5A =   0.00
Leaf  6A =   0.00
Leaf  7A =   0.00
Leaf  8A =   0.00
Leaf  9A =   0.00
Leaf 10A =   0.00
Leaf 11A =   0.00
Leaf 12A =   0.00
Leaf 13A =   0.00
Leaf 14A =   0.00
Leaf 15A =   0.00
Leaf 16A =   0.00
Leaf 17A =   0.00
Leaf 18A =   0.00
Leaf 19A =   0.00
Leaf 20A =   0.00
Leaf 21A =   5.00
Leaf 22A =   5.00
Leaf 23A =   5.00
Leaf 24A =   5.00
Leaf 25A =   5.00
Leaf 26A =   5.00
Leaf 27A =   5.00
Leaf 28A =   5.00
Leaf 29A =   5.00
Leaf 30A =   5.00
Leaf 31A =   5.00
Leaf 32A =   5.00
Leaf 33A =   5.00
Leaf 34A =   5.00
Leaf 35A =   5.00
Leaf 36A =   5.00
Leaf 37A =   5.00
Leaf 38A =   5.00
Leaf 39A =   5.00
Leaf 40A =   5.00
Leaf 41A =   0.00
Leaf 42A =   0.00
Leaf 43A =   0.00
Leaf 44A =   0.00
Leaf 45A =   0.00
Leaf 46A =   0.00
Leaf 47A =   0.00
Leaf 48A =   0.00
Leaf 49A =   0.00
Leaf 50A =   0.00
Leaf 51A =   0.00
Leaf 52A =   0.00
Leaf 53A =   0.00
Leaf 54A =   0.00
Leaf 55A =   0.00
Leaf 56A =   0.00
Leaf 57A =   0.00
Leaf 58A =   0.00
Leaf 59A =   0.00
Leaf 60A =   0.00
Leaf  1B =   0.00
Leaf  2B =   0.00
Leaf  3B =   0.00
Leaf  4B =   0.00
Leaf  5B =   0.00
Leaf  6B =   0.00
Leaf  7B =   0.00
Leaf  8B =   0.00
Leaf  9B =   0.00
Leaf 10B =   0.00
Leaf 11B =   0.00
Leaf 12B =   0.00
Leaf 13B =   0.00
Leaf 14B =   0.00
Leaf 15B =   0.00
Leaf 16B =   0.00
Leaf 17B =   0.00
Leaf 18B =   0.00
Leaf 19B =   0.00
Leaf 20B =   0.00
Leaf 21B =   5.00
Leaf 22B =   5.00
Leaf 23B =   5.00
Leaf 24B =   5.00
Leaf 25B =   5.00
Leaf 26B =   5.00
Leaf 27B =   5.00
Leaf 28B =   5.00
Leaf 29B =   5.00
Leaf 30B =   5.00
Leaf 31B =   5.00
Leaf 32B =   5.00
Leaf 33B =   5.00
Leaf 34B =   5.00
Leaf 35B =   5.00
Leaf 36B =   5.00
Leaf 37B =   5.00
Leaf 38B =   5.00
Leaf 39B =   5.00
Leaf 

Re: A JEW hacker in California admits distributing malware that let him steal usernames and passwords for Paypal accounts.

2007-11-12 Thread thermate
On Nov 12, 11:29 am, radiosrfun [EMAIL PROTECTED] wrote:

 It was MUSLIMS who killed close to 3000 people of all races/religions.

Where is your proof ?

Where is the Anthrax Mailer ??

His proof that the moslems did not do it is painted all over the
internet in videos and research papers ALL made/written by non-
moslems.

stj911.org
911blogger.com
911truth.org
Alex Jones (white christian) video Terror Storm
Loose Change (video by Jewish Kids)

==
911 carried out by evil jews and mossad
http://www.guba.com/watch/2000991770

911 truckload of Explosives on the George Washington Bridge
http://www.youtube.com/watch?v=J520P-MD9a0

Benjamin Freedman's SEMINAL TESTIMONIAL SPEECH
http://video.google.com/videoplay?docid=3552214685532803163

Benjamin Freedman speech with Slide Show (40 Minute Excerpt)
http://video.google.com/videoplay?docid=3552214685532803163

Free pdf book: THE MANUFACTURE AND SALE of Saint Einstein
@
http://jewishracism.com/SaintEinstein.htm

Author interviews @
http://jewishracism.com/interviews.htm

Rothschilds control half the world's wealth directly and indirectly
using zionist proxies, and loyalty based on the zionist racist cult of
hate and paranoia based on being caught for collective financial
crimes and crimes of other categories

History of the Rothschilds part 1
http://www.youtube.com/watch?v=o_u2MaNg-EQ

History of the Rothschilds part 2
http://www.youtube.com/watch?v=o2cw-0N_Unk

FBI, Where are the two Israelis with TRUCKLOAD of explosives at the
George Washington Bridge ?
http://www.youtube.com/watch?v=JfVumKHkcIA   - Shame stooopid
americans

Alex Jones Interviews David Mayer de Rothschild
http://video.google.com/videoplay?docid=4891699310483983031

The rise of the Rothschild Money Masters
http://www.youtube.com/watch?v=ZT3GyphxJv8

Rothschilds financed APARTHEID in South Africa. They corrupted Cecil
Rhodes, the son of an anglican minister, by TEACHING him evil
techniques of apartheid. Apartheid was taught to him by the father
zionists themselves.

Rothschilds control half the world's wealth directly and indirectly
using zionist proxies, and loyalty based on the zionist racist cult
http://www.youtube.com/watch?v=fXVJzXsraX4

Was Hitler's father a bastard son of Rothschilds? Did the Salomon
Mayer von Rothschild perhaps rape  Maria Anna Schicklgruber in dark so
that she could not ever claim with certainty who the real father was?
Look at his facial features, typical central asian khazar. What was
the cause of Hitler's fanatical hatred for the Jews ?
http://en.wikipedia.org/wiki/Alois_Hitler
http://www.youtube.com/watch?v=TihCM_q59c8


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


  1   2   >