Re: [OT] Comparing VCS tools

2011-04-27 Thread Ben Finney
Ben Finney  writes:

> Tim Chase  writes:
> > Mercurial (hg)
> > ==
[…]
> > Cons:
> > - no biggies that I've found
>
> - (Anecdotal) Merge algorithm sometimes fails catastrophically.

I'm going to retract this one point. Merging is not as clear as in
Bazaar, but not enough to count against Mercurial – and certainly not
“fail”.

> - Merged revisions aren't hidden, leading users to alter history.

This still stands as a point against Mercurial (and against Git).

-- 
 \“Always code as if the guy who ends up maintaining your code |
  `\ will be a violent psychopath who knows where you live.” —John |
_o__) F. Woods |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Life

2011-04-27 Thread Kelly James
Only an experienced person can tell about life in this great way.
http://www.insurancesos.co.uk/articles/life-insurance/index.html"; 
rel="dofollow">Life Insurance UK


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


Re: recommended Emacs mode (was Re: Development tools and practices for Pythonistas)

2011-04-27 Thread rusi
On Apr 27, 11:39 am, Gour-Gadadhara Dasa  wrote:
> On Tue, 26 Apr 2011 07:39:41 -0700 (PDT)
>
> snorble  wrote:
> > I'm not a Pythonista, but I aspire to be.
>
> > My current tools:
>
> > Python, gvim, OS file system
>
> I'm also starting with Python after abandoning idea to use D for our
> desktop GUI application.
>
> We plan to use Python + Qt along with Cython extensions and wrapping
> external C library.
>
> I'm interested which Python mode can you recommend for Emacs:
>
> a) python.el
>
> b) python-mode.el or

Thats what I use.

>
> c) 'new' python.el (https://github.com/fgallina/python.el)

Looks interesting -- first time I am hearing...

>
> considering our needs above and desire to use IPython running
> Emacs-23.2 on FreeBSD?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: recommended Emacs mode

2011-04-27 Thread Gour-Gadadhara Dasa
On Wed, 27 Apr 2011 00:51:01 -0700 (PDT)
rusi  wrote:


> > b) python-mode.el or
> 
> Thats what I use.

Upon hearing there is some bug in 23.2 branches with this mode, I've
switched to 'emacs-devel' port and will start with this mode as well.

Thanks.


Sincerely,
Gour

-- 
“In the material world, conceptions of good and bad are
all mental speculations…” (Sri Caitanya Mahaprabhu)

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810




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


Re: Development tools and practices for Pythonistas

2011-04-27 Thread Jean-Michel Pichavant

Ben Finney wrote:

Mercurial – are the ones to choose from. Anoyone recommending a VCS tool
that has poor merging support (such as Subversion or, heaven help us,
CVS) is doing the newcomer a disservice.
  
True enough. But the modern crop of first-tier VCSen – Bazaar, Git,
For a single user, there would be no merge issue. And svn is very simple 
to use.

That would not be a such bad advice for a beginner with VCS systems.

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


Re: Development tools and practices for Pythonistas

2011-04-27 Thread Chris Angelico
On Wed, Apr 27, 2011 at 7:24 PM, Jean-Michel Pichavant
 wrote:
> For a single user, there would be no merge issue. And svn is very simple to
> use.
> That would not be a such bad advice for a beginner with VCS systems.

As someone who for years had "nightly backups and renamed files" as
his only VCS, I would advise beginners to pick up a VCS that they can
learn, master, and then use widely, not one that will be restricted to
solo work (forcing them to learn a different system when they join
some other project). There's no particular benefit in learning older
systems, is there? (I never learned CVS or SVN; my first is git, and
it's the only one I've used to any great extent.)

Oh, and rolling your own VCS can work in specific situations, but it's
probably going to work out a lot more efficient to use a well-known
one, even if it does have a learning curve. I have a few places where
I should probably migrate things to git.

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


Re: client-server parallellised number crunching

2011-04-27 Thread Thomas Rachel

Am 26.04.2011 21:55, schrieb Hans Georg Schaathun:


Now, I would like to use remote hosts as well, more precisely, student
lab boxen which are rather unreliable.  By experience I'd expect to
lose roughly 4-5 jobs in 100 CPU hours on average.  Thus I need some
way of detecting lost connections and requeue unfinished tasks,
avoiding any serious delays in this detection.  What is the best way to
do this in python?


As far as I understand, you acquire a job, send it to a remote host via 
a socket and then wait for the answer. Is that correct?


In this case, I would put running jobs together with the respective 
socket in a "running queue". If you detect a broken connection, put that 
job into the "todo" queue again.




... if I could detect disconnects and
requeue the tasks from the networking threads.  Is that possible
using python sockets?


Of course, why not? It might depend on some settings you set (keepalive 
etc.); but generally you should get an exception when trying a 
communication over a disconnected connection (over a disconnection? ;-))


When going over tne network, aviod pickling. Better use an own protocol.


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


Re: Py_INCREF() incomprehension

2011-04-27 Thread Thomas Rachel

Am 26.04.2011 20:44, schrieb Hegedüs Ervin:


and (maybe) final question: :)

I defined many exceptions:

static PyObject *cibcrypt_error_nokey;
static PyObject *cibcrypt_error_nofile;
static PyObject *cibcrypt_error_badpad;
...

void handle_err(int errcode) {
 switch(errcode) {
 case -1:PyErr_SetString(cibcrypt_error_nokey, "Can't find key.");
 break;
...
}
...
 cibcrypt_error_nokey = PyErr_NewException("cibcrypt.error_nokey", NULL, 
NULL);
...
 PyModule_AddObject(o, "error", cibcrypt_error_nokey);


Then I would not use the name "error" here, but maybe "error_nokey" or 
even better "NoKeyException".


Oops: there is an inconsistency in the docu: on the one hand, it says

  There are exactly two important exceptions to this rule:
  PyTuple_SetItem() and PyList_SetItem().

stating these are the only ones who take over ownership.

But PyModule_AddObject() claims to "steal" a reference as well...



I am right, here also no need any Py_INCREF()/Py_DECREF() action,
based on this doc:
http://docs.python.org/c-api/arg.html


I'm not sure: On one hand, you pass ownership of the error objects to 
the module. There - one could think - they are until the module is unloaded.


But what if someone does "del module.NoKeyException"? In this case, the 
object could have been destroyed, and you are using it -> BANG.


On the other hand, if you keep one instance internally, it is not 
possible any longer to unload the module without a memory leak...



As already stated - you might want to have a look at some other C 
modules and mimic their behaviour... (and hope they are doing it right...)



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


Re: client-server parallellised number crunching

2011-04-27 Thread Hans Georg Schaathun
On Tue, 26 Apr 2011 23:54:24 -0700, geremy condra
   wrote:
:  This sounds like a hadoop job, with the caveat that you still have to
:  get your objects across the network somehow. Have you tried xdrlib or
:  the struct module? I suspect either would save you some time.

Packing the objects up does not appear as a problem at the moment.
Pickled objects work just fine as long as I stick to relatively
simple data types and avoid any redundant information from my own
data structure.  When the CPU-s run a about 85% with a naive com's
format, I am not going to waste any time to speed up com's. 

The problem would occur when a client holding a task crashes.

:  Hmm. I guess I'd boil it down to this: if you have the ability to
:  install software on them, give hadoop a try. If, OTOH you can't
:  disturb normal lab operation at all and need a lot of CPU power, you
:  should probably start weighing what your time is worth against the
:  cost of firing up a few EC2 instances and being done with it- I use it
:  for cryptanalytic work with a similar structure all the time, and you
:  can get a hell of a cluster going over there for about $15-20 an hour.

That is an interesting thought for future work, but with the trial
and error I do at the moment, the cost of EC2 would be quite
significant, especially when I have so many idle CPU-s at my finger tips.

:  If you're an academic (it sounds like you are) you may also be able to
:  use things like planetlab and emulab, which are free and reasonably
:  easy to use.

I am.  

Based on other answers, I should be able to hack together the necessary
error checking to handle lost clients with my current solution using
the standard socket and threading API-s.  With the added benefit that
the familiarity with sockets and threads will be useful for teaching in 
the foreseeable future.

It seems that all the tools you suggest will require much more reading
with less potential for reusing the knowledge.  It will be very useful
when I can commit more resources for a longer period of time, and 
certainly worth remembering for any fully-funded project in the future.

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


minimal python27.dll?

2011-04-27 Thread est
Hi guys,

I need to ship python runtime environment package on Windows, if I
want to stripping unnessasery functions from python27.dll to make it
as small as possible(and perhaps finally UPX it), which parts of
python27.dll do you think can be removed?

>From what I think, these parts are not needed when shipping with final
end-user product:

1. debugging
2. parse text .py files, because everything is already in bytecode

Any ideas? Critics?

Thanks in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: De-tupleizing a list

2011-04-27 Thread John Pinner
On Apr 26, 4:28 am, Gnarlodious  wrote:
> I have an SQLite query that returns a list of tuples:
>
> [('0A',), ('1B',), ('2C',), ('3D',),...
>
> What is the most Pythonic way to loop through the list returning a
> list like this?:
>
> ['0A', '1B', '2C', '3D',...
>
> -- Gnarlie

If you want to handle a list of tuples where each tuple could have
*more* than one element, one solution would be:

>>> L = [(1, 2), (2, 3, 4), (5,), (6, 7, 8, 9, 0)]
>>> tuple([ x for t in L for x in t ])
(1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 0)
>>>

John
--

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


Re: Development tools and practices for Pythonistas

2011-04-27 Thread Jean-Michel Pichavant

Chris Angelico wrote:

On Wed, Apr 27, 2011 at 7:24 PM, Jean-Michel Pichavant
 wrote:
  

For a single user, there would be no merge issue. And svn is very simple to
use.
That would not be a such bad advice for a beginner with VCS systems.



As someone who for years had "nightly backups and renamed files" as
his only VCS, I would advise beginners to pick up a VCS that they can
learn, master, and then use widely, not one that will be restricted to
solo work (forcing them to learn a different system when they join
some other project). There's no particular benefit in learning older
systems, is there? (I never learned CVS or SVN; my first is git, and
it's the only one I've used to any great extent.)

Oh, and rolling your own VCS can work in specific situations, but it's
probably going to work out a lot more efficient to use a well-known
one, even if it does have a learning curve. I have a few places where
I should probably migrate things to git.

Chris Angelico
  
You're mistaking, SVN is not restricted to solo work. However it's more 
suitable for solo work than git.
Git is just the current buzz about VCS. I guess some people are 
switching to it without really knowing what's going on.


http://en.wikipedia.org/wiki/Comparison_of_revision_control_software

I tried to search for indicators about VCS usage without finding any but 
I think that svn is still one the most used VCS. Anyway it's not about 
which one is the most popular, but which one fits your need the best. 
For the OP, that would be SVN IMO.


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


Re: Development tools and practices for Pythonistas

2011-04-27 Thread Anssi Saari
Jean-Michel Pichavant  writes:

> For a single user, there would be no merge issue.

Really? What about a single user with many computers and environments?
I find myself merging files on occasion because I edited them
separately and forgot to check in changes before doing more edits on a
different computer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Development tools and practices for Pythonistas

2011-04-27 Thread Ben Finney
Jean-Michel Pichavant  writes:

> Ben Finney wrote:
> > Mercurial – are the ones to choose from. Anoyone recommending a VCS tool
> > that has poor merging support (such as Subversion or, heaven help us,
> > CVS) is doing the newcomer a disservice.
> >   True enough. But the modern crop of first-tier VCSen – Bazaar,
> > Git,
> For a single user, there would be no merge issue. And svn is very
> simple to use.

Bazaar and Mercurial are also simple to use, and you won't have to
un-learn them when you want a good VCS for collaboration.

> That would not be a such bad advice for a beginner with VCS systems.

I disagree; a beginner can just as easily learn a better VCS and avoid
the bad habits that come along with lesser tools.

-- 
 \   “Theology is the effort to explain the unknowable in terms of |
  `\ the not worth knowing.” —Henry L. Mencken |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Development tools and practices for Pythonistas

2011-04-27 Thread Jean-Michel Pichavant

Anssi Saari wrote:

Jean-Michel Pichavant  writes:

  

For a single user, there would be no merge issue.



Really? What about a single user with many computers and environments?
I find myself merging files on occasion because I edited them
separately and forgot to check in changes before doing more edits on a
different computer.
  
I was talking about merge *issue* i.e merge resulting in conflicts that 
are not easy to solve. With a single user most of the merge will be 
solved automatically by any decent VCS.


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


Re: client-server parallellised number crunching

2011-04-27 Thread Hans Georg Schaathun
On Wed, 27 Apr 2011 11:35:16 +0200, Thomas Rachel
   wrote:
:  As far as I understand, you acquire a job, send it to a remote host via 
:  a socket and then wait for the answer. Is that correct?

That's correct.  And the client initiates the connection.  At the
moment, I use one thread per connection, and don't really want to
spend the time to figure out how to do it singlethreadedly.

:  In this case, I would put running jobs together with the respective 
:  socket in a "running queue". If you detect a broken connection, put that 
:  job into the "todo" queue again.

Probably not a queue.  Maybe a dictionary.  After all I need to look up
the job later.

:  Of course, why not? It might depend on some settings you set (keepalive 
:  etc.); but generally you should get an exception when trying a 
:  communication over a disconnected connection (over a disconnection? ;-))

There are several challenges there and more than one solution.
One concern of mine, which is not necessarily justified, is that I
do not quite know if I know of all the possible error cases.  

I suppose your solution works if I run a relatively short timeout 
on the server and send regular ping messages from the client.

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


Re: Reading Huge UnixMailbox Files

2011-04-27 Thread Nobody
On Tue, 26 Apr 2011 14:02:23 -0700, Dan Stromberg wrote:

> For the archive: This assumes traditional mbox.  A SysV-ish sendmail,
> for example, may not like it.

sendmail itself doesn't deal with mailboxes or spool files; that task is
left to the local delivery agent (e.g. mail.local or procmail).

To clarify: the awk script assumes that any line beginning with
"From " is the start of a message; any matching lines in the message body
must be escaped. sendmail will do this if the mailer has the "E" flag
(F=...E...).

If lines beginning with "From " are only escaped when preceded by a blank
line, you need to maintain a flag which is set when the current line is
the first line in the file or preceded by a blank line and clear
otherwise. This is the behaviour of sendmail's mail.local, and of procmail
when invoked with the -Y flag (this is the default when sendmail is
configured with FEATURE(local_procmail)) or when no Content-Length header
is present.

If lines beginning with "From " aren't escaped (relying upon a
Content-Length header), you need to find some other approach (which
probably won't involve traditional line-oriented tools). You also need to
be really careful when processing such files.

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


Re: Terrible FPU performance

2011-04-27 Thread Mihai Badoiu
I'm using intel xeon harpertown (E5450) and Python 2.6.4.

In the cython code, when I use fpclassify, in the slow case I get 3
(FP_SUBNORMAL)
In the pure-C code, when I use fpclassify, in the case that's supposed to be
slow but it's not, I get a 2 (FP_ZERO)

Somehow, the FPU's have different results for exactly the same asm code.

--mihai

On Tue, Apr 26, 2011 at 11:06 PM, David Cournapeau wrote:

> On Wed, Apr 27, 2011 at 4:14 AM, Dan Goodman 
> wrote:
> > Hi,
> >
> > On 26/04/2011 15:40, Mihai Badoiu wrote:
> >> I have terrible performance for multiplication when one number gets very
> >> close to zero.  I'm using cython by writing the following code:
> >
> > This might be an issue with denormal numbers:
> >
> > http://en.wikipedia.org/wiki/Denormal_number
> >
> > I don't know much about them though, so I can't advise any further than
> > that...
>
> This indeed sounds like it. Mihai, which CPU are you using ? Pentium4
> are especially known to have terrible (read order of magnitude slower)
> performance with denormal numbers.
>
> There is unfortunately no simple way to know whether a float is
> denormal or not in python, but since you are using cython, if you are
> under posix you should be able to use fpclassify to check this,
>
> From there, if you see a difference between cython/python and C, it
> will be easier to debug.
>
> cheers,
>
> David
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: client-server parallellised number crunching

2011-04-27 Thread Chris Angelico
On Wed, Apr 27, 2011 at 10:21 PM, Hans Georg Schaathun  
wrote:
> On Wed, 27 Apr 2011 11:35:16 +0200, Thomas Rachel
>   wrote:
> :  As far as I understand, you acquire a job, send it to a remote host via
> :  a socket and then wait for the answer. Is that correct?
>
> That's correct.  And the client initiates the connection.  At the
> moment, I use one thread per connection, and don't really want to
> spend the time to figure out how to do it singlethreadedly.

Threads work quite happily in Python if they're I/O bound, which they
will be if they're waiting for the client to do something.

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


unpickling derived LogRecord in python 2.7 from python2.6

2011-04-27 Thread ivdn...@gmail.com
Hello all,

I have a service that runs in python 2.6.4. This service sends
LogRecords to a log monitoring app on my workstation running python
2.7. The LogRecord class is derived:

class LogRecord(logging.LogRecord):

def __init__(self, name, level, fn, lno, user, hostname, msg,
args, exc_info, func=None):

if sys.version_info[1] > 4:
logging.LogRecord.__init__(self, name, level, fn, lno,
msg, args, exc_info, func)
else:
logging.LogRecord.__init__(self, name, level, fn, lno,
msg, args, exc_info)

Now when I try to unpickle it:

record = cPickle.loads(data)

I get a TypeError exception:

TypeError: ('__init__() takes at least 8 arguments (1 given)', , ())

I've searched the web and this group, but most results are old. It
worked when my workstation still ran python 2.6.

Thank you,

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


How to upload a file

2011-04-27 Thread Torsten Bronger
Hallöchen!

I'm skimming through the various recipies for uploading a file via
HTTP.  Unfortunately, all of them are awkward but also rather old.
(See for example
http://stackoverflow.com/questions/68477/send-file-using-post-from-a-python-script)

In my module, I do my HTTP request like this:

opener = 
urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.CookieJar()))
opener.open(url, urllib.urlencode(data, doseq=True))

Well, and now I'd also like to include a file upload to the POST
data.  The solution should use urllib2, otherwise I'd have to change
most of my existing code.

If you now say "Torsten, unfortunately it *is* so complicated" I'll
jump through the hoops, but I'd love to hear that with Python 2.6.5
there's an easier way.  ;-)

Tschö,
Torsten.

-- 
Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: client-server parallellised number crunching

2011-04-27 Thread Hans Georg Schaathun
On Wed, 27 Apr 2011 23:35:06 +1000, Chris Angelico
   wrote:
:  On Wed, Apr 27, 2011 at 10:21 PM, Hans Georg Schaathun 
:   wrote:
: > That's correct.  And the client initiates the connection.  At the
: > moment, I use one thread per connection, and don't really want to
: > spend the time to figure out how to do it singlethreadedly.
: 
:  Threads work quite happily in Python if they're I/O bound, which they
:  will be if they're waiting for the client to do something.

Quite.  I was referring to some tutorials and documentation recommending
to use non-blocking sockets and select() within a single thread.  I
cannot say that I understand why, but I can imagine the benefit with
heavy traffic.

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


Re: Case study: debugging failed assertRaises bug

2011-04-27 Thread R David Murray
Ben Finney  benfinney.id.au> writes:
> > (1) assertRaises REALLY needs a better error message. If not a custom
> > message, at least it should show the result it got instead of an
> > exception.
> 
> +1
> 
> Is this one of the many improvements in Python 3.2's ‘unittest’ that
> Michael Foord presided over? Or are we still stuck with the terrible
> behaviour of ‘assertRaises’?

No, but issue 10775 [1] is just waiting for Michael (or someone else
who has time) to commit the patch.

--David

[1] http://bugs.python.org/issue10775


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


Re: client-server parallellised number crunching

2011-04-27 Thread Chris Angelico
On Thu, Apr 28, 2011 at 12:15 AM, Hans Georg Schaathun  
wrote:
> Quite.  I was referring to some tutorials and documentation recommending
> to use non-blocking sockets and select() within a single thread.  I
> cannot say that I understand why, but I can imagine the benefit with
> heavy traffic.

Others will doubtless correct me if I'm wrong, but as I see it, select
is the better option if your code is mostly stateless, while threading
is easier if you want to maintain state and processing order. For
instance, with my MUD, I have one thread dedicated to each client; if
the client sends a series of commands, they will automatically queue
and be processed sequentially. On the other hand, if you run a server
where all connections are identical, it's easier to use select() and a
single thread; every time select returns, you process whichever
sockets can be processed, and move on. I don't know if the
considerations become different when you have insane numbers of
simultaneous connections; how well does your process cope with ten
thousand threads? a couple of million? In Python, it'll probably end
up pretty similar; chances are you won't be taking much advantage of
multiple CPUs/cores (because the threads will all be waiting for
socket read, or the single thread will mostly be waiting in select()),
so it's mainly a resource usage issue. Probably worth testing with
your actual code.

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


Re: minimal python27.dll?

2011-04-27 Thread Tim Golden

On 27/04/2011 11:43, est wrote:

I need to ship python runtime environment package on Windows, if I
want to stripping unnessasery functions from python27.dll to make it
as small as possible(and perhaps finally UPX it), which parts of
python27.dll do you think can be removed?


Perhaps have a look at tinypy?

  http://www.tinypy.org/

Even if it's not exactly what you want, I expect that the
author will have useful ideas / experience.

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


Deditor

2011-04-27 Thread Kruptein
Hey,

I released a new version (0.2.5) of my pythonic text-editor called
Deditor.

It is a text-editor aimed to fasten your python development. (it
perfectly handels other languages too)
Some features are:
- python shell to do quick commands or checks
- pyflakes error check on save
- pylint error check on demand (menu entry)
- Inspecting of current file
- ...

Syntax highlighting is supported for 78 languages.

An extensive plugin system, written in python, makes it very easy to
add new elements to the program.
Networking (ssh & sftp) are standard included and project management
too (you can disable them)

Please try it out and leave your comment!

download link: http://launchpad.net/deditor

( only a .deb is available for download now, if you would like another
format (.tar.gz) please comment )
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unpickling derived LogRecord in python 2.7 from python2.6

2011-04-27 Thread Peter Otten
ivdn...@gmail.com wrote:

> I have a service that runs in python 2.6.4. This service sends
> LogRecords to a log monitoring app on my workstation running python
> 2.7. The LogRecord class is derived:
> 
> class LogRecord(logging.LogRecord):
> 
> def __init__(self, name, level, fn, lno, user, hostname, msg,
> args, exc_info, func=None):
> 
> if sys.version_info[1] > 4:
> logging.LogRecord.__init__(self, name, level, fn, lno,
> msg, args, exc_info, func)
> else:
> logging.LogRecord.__init__(self, name, level, fn, lno,
> msg, args, exc_info)
> 
> Now when I try to unpickle it:
> 
> record = cPickle.loads(data)
> 
> I get a TypeError exception:
> 
> TypeError: ('__init__() takes at least 8 arguments (1 given)',  '...gRecord'>, ())
> 
> I've searched the web and this group, but most results are old. It
> worked when my workstation still ran python 2.6.

The Problem is that as of Python 2.7 logging.LogRecord has become a newstyle 
class which is pickled/unpickled differently. I don't know if there is an 
official way to do the conversion, but here's what I've hacked up. 
The script can read pickles written with 2.6 in 2.7, but not the other way 
round.

$ cat pickle_logrec.py
import sys
import pickle
import logging

class LogRecord(logging.LogRecord):

def __init__(self, name, level, fn, lno, user, hostname, msg, args, 
exc_info, func=None):

if sys.version_info[1] > 4:
logging.LogRecord.__init__(self, name, level, fn, lno, msg, 
args, exc_info, func)
else:
logging.LogRecord.__init__(self, name, level, fn, lno, msg, 
args, exc_info)

def makeLogRecord():
return LogRecord(*[None]*9)

if issubclass(LogRecord, object):
print "LogRecord is a newstyle class"
class MyUnpickler(pickle.Unpickler):
def find_class(self, *args):
klass = pickle.Unpickler.find_class(self, *args)
if klass is LogRecord:
return makeLogRecord
return klass
else:
print "LogRecord is an oldstyle class"
MyUnpickler = pickle.Unpickler

if __name__ == "__main__":
if "--load" in sys.argv:
print "loading"
with open("tmp.pickle") as f:
restored = MyUnpickler(f).load()
print restored
else:
print "dumping"
with open("tmp.pickle", "w") as f:
f.write(pickle.dumps(LogRecord("yadda", *[None]*8)))


$ python2.6 pickle_logrec.py
LogRecord is an oldstyle class
dumping
$ python2.6 pickle_logrec.py --load
LogRecord is an oldstyle class
loading

$ python2.7 pickle_logrec.py --load
LogRecord is a newstyle class
loading


No warranty, use at your own risk.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deditor

2011-04-27 Thread Alec Taylor
Thanks, any plans for a Windows version?

On Thu, Apr 28, 2011 at 1:53 AM, Kruptein  wrote:
> Hey,
>
> I released a new version (0.2.5) of my pythonic text-editor called
> Deditor.
>
> It is a text-editor aimed to fasten your python development. (it
> perfectly handels other languages too)
> Some features are:
> - python shell to do quick commands or checks
> - pyflakes error check on save
> - pylint error check on demand (menu entry)
> - Inspecting of current file
> - ...
>
> Syntax highlighting is supported for 78 languages.
>
> An extensive plugin system, written in python, makes it very easy to
> add new elements to the program.
> Networking (ssh & sftp) are standard included and project management
> too (you can disable them)
>
> Please try it out and leave your comment!
>
> download link: http://launchpad.net/deditor
>
> ( only a .deb is available for download now, if you would like another
> format (.tar.gz) please comment )
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Have you read the Python docs lately?

2011-04-27 Thread Raymond Hettinger
A number of developers have been working on adding examples and useful
advice to the docs.  To sharpen your skills, here are some pieces of
recommended reading:

http://docs.python.org/dev/library/heapq.html#priority-queue-implementation-notes

http://docs.python.org/dev/library/bisect.html#searching-sorted-lists

http://docs.python.org/dev/library/re.html#writing-a-tokenizer

http://docs.python.org/dev/library/cmd.html#cmd-example

http://docs.python.org/dev/library/collections.html#ordereddict-examples-and-recipes

http://docs.python.org/dev/howto/logging.html

http://docs.python.org/dev/howto/sorting.html

http://docs.python.org/dev/library/collections.html#collections.namedtuple


Raymond

python tips on twitter: @raymondh



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


Re: Development tools and practices for Pythonistas

2011-04-27 Thread Thomas Rachel

Am 27.04.2011 13:17, schrieb Jean-Michel Pichavant:


You're mistaking, SVN is not restricted to solo work. However it's more
suitable for solo work than git.


Why?

I personally found hg much better than svn. That's why I migrated all my 
projects.



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


Re: Deditor

2011-04-27 Thread Kruptein
On 27 apr, 19:22, Alec Taylor  wrote:
> Thanks, any plans for a Windows version?
>
>
>
> On Thu, Apr 28, 2011 at 1:53 AM, Kruptein  wrote:
> > Hey,
>
> > I released a new version (0.2.5) of my pythonic text-editor called
> > Deditor.
>
> > It is a text-editor aimed to fasten your python development. (it
> > perfectly handels other languages too)
> > Some features are:
> > - python shell to do quick commands or checks
> > - pyflakes error check on save
> > - pylint error check on demand (menu entry)
> > - Inspecting of current file
> > - ...
>
> > Syntax highlighting is supported for 78 languages.
>
> > An extensive plugin system, written in python, makes it very easy to
> > add new elements to the program.
> > Networking (ssh & sftp) are standard included and project management
> > too (you can disable them)
>
> > Please try it out and leave your comment!
>
> > download link:http://launchpad.net/deditor
>
> > ( only a .deb is available for download now, if you would like another
> > format (.tar.gz) please comment )
> > --
> >http://mail.python.org/mailman/listinfo/python-list

Well actually I have a working version of deditor for windows! it is
0.2.4 though I will do my best to release a windows version asap :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Have you read the Python docs lately?

2011-04-27 Thread Irmen de Jong
On 27-4-2011 19:56, Raymond Hettinger wrote:
> A number of developers have been working on adding examples and useful
> advice to the docs.  To sharpen your skills, here are some pieces of
> recommended reading:
> 
> http://docs.python.org/dev/library/heapq.html#priority-queue-implementation-notes
> 
> http://docs.python.org/dev/library/bisect.html#searching-sorted-lists
> 
> http://docs.python.org/dev/library/re.html#writing-a-tokenizer
> 
> http://docs.python.org/dev/library/cmd.html#cmd-example
> 
> http://docs.python.org/dev/library/collections.html#ordereddict-examples-and-recipes
> 
> http://docs.python.org/dev/howto/logging.html
> 
> http://docs.python.org/dev/howto/sorting.html
> 
> http://docs.python.org/dev/library/collections.html#collections.namedtuple
> 
> 
> Raymond

Awesome. More reasons to browse the docs online instead of using the ones that 
get
installed locally with your Python distribution :)

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


ElementTree XML parsing problem

2011-04-27 Thread Mike
I'm using ElementTree to parse an XML file, but it stops at the second 
record (id = 002), which contains a non-standard ascii character, ä. 
Here's the XML:











The complaint offered up by the parser is

Unexpected error opening simple_fail.xml: not well-formed (invalid 
token): line 5, column 40


and if I change the line to eliminate the ä, everything is wonderful. 
The parser is perfectly happy with this modification:




I can't find anything in the ElementTree docs about allowing additional 
text characters or coercing strange ascii to Unicode.


Is there a way to coerce the text so it doesn't cause the parser to 
raise an exception?


Here's my test script (simple_fail contains the offending line, and 
simple_pass contains the line that passes).


import sys
import xml.etree.ElementTree as ET

def main():

xml_files = ['simple_fail.xml', 'simple_pass.xml']
for xml_file in xml_files:

print
print 'XML file: %s' % (xml_file)

try:
tree = ET.parse(xml_file)
except Exception, inst:
print "Unexpected error opening %s: %s" % (xml_file, inst)
continue

root = tree.getroot()
records = root.find('records')
for record in records:
print record.attrib['id'], record.attrib['education']

if __name__ == "__main__":
main()


Thanks,

-- Mike --

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


Re: Python IDE/text-editor

2011-04-27 Thread Stefaan Himpe



Thanks for all the suggestions, glad I found the right one!


You're welcome :D
--
http://mail.python.org/mailman/listinfo/python-list


Re: ElementTree XML parsing problem

2011-04-27 Thread Benjamin Kaplan
On Wed, Apr 27, 2011 at 2:26 PM, Mike  wrote:
> I'm using ElementTree to parse an XML file, but it stops at the second
> record (id = 002), which contains a non-standard ascii character, ä. Here's
> the XML:
>
> 
> 
> 
> 
> 
> 
> 
> 
>
> The complaint offered up by the parser is
>
> Unexpected error opening simple_fail.xml: not well-formed (invalid token):
> line 5, column 40
>
> and if I change the line to eliminate the ä, everything is wonderful. The
> parser is perfectly happy with this modification:
>
> 
>
> I can't find anything in the ElementTree docs about allowing additional text
> characters or coercing strange ascii to Unicode.
>
> Is there a way to coerce the text so it doesn't cause the parser to raise an
> exception?
>

Have you tried specifying the file encoding? ä is not "strange ascii".
It's outside the ASCII range so if the parser expects ASCII, it will
get confused.

> Here's my test script (simple_fail contains the offending line, and
> simple_pass contains the line that passes).
>
> import sys
> import xml.etree.ElementTree as ET
>
> def main():
>
>    xml_files = ['simple_fail.xml', 'simple_pass.xml']
>    for xml_file in xml_files:
>
>        print
>        print 'XML file: %s' % (xml_file)
>
>        try:
>            tree = ET.parse(xml_file)
>        except Exception, inst:
>            print "Unexpected error opening %s: %s" % (xml_file, inst)
>            continue
>
>        root = tree.getroot()
>        records = root.find('records')
>        for record in records:
>            print record.attrib['id'], record.attrib['education']
>
> if __name__ == "__main__":
>        main()
>
>
> Thanks,
>
> -- Mike --
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: client-server parallellised number crunching

2011-04-27 Thread Hans Georg Schaathun
On Thu, 28 Apr 2011 00:58:22 +1000, Chris Angelico
   wrote:
:  thousand threads? a couple of million? In Python, it'll probably end
:  up pretty similar; chances are you won't be taking much advantage of
:  multiple CPUs/cores (because the threads will all be waiting for
:  socket read, or the single thread will mostly be waiting in select()),
:  so it's mainly a resource usage issue. Probably worth testing with
:  your actual code.

For my own application, the performance issue is rather negligible.
I don't have more than about 50 idle CPU-s which I can access easily,
and even if I had, it would always stop at 6-7000 functions calls
to evaluate.  In the current test runs using 4 clients and one master
on a quad-core, the master never uses more than around 7% of a core,
and that includes some simple post-processing as well as com's. 

In short, my philosophy is that it works, so why change it?

But, I am aware that some more technical adept programmers think
otherwise, and I am quite happy with that :-)

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


Re: Terrible FPU performance

2011-04-27 Thread David Cournapeau
On Wed, Apr 27, 2011 at 10:04 PM, Mihai Badoiu  wrote:
> I'm using intel xeon harpertown (E5450) and Python 2.6.4.
> In the cython code, when I use fpclassify, in the slow case I get 3
> (FP_SUBNORMAL)
> In the pure-C code, when I use fpclassify, in the case that's supposed to be
> slow but it's not, I get a 2 (FP_ZERO)

Ok, so this is indeed a denormal issue. Could you post the exact code
(and compilation steps) you used in both cases ?

cheers,

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


Re: [OT] VCS tools (was "Development tools and practices for Pythonistas")

2011-04-27 Thread Tim Chase

On 04/27/2011 04:24 AM, Jean-Michel Pichavant wrote:

Ben Finney wrote:

Mercurial – are the ones to choose from. Anoyone
recommending a VCS tool that has poor merging support (such
as Subversion or, heaven help us, CVS) is doing the newcomer
a disservice.


True enough. But the modern crop of first-tier VCSen – Bazaar,
Git, For a single user, there would be no merge issue. And svn
is very simple to use.


There have been plenty of times I've needed to merge in SVN as a 
solo developer.  Usually I'll branch off maint. branches and spin 
out feature branches.  For the maint. branches, I want to apply 
hot-fixes to the branch and then merge those hot-fixes into the 
dev mainline.  For the feature branches, I want to be able to 
flip between mainline development and feature development without 
one interfering with the other, but then easily pull changes from 
one to the other.


And it's always been a pain.  While I understand more recent SVN 
releases should auto-mark things in a way that merging is less 
painful, I find that it doesn't come remotely close to the ease 
with which I can merge in other systems.


-tkc



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


Re: [OT] Comparing VCS tools

2011-04-27 Thread Tim Chase

On 04/26/2011 09:45 PM, Ben Finney wrote:

Tim Chase  writes:

Bazaar (bzr)

Cons:
- was slow, though I understand they've worked on improving this


Right, that's not a count against Bazaar for at least the last several
versions (since 2009 at least). Bazaar is easily fast enough for
anything people use, say, Mercurial for.


Glad to hear.  That was my biggest beef with bzr when I tried it 
(c. 2008), so if they've got that working well, it's worth my 
time to revisit.  Do you have a reference for timing improvements 
against version number ("in version x.y, action Z took N ms; in 
version x.[y+1], action Z took N-M ms")?  I'm running Debian 
Stable and sometimes it takes a little while for these features 
to trickle down.  But I *hope* changes in 2009 would have made it 
in by now :)





Git (git)
=
Pros:
- good documentation (though somewhat scattered)


Hmm. Can't really overcome the rampant NIH syndrome: there is a lot that
shouldn't *need* so much documentation if the interface were better
designed from the start. I wouldn't count this as a pro for Git.


Yeah, I've encountered that aspect of the abundant documentation 
on Git. :)



So that said, I've become a Mercurial user because the interface was
close to SVN which I used previously, and it was speedy on my older
machines. If bzr has come up to comparable speed, I'd be game to probe
it again.


I recommend doing so.


Thanks for giving me something to do this weekend. :)

-tkc



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


Re: ElementTree XML parsing problem

2011-04-27 Thread Neil Cerutti
On 2011-04-27, Mike  wrote:
> I'm using ElementTree to parse an XML file, but it stops at the
> second record (id = 002), which contains a non-standard ascii
> character, ?. Here's the XML:
>
>
>
>
>
>
>
>
>
>
> The complaint offered up by the parser is
>
> Unexpected error opening simple_fail.xml: not well-formed
> (invalid token): line 5, column 40

It seems to be an invalid XML document, as another poster
indicated.

> and if I change the line to eliminate the ?, everything is
> wonderful. The parser is perfectly happy with this
> modification:
>
> 
>
> I can't find anything in the ElementTree docs about allowing
> additional text characters or coercing strange ascii to
> Unicode.

If you're not the one generating that bogus file, then you can
specify the encoding yourself instead by declaring an XMLParser.

  import xml.etree.ElementTree as etree
  with open('file.xml') as xml_file:
parser = etree.XMLParser(encoding='ISO-8859-1')
root = etree.parse(xml_file, parser=parser).getroot()

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


Re: De-tupleizing a list

2011-04-27 Thread Algis Kabaila
On Wednesday 27 April 2011 20:56:20 John Pinner wrote:
> On Apr 26, 4:28 am, Gnarlodious  wrote:
> > I have an SQLite query that returns a list of tuples:
> > 
> > [('0A',), ('1B',), ('2C',), ('3D',),...
> > 
> > What is the most Pythonic way to loop through the list
> > returning a list like this?:
> > 
> > ['0A', '1B', '2C', '3D',...
> > 
> > -- Gnarlie
> 
> If you want to handle a list of tuples where each tuple could
> have
> 
> *more* than one element, one solution would be:
> >>> L = [(1, 2), (2, 3, 4), (5,), (6, 7, 8, 9, 0)]
> >>> tuple([ x for t in L for x in t ])
> 
> (1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 0)
> 
> 
> John
> --
John,

That really tickles me - full marks to you!

OldAl.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ElementTree XML parsing problem

2011-04-27 Thread Philip Semanchuk

On Apr 27, 2011, at 2:26 PM, Mike wrote:

> I'm using ElementTree to parse an XML file, but it stops at the second record 
> (id = 002), which contains a non-standard ascii character, ä. Here's the XML:
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> The complaint offered up by the parser is
> 
> Unexpected error opening simple_fail.xml: not well-formed (invalid token): 
> line 5, column 40

You've gotten a number of good observations & suggestions already. I would add 
that if you're saving your XML file from a text editor, make sure you're saving 
it as UTF-8 and not ISO-8859-1 or Win-1252. 


bye
Philip

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


Re: ElementTree XML parsing problem

2011-04-27 Thread Hegedüs Ervin
hello,

> I'm using ElementTree to parse an XML file, but it stops at the
> second record (id = 002), which contains a non-standard ascii
> character, ä. Here's the XML:
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> The complaint offered up by the parser is

I've checked this xml with your script, I think your locales
settings are not good.

$ ./parse.py 

XML file: test.xml
001 High School
002 Universität Bremen
003 River College

(name of xml file is "test.xml")

So, I started change the codepage mark of xml:

 - same result
 - same result
 - same result

and then:
 - gives same error as you
described.

Try to change XML encoding.


a.

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


Re: Deditor

2011-04-27 Thread Algis Kabaila
On Thursday 28 April 2011 01:53:18 Kruptein wrote:
> Hey,
> 
> I released a new version (0.2.5) of my pythonic text-editor
> called Deditor.
>snip... 
> ( only a .deb is available for download now, if you would
> like another format (.tar.gz) please comment )

Congratulations!  Though I am happy with eric, it will be a 
pleasure to look at an alternative.  Of course, I want to look 
at the source code as that is the way to learn.  Good to see 
Launchpad and Bazaar put to good use. 

I would need the tar ball of the source code, however.  :)

I suppose it can be extracted from a deb, but that is an extra 
step and inconvenience.  Why not a tar ball?

Thanks for sharing your experience,

OldAl.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deditor

2011-04-27 Thread Kruptein
On 27 apr, 21:46, Algis Kabaila  wrote:
> On Thursday 28 April 2011 01:53:18 Kruptein wrote:
>
> > Hey,
>
> > I released a new version (0.2.5) of my pythonic text-editor
> > called Deditor.
> >snip...
> > ( only a .deb is available for download now, if you would
> > like another format (.tar.gz) please comment )
>
> Congratulations!  Though I am happy with eric, it will be a
> pleasure to look at an alternative.  Of course, I want to look
> at the source code as that is the way to learn.  Good to see
> Launchpad and Bazaar put to good use.
>
> I would need the tar ball of the source code, however.  :)
>
> I suppose it can be extracted from a deb, but that is an extra
> step and inconvenience.  Why not a tar ball?
>
> Thanks for sharing your experience,
>
> OldAl.
> --
> Algishttp://akabaila.pcug.org.au/StructuralAnalysis.pdf

No problem at all :)  it's just that I need to modify some things
before I upload the tarball
It is not the easiest code to understand if you never saw it
before :)  the plugin system may look complicated in the beginning but
is actually very easy once you understand it :) I will upload it
tommorow probably
-- 
http://mail.python.org/mailman/listinfo/python-list


I think I found a mistake in the official language reference documentation -- or I am missing somethig???

2011-04-27 Thread Igor Soares
Reading the section "6.11. The import statement"
http://docs.python.org/py3k/reference/simple_stmts.html#the-import-statement

I found:
"""
Import statements are executed in two steps: (1) find a module, and
initialize it if necessary; (2) define a name or names in the local
namespace (of the scope where the import statement occurs).
(...)
The first form (without from) repeats these steps for each identifier
in the list. The form with from performs step (1) once, and then
performs step (2) repeatedly.
"""
In the last sentence, isn't it the opposite?
With the "from" form it would find/initialize all the modules and
define just the name after "from".
Or am I missing something?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: minimal python27.dll?

2011-04-27 Thread Martin v. Loewis
Am 27.04.2011 12:43, schrieb est:
> Hi guys,
> 
> I need to ship python runtime environment package on Windows, if I
> want to stripping unnessasery functions from python27.dll to make it
> as small as possible(and perhaps finally UPX it), which parts of
> python27.dll do you think can be removed?
> 
> From what I think, these parts are not needed when shipping with final
> end-user product:
> 
> 1. debugging
> 2. parse text .py files, because everything is already in bytecode
> 
> Any ideas? Critics?

You really should be looking at object sizes first. In your build
of Python, find out what object files are largest, and check whether
they can be removed or shrinked. Starting with functions that you know
you won't need isn't as productive, as it likely leads only to small
reductions. E.g. you'll find that there is actually no debugging
support in python27.dll anymore that is worth stripping.

OTOH, you'll also find that the CJK codecs use quite some space,
if you don't need them, they give a rather impressive reduction.
Likewise for the Unicode database, although you may actually need
it in some cases.

I'd rather go for a static build of Python, and let the linker figure
out what's needed.

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


Re: ElementTree XML parsing problem

2011-04-27 Thread Mike

On 4/27/2011 12:33 PM, Hegedüs Ervin wrote:

hello,


I'm using ElementTree to parse an XML file, but it stops at the
second record (id = 002), which contains a non-standard ascii
character, ä. Here's the XML:










The complaint offered up by the parser is


I've checked this xml with your script, I think your locales
settings are not good.

$ ./parse.py

XML file: test.xml
001 High School
002 Universität Bremen
003 River College

(name of xml file is "test.xml")

So, I started change the codepage mark of xml:

  - same result
  - same result
  - same result

and then:
  - gives same error as you
described.

Try to change XML encoding.


a.


Thanks, Hegedüs and everyone else who responded. That is exactly it - 
I'm afraid I probably missed it in the docs because I was searching for 
terms like "unicode" and "coerce." In any event, that solves the 
problem. Thanks!


-- Mike --


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


Re: unpickling derived LogRecord in python 2.7 from python2.6

2011-04-27 Thread Vinay Sajip
On Apr 27, 5:41 pm, Peter Otten <__pete...@web.de> wrote:

> The Problem is that as of Python 2.7logging.LogRecord has become a newstyle
> class which is pickled/unpickled differently. I don't know if there is an
> official way to do the conversion, but here's what I've hacked up.
> The script can read pickles written with 2.6 in 2.7, but not the other way
> round.
> [code snipped]

I don't know about "official", but another way of doing this is to
pickle just the LogRecord's __dict__ and send that over the wire. The
logging package contains a function makeLogRecord(d) where d is a
dict.

This is the approach used by the examples in the library documentation
which pickle events for sending across a network:

http://docs.python.org/howto/logging-cookbook.html#sending-and-receiving-logging-events-across-a-network

The built-in SocketHandler pickles the LogRecord's __dict__ rather
than the LogRecord itself, precisely because of the improved
interoperability over pickling the instance directly.

Regards,

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


Re: Deditor

2011-04-27 Thread Yico Gaga
 why not linux?

2011/4/28 Alec Taylor 

> Thanks, any plans for a Windows version?
>
> On Thu, Apr 28, 2011 at 1:53 AM, Kruptein  wrote:
> > Hey,
> >
> > I released a new version (0.2.5) of my pythonic text-editor called
> > Deditor.
> >
> > It is a text-editor aimed to fasten your python development. (it
> > perfectly handels other languages too)
> > Some features are:
> > - python shell to do quick commands or checks
> > - pyflakes error check on save
> > - pylint error check on demand (menu entry)
> > - Inspecting of current file
> > - ...
> >
> > Syntax highlighting is supported for 78 languages.
> >
> > An extensive plugin system, written in python, makes it very easy to
> > add new elements to the program.
> > Networking (ssh & sftp) are standard included and project management
> > too (you can disable them)
> >
> > Please try it out and leave your comment!
> >
> > download link: http://launchpad.net/deditor
> >
> > ( only a .deb is available for download now, if you would like another
> > format (.tar.gz) please comment )
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deditor

2011-04-27 Thread geremy condra
On Wed, Apr 27, 2011 at 1:47 PM, Yico Gaga  wrote:
>  why not linux?

The download is a .deb, ie, for Debian and Ubuntu.

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


Re: ElementTree XML parsing problem

2011-04-27 Thread Mike

On 4/27/2011 12:24 PM, Neil Cerutti wrote:

On 2011-04-27, Mike  wrote:

I'm using ElementTree to parse an XML file, but it stops at the
second record (id = 002), which contains a non-standard ascii
character, ?. Here's the XML:










The complaint offered up by the parser is

Unexpected error opening simple_fail.xml: not well-formed
(invalid token): line 5, column 40


It seems to be an invalid XML document, as another poster
indicated.


and if I change the line to eliminate the ?, everything is
wonderful. The parser is perfectly happy with this
modification:



I can't find anything in the ElementTree docs about allowing
additional text characters or coercing strange ascii to
Unicode.


If you're not the one generating that bogus file, then you can
specify the encoding yourself instead by declaring an XMLParser.

   import xml.etree.ElementTree as etree
   with open('file.xml') as xml_file:
 parser = etree.XMLParser(encoding='ISO-8859-1')
 root = etree.parse(xml_file, parser=parser).getroot()



Thanks, Neil. I'm not generating the file, just trying to parse it. Your 
solution is precisely what I was looking for, even if I didn't quite ask 
correctly. I appreciate the help!


-- Mike --

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


Re: Deditor

2011-04-27 Thread Yico Gaga
yeah ,I know ,Ubuntu is based on Debian , i said why not linux ,
because someone ask for windows version of this Deditor ,
so, I type :why not linux.. i mean he may like to try a linux-desktop OS;
THX~

2011/4/28 geremy condra 

> On Wed, Apr 27, 2011 at 1:47 PM, Yico Gaga  wrote:
> >  why not linux?
>
> The download is a .deb, ie, for Debian and Ubuntu.
>
> Geremy Condra
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I think I found a mistake in the official language reference documentation -- or I am missing somethig???

2011-04-27 Thread Ken Watford
On Wed, Apr 27, 2011 at 4:02 PM, Igor Soares  wrote:
> Reading the section "6.11. The import statement"
> http://docs.python.org/py3k/reference/simple_stmts.html#the-import-statement
>
> I found:
> """
> Import statements are executed in two steps: (1) find a module, and
> initialize it if necessary; (2) define a name or names in the local
> namespace (of the scope where the import statement occurs).
> (...)
> The first form (without from) repeats these steps for each identifier
> in the list. The form with from performs step (1) once, and then
> performs step (2) repeatedly.
> """
> In the last sentence, isn't it the opposite?
> With the "from" form it would find/initialize all the modules and
> define just the name after "from".
> Or am I missing something?

Judging only by what you've quoted, the forms would be:

1) import os, sys, glob
2) from os.path import exists, split, join

In the first form, one or more modules come after the 'import'. In the
second form, a single module comes after the 'from', and then multiple
names from within that module come after the 'import'. Looks fine to
me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Reliably call code after object no longer exists or is "unreachable"?

2011-04-27 Thread Jack Bates
In Python, how can you reliably call code - but wait until an object no
longer exists or is "unreachable"?

I want to ensure that some code is called (excluding some exotic
situations like when the program is killed by a signal not handled by
Python) but can't call it immediately. I want to wait until there are no
references to an object - or the only references to the object are from
unreachable reference cycles


#!/usr/bin/env python

class Goodbye:
  def __del__(self):
print 'Goodbye, world!'

ref = Goodbye()


$ ./goodbye
Goodbye, world!
$ 


Python's __del__ or destructor method works (above) - but only in the
absence of reference cycles (below). An object, with a __del__ method,
in a reference cycle, causes all objects in the cycle to be
"uncollectable". This can cause memory leaks and because the object is
never collected, its __del__ method is never called


> Circular references which are garbage are detected when the option
> cycle detector is enabled (it's on by default), but can only be
> cleaned up if there are no Python-level __del__() methods involved.


#!/usr/bin/env python

class Goodbye:
  def __del__(self):
print 'Goodbye, world!'

class Cycle:
  def __init__(self, cycle):
self.next = cycle
cycle.next = self

Cycle(Goodbye())


$ ./cycle
$ 


In PEP 342 I read that an object, with a __del__ method, referenced by a
cycle but not itself participating in the cycle, doesn't cause objects
to be uncollectable. If the cycle is "collectable" then when it's
eventually collected by the garbage collector, the __del__ method is
called


> If the generator object participates in a cycle, g.__del__() may not
> be called. This is the behavior of CPython's current garbage
> collector. The reason for the restriction is that the GC code needs to
> "break" a cycle at an arbitrary point in order to collect it, and from
> then on no Python code should be allowed to see the objects that
> formed the cycle, as they may be in an invalid state. Objects "hanging
> off" a cycle are not subject to this restriction.


#!/usr/bin/env python

import sys

class Destruct:
  def __init__(self, callback):
self.__del__ = callback

class Goodbye:
  def __init__(self):
self.destruct = Destruct(lambda: sys.stdout.write('Goodbye, world!\n'))

class Cycle:
  def __init__(self, cycle):
self.next = cycle
cycle.next = self

Cycle(Goodbye())


$ ./dangle
Goodbye, world!
$ 


However it's *extremely* tricky to ensure that the object with a __del__
method doesn't participate in a cycle, e.g. in the example below, the
__del__ method is never called - I suspect because the object with a
__del__ method is reachable from the global scope, and this forms a
cycle with a frame's f_globals reference? "storing a generator object in
a global variable creates a cycle via the generator frame's f_globals
pointer"


#!/usr/bin/env python

import sys

class Destruct:
  def __init__(self, callback):
self.__del__ = callback

class Goodbye:
  def __init__(self):
self.destruct = Destruct(lambda: sys.stdout.write('Goodbye, world!\n'))

class Cycle:
  def __init__(self, cycle):
self.next = cycle
cycle.next = self

ref = Cycle(Goodbye())


$ ./global
$ 


Faced with the real potential for reference cycles, how can you reliably
call code - but wait until an object no longer exists or is
"unreachable"?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: minimal python27.dll?

2011-04-27 Thread Ryan Kelly
On Wed, 2011-04-27 at 22:06 +0200, Martin v. Loewis wrote:
> Am 27.04.2011 12:43, schrieb est:
> > Hi guys,
> > 
> > I need to ship python runtime environment package on Windows, if I
> > want to stripping unnessasery functions from python27.dll to make it
> > as small as possible(and perhaps finally UPX it), which parts of
> > python27.dll do you think can be removed?
> > 
>
> I'd rather go for a static build of Python, and let the linker figure
> out what's needed.

I have vague recollections that pythonXY.dll could not be statically
linked on Windows, or that doing so causes some serious loss of
functionality.  Was this ever true, and is it still?


  Cheers,

 Ryan


-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Have you read the Python docs lately?

2011-04-27 Thread Dan Stromberg
On Wed, Apr 27, 2011 at 10:56 AM, Raymond Hettinger  wrote:
> A number of developers have been working on adding examples and useful
> advice to the docs.  To sharpen your skills, here are some pieces of
> recommended reading:
>
> http://docs.python.org/dev/library/heapq.html#priority-queue-implementation-notes

I believe there isn't any reason why a heap _has_ to be stored in an
array - it's just one of the best representations.  Or so I was taught
in school.  Though granted, in _Python_ most heaps are arrays, because
the standard library implements them as arrays - perhaps this is what
was meant.

> http://docs.python.org/dev/library/bisect.html#searching-sorted-lists
>
> http://docs.python.org/dev/library/re.html#writing-a-tokenizer
>
> http://docs.python.org/dev/library/cmd.html#cmd-example
>
> http://docs.python.org/dev/library/collections.html#ordereddict-examples-and-recipes

Boy, all this sorting...  It seems like it'd be better to use a treap
or red black tree, even when you take into account that Python's sort
will tend to handle adding a single value in O(n) time - because the
treap or red black tree should handle the task in O(logn) time with a
low constant.

http://stromberg.dnsalias.org/~strombrg/treap/
http://newcenturycomputers.net/projects/rbtree.html

A treap should give better average case time than a red black tree,
but a red black tree should give a decent average case with less time
variability.

> http://docs.python.org/dev/howto/logging.html
>
> http://docs.python.org/dev/howto/sorting.html
>
> http://docs.python.org/dev/library/collections.html#collections.namedtuple
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I think I found a mistake in the official language reference documentation -- or I am missing somethig???

2011-04-27 Thread Igor Soares
On Apr 27, 6:21 pm, Ken Watford  wrote:
> On Wed, Apr 27, 2011 at 4:02 PM, Igor Soares  wrote:
> > Reading the section "6.11. The import statement"
> >http://docs.python.org/py3k/reference/simple_stmts.html#the-import-st...
>
> > I found:
> > """
> > Import statements are executed in two steps: (1) find a module, and
> > initialize it if necessary; (2) define a name or names in the local
> > namespace (of the scope where the import statement occurs).
> > (...)
> > The first form (without from) repeats these steps for each identifier
> > in the list. The form with from performs step (1) once, and then
> > performs step (2) repeatedly.
> > """
> > In the last sentence, isn't it the opposite?
> > With the "from" form it would find/initialize all the modules and
> > define just the name after "from".
> > Or am I missing something?
>
> Judging only by what you've quoted, the forms would be:
>
> 1) import os, sys, glob
> 2) from os.path import exists, split, join
>
> In the first form, one or more modules come after the 'import'. In the
> second form, a single module comes after the 'from', and then multiple
> names from within that module come after the 'import'. Looks fine to
> me.

Ooops... yeah, i got somthing wrong
Well, I've got a strange example running in windows, IDLE, and python
2.7.1

running this:
"import pkg1.pkg2.mod1"
defined all theese names ("pkg1", "pkg2" and "mod1") in the local
scope

But now, at home, running python 2.6.6 with Debian (without IDLE) it
doesn't work
I'll try again tomorow (maybe its IDLE)

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


Re: Have you read the Python docs lately?

2011-04-27 Thread Ben Finney
Raymond Hettinger  writes:

> A number of developers have been working on adding examples and useful
> advice to the docs. To sharpen your skills, here are some pieces of
> recommended reading:

Great stuff, and thank you for directing us to some gems.

> http://docs.python.org/dev/howto/logging.html

This one in particular was sorely needed, especially its early if-then
discussion of whether to use ‘logging’ at all. Thanks very much to Vinay
Sajip.

-- 
 \“Without cultural sanction, most or all of our religious |
  `\  beliefs and rituals would fall into the domain of mental |
_o__) disturbance.” —John F. Schumaker |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Development tools and practices for Pythonistas

2011-04-27 Thread Ben Finney
Thomas Rachel writes:

> Am 27.04.2011 13:17, schrieb Jean-Michel Pichavant:
>
> > You're mistaking, SVN is not restricted to solo work. However it's
> > more suitable for solo work than git.
>
> Why?
>
> I personally found hg much better than svn. That's why I migrated all
> my projects.

Indeed. The only thing left that Subversion is better at than the three
modern top-tier VCSen is working with existing Subversion legacy
repositories. Even for that, ‘bzr-svn’ and ‘git-svn’ work admirably
well.

-- 
 \  “Nullius in verba” (“Take no-one's word for it”) —motto of the |
  `\   Royal Society, since 1663-06-30 |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I think I found a mistake in the official language reference documentation -- or I am missing somethig???

2011-04-27 Thread MRAB

On 27/04/2011 21:02, Igor Soares wrote:

Reading the section "6.11. The import statement"
http://docs.python.org/py3k/reference/simple_stmts.html#the-import-statement

I found:
"""
Import statements are executed in two steps: (1) find a module, and
initialize it if necessary; (2) define a name or names in the local
namespace (of the scope where the import statement occurs).
(...)
The first form (without from) repeats these steps for each identifier
in the list. The form with from performs step (1) once, and then
performs step (2) repeatedly.
"""
In the last sentence, isn't it the opposite?
With the "from" form it would find/initialize all the modules and
define just the name after "from".
Or am I missing something?


The "from" form is like:

from monty import spam, eggs

The steps are:

1. find module "monty", and initialize it if necessary

2. define name "spam" in the local namespace

3. define name "eggs" in the local namespace

Also note that the name "monty" itself never enters the local namespace.
--
http://mail.python.org/mailman/listinfo/python-list


Re: minimal python27.dll?

2011-04-27 Thread est
On Apr 27, 11:15 pm, Tim Golden  wrote:
> Perhaps have a look at tinypy?
>
>    http://www.tinypy.org/
>
> Even if it's not exactly what you want, I expect that the
> author will have useful ideas / experience.
>
> TJG

Thanks, but I still need the completeness of CPython. AFAIK TinyPy is
a python implementation from scratch


On Apr 28, 4:06 am, "Martin v. Loewis"  wrote:
>
> OTOH, you'll also find that the CJK codecs use quite some space,
> if you don't need them, they give a rather impressive reduction.
> Likewise for the Unicode database, although you may actually need
> it in some cases.


On the CJK issue, why python ship its own codec, not using OS builtin?

If I don't need the full Unicode5.1 can I just map python's unicode
functions to some Win32 unicode API?
-- 
http://mail.python.org/mailman/listinfo/python-list


use of index (beginner's question)

2011-04-27 Thread Rusty Scalf

Greetings,
I am just now learning python and am trying to use the index function 
with variables.


list1 = ['pig', 'horse', 'moose']
list2 =  ['62327', '49123', '79115']
a = list2[list1.index('horse')]
print a
>49123

   -works fine. But

list1 = ['pig', 'horse', 'moose']
list2 =  ['62327', '49123', '79115']
n = 2
s2 = "list" + `n`
a = s2[list1.index('horse')]
print a

  -does not work

I'd like to use the index function in a loop updating the file names by 
adding a number to that name with each cycle. But can't get to first base.


Thank you,

   Rusty Scalf

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


Re: use of index (beginner's question)

2011-04-27 Thread Chris Angelico
On Thu, Apr 28, 2011 at 10:42 AM, Rusty Scalf  wrote:
> list1 = ['pig', 'horse', 'moose']
> list2 =  ['62327', '49123', '79115']
> n = 2
> s2 = "list" + `n`
> a = s2[list1.index('horse')]
> print a

s2 is a string with the value "list2"; this is not the same as the
variable list2. You could use eval to convert it, but you'd do better
to have a list of lists:

lists = [
 ['pig', 'horse', 'moose']
 ['62327', '49123', '79115']
]

Then you could use:
n = 2
a = lists[n][list1.index('horse')]

If it helps, you can think of this as a two-dimensional array;
technically it's not, though, it's a list that contains other lists.
(Note that you probably don't want to use the word 'list' as a
variable name; it's the name of the type, and is actually a token in
its own right. But 'lists' or something is fine.)

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


Re: Reliably call code after object no longer exists or is "unreachable"?

2011-04-27 Thread Thomas 'PointedEars' Lahn
Jack Bates wrote:

> Python's __del__ or destructor method works (above) - but only in the
> absence of reference cycles (below). An object, with a __del__ method,
> in a reference cycle, causes all objects in the cycle to be
> "uncollectable". This can cause memory leaks and because the object is
> never collected, its __del__ method is never called

AIUI there is no guarantee that __del__() will be called automatically at 
all:



> Faced with the real potential for reference cycles, how can you reliably
> call code - but wait until an object no longer exists or is
> "unreachable"?

For normal program termination, the solution is the `atexit' module (as used 
e.g. in , however it is considered better style to 
explicitly call methods that free resources, and `del' object references.

As for abnormal program termination, I think there is no way to deal with 
signals that signal.signal() cannot handle.


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


Re: Reliably call code after object no longer exists or is "unreachable"?

2011-04-27 Thread Dan Stromberg
On Wed, Apr 27, 2011 at 5:54 PM, Thomas 'PointedEars' Lahn <
pointede...@web.de> wrote:

> Jack Bates wrote:
> > Faced with the real potential for reference cycles, how can you reliably
> > call code - but wait until an object no longer exists or is
> > "unreachable"?
>
> For normal program termination, the solution is the `atexit' module (as
> used
> e.g. in <
> http://code.activestate.com/recipes/523007-semi-automatic-resource-
> management-with-autoclose/>, however it is considered better style to
> explicitly call methods that free resources, and `del' object references.
>
> As for abnormal program termination, I think there is no way to deal with
> signals that signal.signal() cannot handle.
>

Sometimes __enter__, __exit__ and "with" combine well for such a purpose,
depending on what the actual purpose is.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: use of index (beginner's question)

2011-04-27 Thread Thomas 'PointedEars' Lahn
Chris Angelico wrote:

> Rusty Scalf wrote:
>> list1 = ['pig', 'horse', 'moose']
>> list2 =  ['62327', '49123', '79115']
>> n = 2
>> s2 = "list" + `n`

I would prefer the clearer

  s2 = "list" + str(n)

or

  s2 = "list%s" % n

>> a = s2[list1.index('horse')]
>> print a
> 
> s2 is a string with the value "list2"; this is not the same as the
> variable list2. You could use eval to convert it, but you'd do better
> to have a list of lists:
> 
> lists = [
>  ['pig', 'horse', 'moose']
> ['62327', '49123', '79115']
> ]

You forgot a comma after the first `]', to separate the list elements.
A way to reuse the existing code is

  lists = [list1, list2]
 
> Then you could use:
> n = 2
> a = lists[n][list1.index('horse')]

That would throw an IndexError exception, though, since list indexes are
0-based, and this list has only two items (so the highest index is 1, not 
2).

But even if this was fixed, this could still throw a ValueError exception
if there was no 'horse' in `list1'.  While you could catch that –

  needle = 'horse'
  try:
  a = lists[n][list1.index(needle)]
  except ValueError:
  a = 'N/A'

– perhaps a better way to store this data is a dictionary:

  data = {
  'pig':   '62327',
  'horse': '49123',
  'moose': '79115'
  }

  print data.get('horse')
  print data.get('cow')
  print data.get('cow', 'N/A')

Such a dictionary can be built from the existing lists as well:

  data = dict(zip(list1, list2))
  print data
  print data.get('horse', 'N/A')


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


Re: use of index (beginner's question)

2011-04-27 Thread Chris Rebert
On Wed, Apr 27, 2011 at 6:23 PM, Thomas 'PointedEars' Lahn
 wrote:
> Chris Angelico wrote:
>> Rusty Scalf wrote:
>>> list1 = ['pig', 'horse', 'moose']
>>> list2 =  ['62327', '49123', '79115']
>>> n = 2
>>> s2 = "list" + `n`
>
> I would prefer the clearer
>
>  s2 = "list" + str(n)
>
> or
>
>  s2 = "list%s" % n

Agreed. The backticks operator is deprecated and was removed in Python 3.

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


Re: use of index (beginner's question)

2011-04-27 Thread Chris Angelico
On Thu, Apr 28, 2011 at 11:23 AM, Thomas 'PointedEars' Lahn
 wrote:
> You forgot a comma after the first `]', to separate the list elements.

Whoops! Apologies. It's very confusing when example code has silly
bugs in it! And yes, need to either back down the indices or insert a
shim. Memo, to self: Run the code through IDLE before posting it,
saves people a lot of trouble!

Incidentally, you're allowed to put the comma on the last item too:

 lists = [
  ['pig', 'horse', 'moose'],
  ['62327', '49123', '79115'],
]

Often makes for easier maintenance, especially when you append
array/list elements.

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


Re: use of index (beginner's question)

2011-04-27 Thread Steven D'Aprano
On Wed, 27 Apr 2011 17:42:30 -0700, Rusty Scalf wrote:

> Greetings,
> I am just now learning python and am trying to use the index function
> with variables.
> 
> list1 = ['pig', 'horse', 'moose']
> list2 =  ['62327', '49123', '79115']
> a = list2[list1.index('horse')]
> print a
>  >49123
> 
> -works fine. But
> 
> list1 = ['pig', 'horse', 'moose']
> list2 =  ['62327', '49123', '79115']
> n = 2
> s2 = "list" + `n`
> a = s2[list1.index('horse')]
> print a
> 
>-does not work


Define "does not work".

What do you expect to happen, and what happens instead? When I try it, 
index works perfectly. You can see that most clearly by extracting out 
the call to index without all the other noise surrounding it. 

>>> list1.index('horse')
1

Works fine.

Whatever your problem is, it has *nothing* to do with index. You could 
remove the call to index completely:

>>> a = s2[1]
>>> print a
i

and get the same result.

If you print s2, you will see your problem:

>>> print s2  # do you expect it to be ['62327', '49123', '79115'] ?
list2


s2 is a string that happens to be the same as the name of the variable 
list2. That's all.


> I'd like to use the index function in a loop updating the file names by
> adding a number to that name with each cycle. But can't get to first
> base.

Don't do it that way. Instead of:

filename1 = 'foo.txt'
filename2 = 'spam.doc'
filename3 = 'image.jpg'

Keep a list of file names:

filenames = ['foo.txt', 'spam.doc', 'image.jpg']

and work with that.



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


Access violation reading 0x00000010

2011-04-27 Thread yuan zheng
Hi,
everyone. I have a question when I invoke an api which is included a
library
open by CDLL. And then it will prompt the follow error:

libcommon.SIM_init()
WindowsError: exception: access violation reading 0x0010


What's the problem?



thanks,
yuanzheng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Access violation reading 0x00000010

2011-04-27 Thread Chris Angelico
On Thu, Apr 28, 2011 at 1:00 PM, yuan zheng  wrote:
> Hi,
>     everyone. I have a question when I invoke an api which is included a
> library
> open by CDLL. And then it will prompt the follow error:

How are you invoking it?

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


Re: use of index (beginner's question)

2011-04-27 Thread Algis Kabaila
On Thursday 28 April 2011 11:23:51 Thomas 'PointedEars' Lahn 
wrote:
> Chris Angelico wrote:
> > Rusty Scalf wrote:
> >> list1 = ['pig', 'horse', 'moose']
> >> list2 =  ['62327', '49123', '79115']
> >> n = 2
> >> s2 = "list" + `n`
>>> "list" + 'n'
'listn'
>>> 
And IMHO you did not want that, did you?

OldAl.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deditor

2011-04-27 Thread Alec Taylor
By all means I use Linux... when it's available, but I'm often on
non-Linux machines (at Uni), so it'd be great if something like
Deditor was available.

On Thu, Apr 28, 2011 at 7:07 AM, Yico Gaga  wrote:
> yeah ,I know ,Ubuntu is based on Debian , i said why not linux ,
> because someone ask for windows version of this Deditor ,
> so, I type :why not linux.. i mean he may like to try a linux-desktop OS;
> THX~
>

That'd be great, saw a bit of the YouTube video, can I confirm that
there's a keyboard shortcut to run the code in the embedded
interpreter, and that there's code-completion?

> Well actually I have a working version of deditor for windows! it is
> 0.2.4 though I will do my best to release a windows version asap :)
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Thanks for the speedy reply,

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


Re: Deditor

2011-04-27 Thread jmfauth
On 27 avr, 19:22, Alec Taylor  wrote:
> Thanks, any plans for a Windows version?
>

- Download the deb
- Unpack it with a utility like 7zip
- Throw away the unnecessary stuff, (keep the "deditor part")
- Depending on your libs, adatpt the "import"
- Launch deditor.py
- Then ...

[5 minutes]

In fact, this kind of app can be simply packed in a zip file.

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


Re: ElementTree XML parsing problem

2011-04-27 Thread Stefan Behnel

Hegedüs Ervin, 27.04.2011 21:33:

hello,


I'm using ElementTree to parse an XML file, but it stops at the
second record (id = 002), which contains a non-standard ascii
character, ä. Here's the XML:










The complaint offered up by the parser is


I've checked this xml with your script, I think your locales
settings are not good.

$ ./parse.py

XML file: test.xml
001 High School
002 Universität Bremen
003 River College

(name of xml file is "test.xml")

So, I started change the codepage mark of xml:

  - same result
  - same result
  - same result


You probably changed this in an editor that supports XML and thus saves the 
file in the declared encoding. Switching between the three by simply 
changing the first line (the XML declaration) and not adapting the encoding 
of the document itself would otherwise not yield the same result for the 
document given above.


Stefan

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


Re: Access violation reading 0x00000010

2011-04-27 Thread yuan zheng
libcommon = CDLL("c:\libcommon-0.dll", RTLD_GLOBAL)

libcommon.SIM_init() -> This is the invoking.




thanks,
yuanzheng.

2011/4/28 Chris Angelico 

> On Thu, Apr 28, 2011 at 1:00 PM, yuan zheng 
> wrote:
> > Hi,
> > everyone. I have a question when I invoke an api which is included a
> > library
> > open by CDLL. And then it will prompt the follow error:
>
> How are you invoking it?
>
> Chris Angelico
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Access violation reading 0x00000010

2011-04-27 Thread Chris Angelico
On Thu, Apr 28, 2011 at 4:01 PM, yuan zheng  wrote:
>
> libcommon = CDLL("c:\libcommon-0.dll", RTLD_GLOBAL)
>
> libcommon.SIM_init() -> This is the invoking.

When you have a backslash in a literal string, you need to double it:
libcommon = CDLL("c:\\libcommon-0.dll", RTLD_GLOBAL)

I don't know if that's your problem, but it could be!

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


Re: ElementTree XML parsing problem

2011-04-27 Thread Ervin Hegedüs
hello,

On Thu, Apr 28, 2011 at 07:57:28AM +0200, Stefan Behnel wrote:
> >So, I started change the codepage mark of xml:
> >
> >  - same result
> >  - same result
> >  - same result
> 
> You probably changed this in an editor that supports XML and thus
> saves the file in the declared encoding.

no. I've saved the XML as UTF8, and didn't change the _file_
encoding - just modified the XML header, nothing else...

(I'm using Geany - it doesn't realize what user wrote in file,
just can save file as another encodign, when user choose one)


> Switching between the three
> by simply changing the first line (the XML declaration) and not
> adapting the encoding of the document itself would otherwise not
> yield the same result for the document given above.

yes, that's what I wrote exactly.


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


Re: Have you read the Python docs lately?

2011-04-27 Thread Paul Rubin
Raymond Hettinger  writes:
> A number of developers have been working on adding examples and useful
> advice to the docs.  To sharpen your skills, here are some pieces of
> recommended reading:

Thanks, those are nice.  The logging one looks especially useful.  The
module always looked very confusing to me (too Java-like), and I've
dreaded the day when I might have to figure out how to use it instead of
my own ad-hoc logging.  I can sleep better now ;-).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Access violation reading 0x00000010

2011-04-27 Thread yuan zheng
Sorry , the path is just an example.

This is not the question I think. Because there is lots of api
in libcommon-0.dll, and there is no fault when invoking other
api, such as libcommon.SIM_start().. It's just fault when invoking
this api -> SIM_init(). So I wanna which situation would lead to this error:
--
WindowsError: exception: access violation reading 0x0010
--



thanks,
yuanzheng.


2011/4/28 Chris Angelico 

> On Thu, Apr 28, 2011 at 4:01 PM, yuan zheng 
> wrote:
> >
> > libcommon = CDLL("c:\libcommon-0.dll", RTLD_GLOBAL)
> >
> > libcommon.SIM_init() -> This is the invoking.
>
> When you have a backslash in a literal string, you need to double it:
> libcommon = CDLL("c:\\libcommon-0.dll", RTLD_GLOBAL)
>
> I don't know if that's your problem, but it could be!
>
> Chris Angelico
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list