Re: Nuitka now supports Python 3.2

2013-02-27 Thread jmfauth


Fascinating software.
Some are building, some are destroying.

Py33
>>> timeit.repeat("{1:'abc需'}")
[0.2573893570572636, 0.24261832285651508, 0.24259548003601594]

Py323
timeit.repeat("{1:'abc需'}")
[0.11000708521282831, 0.0994753634273593, 0.09901023634051853]

jmf

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


Project Based python tutorials

2013-02-27 Thread Alvin Ghouas
Hi everyone!

First of all: Im new to this group and i dont know if there are any "rules" or 
jargon around her. If so; pleas fill me in.

So, I desided to start learning programming a few months ago and by now i feel 
pretty confident about the basics of the python language, and programming in 
general. 
Variables,loops, conditionals, data structures, methods and even some object 
oriented programming, are all familiar consepts.

As i want to become a better programmer, i figured the next step would be to 
start working on some bigger and more complex projects.Yet despite my numerouse 
web searchs for project based tutorials,i cant seem to find any good ones.   
I have no trouble with understanding the concepts of programming, however I 
find it quite difficult to take it to the next "level".

So, is there anyone out there willing to share some experience? I would be 
really grateful!

Greetings from Norway!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Nuitka now supports Python 3.2

2013-02-27 Thread jmfauth
On 27 fév, 09:21, jmfauth  wrote:
> 
>
> Fascinating software.
> Some are building, some are destroying.
>
> Py33>>> timeit.repeat("{1:'abc需'}")
>
> [0.2573893570572636, 0.24261832285651508, 0.24259548003601594]
>
> Py323
> timeit.repeat("{1:'abc需'}")
> [0.11000708521282831, 0.0994753634273593, 0.09901023634051853]
>
> jmf



Oops. My bad. (This google).

You should read abc需

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


RE: Project Based python tutorials

2013-02-27 Thread Andriy Kornatskyy

I would advise try answer the question: what is my goal?

Don't be surprised that not everyone become a programmer... many people fail 
and get back to market thinking it was waste of time.

Thanks.

Andriy Kornatskyy



> Date: Wed, 27 Feb 2013 00:31:11 -0800
> Subject: Project Based python tutorials
> From: alvin.gho...@gmail.com
> To: python-list@python.org
>
> Hi everyone!
>
> First of all: Im new to this group and i dont know if there are any "rules" 
> or jargon around her. If so; pleas fill me in.
>
> So, I desided to start learning programming a few months ago and by now i 
> feel pretty confident about the basics of the python language, and 
> programming in general.
> Variables,loops, conditionals, data structures, methods and even some object 
> oriented programming, are all familiar consepts.
>
> As i want to become a better programmer, i figured the next step would be to 
> start working on some bigger and more complex projects.Yet despite my 
> numerouse web searchs for project based tutorials,i cant seem to find any 
> good ones.
> I have no trouble with understanding the concepts of programming, however I 
> find it quite difficult to take it to the next "level".
>
> So, is there anyone out there willing to share some experience? I would be 
> really grateful!
>
> Greetings from Norway!
> --
> http://mail.python.org/mailman/listinfo/python-list
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Python newbie trying to embed in C++

2013-02-27 Thread Marwan

Hello all,

I'm new to Python and just starting to learn it. For he needs of my 
project, I need to call some specific methods in Python scripts from C++.


For now, I just compiled the example in the Python documentation about 
Pure Embedding to try it out ( 
http://docs.python.org/2/extending/embedding.html#pure-embedding ).


I'm trying to test it on an extremely simple script called test.py which 
contains the following:


def testPY( value ):
   print('You input ', value )

 def Hello():
print('Hello')


When I run the generated exe, I get errors about the functions not 
existing...


TestPython.exe test Hello
AttributeError: 'module' object has no attribute 'Hello'
Cannot find function "Hello"


My Python version is 2.7.3 because that's the version used in the module 
we need to access. And I'm using VS2010 SP1 for compiling my C++ because 
that's the version used to generate our DLLs and EXEs.


Could anyone tell me why this is happening?

And I'd appreciate it if you could give me pointers to how to easily 
call Python from C++.


Thanks in advance for your help,

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


What are the Dos and Don'ts

2013-02-27 Thread Sven
Hello,

As I am new to this list I was wondering what the rules are about what you
can/can't post on this list.

Is it general python, i.e. questions, information, links to
articles/programs you have written yourself etc are all ok as long as they
are Python related

or is it more a Q&A where the point is to talk about python, help people
rather than anything else.

TIA

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


Re: Python newbie trying to embed in C++

2013-02-27 Thread Ian Kelly
On Wed, Feb 27, 2013 at 1:51 AM, Marwan  wrote:
> When I run the generated exe, I get errors about the functions not
> existing...
>
> TestPython.exe test Hello
> AttributeError: 'module' object has no attribute 'Hello'
> Cannot find function "Hello"

"test" is the name of a module in the standard library.  My guess
would be that for some reason it's importing that module rather than
your test.py.  Make sure that test.py can be found on your sys.path,
and perhaps change the name of your module to reduce confusion.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Mark Lawrence

On 26/02/2013 12:54, Steven D'Aprano wrote:

One week ago, "JoePie91" wrote a blog post challenging the Python
community and the state of Python documentation, titled:

"The Python documentation is bad, and you should feel bad".

http://joepie91.wordpress.com/2013/02/19/the-python-documentation-is-bad-
and-you-should-feel-bad/

It is valuable to contrast and compare the PHP and Python docs:

http://php.net/manual/en/index.php
http://www.python.org/doc/

There's no doubt that one of PHP's strengths, perhaps its biggest
strength, is the good state of documentation. But should we feel bad
about Python's docs? I don't think that either the Python documentation
or community is as bad as JoePie91 suggests. (Well, I won't speak for the
people on Freenode's #python. It took me approximately three minutes to
be banned from there, with no warning or explanation.)

Another response to the blog post, by one of the core developers:

http://blog.briancurtin.com/posts/why-i-dont-feel-so-bad.html



Not really when we've got world leading experts to help us out 
http://xahlee.info/perl-python/python_doc.html :) * sys.maxint


--
Cheers.

Mark Lawrence

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


Re: Nuitka now supports Python 3.2

2013-02-27 Thread Mark Lawrence

On 27/02/2013 08:21, jmfauth wrote:



Fascinating software.
Some are building, some are destroying.

Py33

timeit.repeat("{1:'abc需'}")

[0.2573893570572636, 0.24261832285651508, 0.24259548003601594]

Py323
timeit.repeat("{1:'abc需'}")
[0.11000708521282831, 0.0994753634273593, 0.09901023634051853]

jmf



Haven't I seen you at the airport throwing bread crumbs to the 
helicoptors, as clearly that's just how stupid you are?


--
Cheers.

Mark Lawrence

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


Re: nested loops

2013-02-27 Thread K. Elo

Hi!

> leonardo  writes:



how can i have it print  a row of stars beside each number, like this?:

how many seconds?: 5
5 * * * * *
4 * * * *
3 * * *
2 * *
1 *
blast off!


--- snip ---
sec = int(input("How many seconds? "))
for i in range(0,sec):
print str(sec-i)+":"+" *"*(sec-i)
print "blast off!"
--- snip ---

Please note: the value for the upper bound is not included in the range. 
In my example, the actual range is from 0 to 4.


HTH,
Kimmo


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


Re: python 3 problem: how to convert an extension method into a class Method

2013-02-27 Thread Robin Becker

On 26/02/2013 18:38, Peter Otten wrote:

Robin Becker wrote:

...3:


$ python -m timeit -s 'from new import instancemethod

from math import sqrt
class A(int): pass
A.m = instancemethod(sqrt, None, A)
a = A(42)
' 'a.m()'

100 loops, best of 3: 0.5 usec per loop
$ python -m timeit -s 'from math import sqrt

class A(int):
 def m(self):
 return sqrt(self)
a = A(42)
' 'a.m()'

100 loops, best of 3: 0.473 usec per loop


this analysis might be relevant if I wanted to use sqrt. However, in my case the 
method takes




  py  C
utf8 bytes50  20 usec
unicode   39  15

here py refers to a native python method and C  to the extension method after 
adding to the class. Both are called via an instance of the class.

--
Robin Becker

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


Re: What are the Dos and Don'ts

2013-02-27 Thread Chris Angelico
On Wed, Feb 27, 2013 at 8:19 PM, Sven  wrote:
> Hello,
>
> As I am new to this list I was wondering what the rules are about what you
> can/can't post on this list.
?
> Is it general python, i.e. questions, information, links to
> articles/programs you have written yourself etc are all ok as long as they
> are Python related
>
> or is it more a Q&A where the point is to talk about python, help people
> rather than anything else.

More the former. If it's about Python, it's probably okay. But we're
not ogres... if you do something "wrong" or post something
"off-topic", we won't eat you :) Best way to get an idea of the
character of a list is to read the archive:

http://mail.python.org/pipermail/python-list/

Or lurk for a while, then dive in when the fit grabs you, that's what
most of us do :)

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


Re: python 3 problem: how to convert an extension method into a class Method

2013-02-27 Thread Chris Angelico
On Wed, Feb 27, 2013 at 9:36 PM, Robin Becker  wrote:
> However, in my case the method takes
>
>
>
>   py  C
> utf8 bytes50  20 usec
> unicode   39  15
>
> here py refers to a native python method and C  to the extension method
> after adding to the class. Both are called via an instance of the class.

Which raises the obvious question: Does it even matter? Will the
saving of a few microseconds really make a difference? Python's best
feature is its clarity of code, not its blazing performance; its
performance goal is "fast enough", and for many MANY purposes, you
won't be able to tell the difference between that and "awesome". Don't
sacrifice your code's clarity to the little tin god of efficiency
until you're sure you actually get something back.

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


"Daemonizing" an application.

2013-02-27 Thread Gilles Lenfant
Hello,

Sorry for the obscure title, but I can't make short to explain what I'm 
searching for. :)

I made an app (kind of proxy) that works without UI within it's process. So 
far, so good.

Now I need to change "live" some controls of this application, without stopping 
it.

So my app will be split in two :

* A control app (say "appctl") for a console UI
* A daemon (or agent ?) that runs the core of the app (say "appd"), processing 
inputs and outputs

What are the best practices to do this ? Examples in a well known Pyhon app I 
could hack ? Is it possible with standard packages only ?

Thanks in advance fo any pointer.

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


win32com how to catch events

2013-02-27 Thread igorjan2332
Hello,
I have a VBS sample code that I need to rewrite into python. It calls a com 
object which then generates events. My problem is that I don't know how to 
catch this events.
VBS sample looks like this:

Set oCOV = WScript.CreateObject( "RainbowObjectHandlerSrv.RainbowCOV", "oCOV_") 
' like WithEvents in VB(A)

Sub oCOV_Update( ObjectId, ObjInstDataCOV)
   'some code
End Sub

I tried like this:

from win32com.client import DispatchWithEvents
class Events:
def Update(self, ObjectID, Data):
print('update event')

oCOV = DispatchWithEvents("RainbowObjectHandlerSrv.RainbowCOV", Events)

my code can be found here: http://pastebin.com/EgfippzD
but the event newer gets called. Any idea what I'm doing wrong?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Daemonizing" an application.

2013-02-27 Thread Chris Angelico
On Wed, Feb 27, 2013 at 9:52 PM, Gilles Lenfant
 wrote:
> Hello,
>
> Sorry for the obscure title, but I can't make short to explain what I'm 
> searching for. :)
>
> I made an app (kind of proxy) that works without UI within it's process. So 
> far, so good.
>
> Now I need to change "live" some controls of this application, without 
> stopping it.
>
> So my app will be split in two :
>
> * A control app (say "appctl") for a console UI
> * A daemon (or agent ?) that runs the core of the app (say "appd"), 
> processing inputs and outputs

Daemonizing is a fairly specific operation (forking and disconnecting
from the console), which may well be a part of what you're asking for,
but on the other hand may be unnecessary (if, for instance, you let
your core app be invoked by Upstart directly).

What form of control do you need? With many apps of this nature, the
only control required is Unix signals - particularly SIGHUP, to say
"I've edited your config files, go reread them". Your front end might
do the editing, or you could even abolish the control app altogether
and simply edit the configs manually. But if you need more, you'll
need to work out how you want them to communicate with each other.

What platform or platforms do you need this to run on?

Regardless of your answers to the above, I would say that in all
probability *yes*, you will be able to do this with just Python and
the standard library. There are a lot of batteries included with
Python :)

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


Re: python 3 problem: how to convert an extension method into a class Method

2013-02-27 Thread Robin Becker

On 27/02/2013 10:49, Chris Angelico wrote:

On Wed, Feb 27, 2013 at 9:36 PM, Robin Becker  wrote:

However, in my case the method takes



   py  C
utf8 bytes50  20 usec
unicode   39  15

here py refers to a native python method and C  to the extension method
after adding to the class. Both are called via an instance of the class.


Which raises the obvious question: Does it even matter? Will the
saving of a few microseconds really make a difference? Python's best
feature is its clarity of code, not its blazing performance; its
performance goal is "fast enough", and for many MANY purposes, you
won't be able to tell the difference between that and "awesome". Don't
sacrifice your code's clarity to the little tin god of efficiency
until you're sure you actually get something back.

ChrisA

in fact this is the stringWidth function and it's used thousands of times. I 
think when we did benchmark tests it came out as 1 or 2 as a cpu hog. Since it's 
comparatively easy to code it's an obvious choice to move to C.

--
Robin Becker

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


Re: python 3 problem: how to convert an extension method into a class Method

2013-02-27 Thread Peter Otten
Robin Becker wrote:

> On 26/02/2013 18:38, Peter Otten wrote:
>> Robin Becker wrote:
> ...3:
>>
>> $ python -m timeit -s 'from new import instancemethod
>>> from math import sqrt
>>> class A(int): pass
>>> A.m = instancemethod(sqrt, None, A)
>>> a = A(42)
>>> ' 'a.m()'
>> 100 loops, best of 3: 0.5 usec per loop
>> $ python -m timeit -s 'from math import sqrt
>>> class A(int):
>>>  def m(self):
>>>  return sqrt(self)
>>> a = A(42)
>>> ' 'a.m()'
>> 100 loops, best of 3: 0.473 usec per loop
>>
>>
> this analysis might be relevant if I wanted to use sqrt. However, in my
> case the method takes
> 
> 
> 
>py  C
> utf8 bytes50  20 usec
> unicode   39  15
> 
> here py refers to a native python method and C  to the extension method
> after adding to the class. Both are called via an instance of the class.

I think you misunderstood. You compare the time it takes to run the function 
coded in C and its Python equivalent -- that difference is indeed 
significant.

But what I was trying to measure was the difference between two ways to wrap 
the C function:

Given a function cfunc implemented in C and the two ways of turning it into 
a method

(1)
class A(object):
   pass

def method(self, ...):
   return cfunc(self, ...)
A.method = method

(2)
class A(object):
   pass

A.method = new.instancemethod(cfunc, None, A)

I interpreted my timeit results as an indication that both ways have roughly 
the same overhead (method (1) being 0.027 usec faster).

I don't have your code available, that's why I picked math.sqrt as an 
example for cfunc. 

I expect that you will get a similar result with your actual cfunc and 
therefore can (and should IMO) use method (1) in both Python 2 and 3
-- but of course not being able to measure it myself it may turn out I'm 
wrong.

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


Re: "Daemonizing" an application.

2013-02-27 Thread Werner Thie

Hi

Might be an overkill, but have a look at twisted, 
http://www.twistedmatrix.com


I usually use the spread package for structured communication between 
partners via localhost



What are the best practices to do this ? Examples in a well known Pyhon app I 
could hack ? Is it possible with standard packages only ?


Have fun, Werner

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


Re: "Daemonizing" an application.

2013-02-27 Thread Sven
On 27 February 2013 11:03, Chris Angelico  wrote:

> On Wed, Feb 27, 2013 at 9:52 PM, Gilles Lenfant
>  wrote:
> > Hello,
> >
> > Sorry for the obscure title, but I can't make short to explain what I'm
> searching for. :)
> >
> > I made an app (kind of proxy) that works without UI within it's process.
> So far, so good.
> >
> > Now I need to change "live" some controls of this application, without
> stopping it.
> >
> > So my app will be split in two :
> >
> > * A control app (say "appctl") for a console UI
> > * A daemon (or agent ?) that runs the core of the app (say "appd"),
> processing inputs and outputs
>
> Daemonizing is a fairly specific operation (forking and disconnecting
> from the console), which may well be a part of what you're asking for,
> but on the other hand may be unnecessary (if, for instance, you let
> your core app be invoked by Upstart directly).
>
> What form of control do you need? With many apps of this nature, the
> only control required is Unix signals - particularly SIGHUP, to say
> "I've edited your config files, go reread them". Your front end might
> do the editing, or you could even abolish the control app altogether
> and simply edit the configs manually. But if you need more, you'll
> need to work out how you want them to communicate with each other.
>
> What platform or platforms do you need this to run on?
>
> Regardless of your answers to the above, I would say that in all
> probability *yes*, you will be able to do this with just Python and
> the standard library. There are a lot of batteries included with
> Python :)
>

One solution is to use XMLRPC to communicate with the daemonized process.
This does involve the daemon listening on the local network. The GUI can
then connect to the daemon and send it commands which essentially is
calling functions on the daemon. These can then change certain behaviors of
the daemon process without restarting it. If you want to be hardcore you
can use sockets. There are other networking libs like Twisted and RabbitMQ,
but they might be a bit overkill for your purpose.

But whether any of this is ok depends on your use case. The signals Chris
mentioned will also work. Alternatively there are a number of filewatching
libraries like watchdog or https://github.com/seb-m/pyinotify which you can
use to monitor changes to a config file if that's the way you want to go.

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


Re: python 3 problem: how to convert an extension method into a class Method

2013-02-27 Thread Robin Becker

On 27/02/2013 11:14, Peter Otten wrote:


I think you misunderstood. You compare the time it takes to run the function
coded in C and its Python equivalent -- that difference is indeed
significant.



indeed. The function call overhead there looks pretty small so perhaps that's 
the way forward.



But what I was trying to measure was the difference between two ways to wrap
the C function:



I expect that you will get a similar result with your actual cfunc and
therefore can (and should IMO) use method (1) in both Python 2 and 3
-- but of course not being able to measure it myself it may turn out I'm
wrong.



Thanks, I suspect function calls have got faster in later pythons so my fear of 
the wrapper is outdated.


As others have pointed out I should probably be creating a method in C then I 
should be able to do something like



class A:
 def meth(self):
   .

from extension import c_dummy_class

A.meth = c_dummy_class.c_meth
--
Robin Becker

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


Re: "Daemonizing" an application.

2013-02-27 Thread Jean-Michel Pichavant
- Original Message -
> Hello,
> 
> Sorry for the obscure title, but I can't make short to explain what
> I'm searching for. :)
> 
> I made an app (kind of proxy) that works without UI within it's
> process. So far, so good.
> 
> Now I need to change "live" some controls of this application,
> without stopping it.
> 
> So my app will be split in two :
> 
> * A control app (say "appctl") for a console UI
> * A daemon (or agent ?) that runs the core of the app (say "appd"),
> processing inputs and outputs
> 
> What are the best practices to do this ? Examples in a well known
> Pyhon app I could hack ? Is it possible with standard packages only
> ?
> 
> Thanks in advance fo any pointer.
> 
> --
> Gilles Lenant

Hi, 

You could use a remote protocol. This can become very easy in python. Is your 
daemon application written in python ?
Look For xmlrpclib if you want to communicate with client/servers that are not 
written in python.

If both of them are in python, then pyro would be a good choice.
http://pythonhosted.org/Pyro4/

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Daemonizing" an application.

2013-02-27 Thread Gilles Lenfant
Le mercredi 27 février 2013 11:52:19 UTC+1, Gilles Lenfant a écrit :
> Hello,
> 
Hello again,

And thanks to all for your pointers and ideas.

As the app is already tied to an Unix like OS, I'll go with signal handling 
first since I can do all I need through reconfiguration (SIGHUP).

If I need other controls, I shall use an XML-RPC, since it's an OTB feature.

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


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Antoine Pitrou
Steven D'Aprano  pearwood.info> writes:
> 
> It is valuable to contrast and compare the PHP and Python docs:
> 
> http://php.net/manual/en/index.php
> http://www.python.org/doc/

I suppose you should compare it with http://docs.python.org/3/ instead.

> There's no doubt that one of PHP's strengths, perhaps its biggest 
> strength, is the good state of documentation.

My (probably outdated) experience with the PHP docs is that they are very
succinct and don't document failure cases or behavioral details at all.
Sure, if you only care about the big picture, they are good enough.

Regards

Antoine.


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


Re: "Daemonizing" an application.

2013-02-27 Thread Chris Angelico
On Thu, Feb 28, 2013 at 12:06 AM, Gilles Lenfant
 wrote:
> Le mercredi 27 février 2013 11:52:19 UTC+1, Gilles Lenfant a écrit :
>> Hello,
>>
> Hello again,
>
> And thanks to all for your pointers and ideas.
>
> As the app is already tied to an Unix like OS, I'll go with signal handling 
> first since I can do all I need through reconfiguration (SIGHUP).
>
> If I need other controls, I shall use an XML-RPC, since it's an OTB feature.

Sounds good! Definitely go with the simplest possible solution first;
you can always complicate things later.

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


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Antoine Pitrou
Mitya Sirenef  lightbird.net> writes:
> I think the issue with python documentation is that it ignores the 95/5
> rule: 95% of people who land on a module's page are only looking for 5%
> of its information.

The 95/5 rule is generally a fallacy which ignores that the 5% which the
readers are expecting to learn about is not the same 5% from reader to reader.
(*)

Which means that in the end you would really want a diversity of HOWTOs
targeted at different usages of the stdlib. But it is a lot of work to
write *and* maintain.

(*) cf. http://www.joelonsoftware.com/items/2006/12/09.html

Regards

Antoine.


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


Re: Writing to same file from two threads

2013-02-27 Thread Antoine Pitrou
Jens Thoms Toerring  toerring.de> writes:
> 
> Paul Rubin  nospam.invalid> wrote:
> > jt  toerring.de (Jens Thoms Toerring) writes:
> > > in garbled output (i.e. having some output from A inside a
> > > line written by B or vice versae) because the "main thread" or
> 
> > Yes they do get garbled like that.  Preferred Python style is put a
> > single thread in charge of all the i/o to that file, and communicate
> > with it by message passing through Queue objects.  That is safer than
> > directly using locks.
> 
> Thank you for confirmig my suspicion But you have induced
> another question: why is using a Queue safer than locking (not
> that I doubt that it might be more elegant etc.). Is it "safer"
> because it's less likely that one gets it wrong (e.g. by for-
> grtting to acquire the lock) or is there something inherently
> unsafe about locks?

For the record, binary files are thread-safe in Python 3, but text files
are not.
Locks are safe if you use them well. As you point out, if you forget
to acquire your lock, or if you devise a situation where there is a
deadlock between competing locks, you can have difficult to diagnose
issues. Queues have their internal locking all done for you.

Regards

Antoine.


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


Re: "Daemonizing" an application.

2013-02-27 Thread Vytas D.
Hello,

Just recently learned about memory-mapped files (module mmap). If two
processes open the same file, this file is mapped for both processes. So at
the same time the same memory space can be accesses by two processes. The
documentation stated that memory-mapped files can (and are) used for
inter-process communication. Also, you can work with the memory-mapped
files using indexing (just like strings).

So you might want to have a look at memory-mapped files if not considered
before. Might help to solve your problem.

Vytas


On Wed, Feb 27, 2013 at 1:21 PM, Chris Angelico  wrote:

> On Thu, Feb 28, 2013 at 12:06 AM, Gilles Lenfant
>  wrote:
> > Le mercredi 27 février 2013 11:52:19 UTC+1, Gilles Lenfant a écrit :
> >> Hello,
> >>
> > Hello again,
> >
> > And thanks to all for your pointers and ideas.
> >
> > As the app is already tied to an Unix like OS, I'll go with signal
> handling first since I can do all I need through reconfiguration (SIGHUP).
> >
> > If I need other controls, I shall use an XML-RPC, since it's an OTB
> feature.
>
> Sounds good! Definitely go with the simplest possible solution first;
> you can always complicate things later.
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Daemonizing" an application.

2013-02-27 Thread Tarek Ziadé

On 2/27/13 11:52 AM, Gilles Lenfant wrote:

Hello,

Sorry for the obscure title, but I can't make short to explain what I'm 
searching for. :)

I made an app (kind of proxy) that works without UI within it's process. So 
far, so good.

Now I need to change "live" some controls of this application, without stopping 
it.

So my app will be split in two :

* A control app (say "appctl") for a console UI
* A daemon (or agent ?) that runs the core of the app (say "appd"), processing 
inputs and outputs

What are the best practices to do this ? Examples in a well known Pyhon app I 
could hack ? Is it possible with standard packages only ?

Thanks in advance fo any pointer.

You can have a look at Circus - https://circus.readthedocs.org which is 
a process manager.


"circusctl" is used to control "circusd" using ZeroMQ

The nice thing about zmq as opposed to signals is that you can code your 
thing independantly from the transport
then choose which transport fits a situation: TPC (then the ctl can be 
on another box), IPC or even ITC


That also means your ctl part can be portable to any platform

Cheers
Tarek

--
Tarek Ziadé · http://ziade.org · @tarek_ziade

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


Re: "Daemonizing" an application.

2013-02-27 Thread Tarek Ziadé

s/TPC/TCP   ;)
--
http://mail.python.org/mailman/listinfo/python-list


Re: "Daemonizing" an application.

2013-02-27 Thread Gilles Lenfant
Le mercredi 27 février 2013 14:55:42 UTC+1, Tarek Ziadé a écrit :
> On 2/27/13 11:52 AM, Gilles Lenfant wrote:
> 
> > Hello,

[...]

> 
> > Thanks in advance fo any pointer.
> 
> >
> 
> You can have a look at Circus - https://circus.readthedocs.org which is 
> 
> a process manager.
> 
> 
> 
> "circusctl" is used to control "circusd" using ZeroMQ
> 
> 
> 
> The nice thing about zmq as opposed to signals is that you can code your 
> 
> thing independantly from the transport
> 
> then choose which transport fits a situation: TPC (then the ctl can be 
> 
> on another box), IPC or even ITC
> 
> 
> 
> That also means your ctl part can be portable to any platform

Hi Tarek,

Great stuff. Exactly what I was looking for. The various processes of my app 
already chat with each other using the great ZeroMQ power sockets. And can 
potentially be powered in as many physical servers since the shared persistent 
data are provided through SQLAlchemy + eXist-db.

I can read that Circus can monitor sockets too. Should I understand that I can 
monitor the state of ZMQ listening sockets with Circus too ?

Cheers
-- 
Gilles

> 
> 
> 
> Cheers
> 
> Tarek
> 
> 
> 
> -- 
> 
> Tarek Ziadé · http://ziade.org · @tarek_ziade

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


Re: Python newbie trying to embed in C++

2013-02-27 Thread Christian Gollwitzer

Am 27.02.13 09:51, schrieb Marwan:

And I'd appreciate it if you could give me pointers to how to easily
call Python from C++.


Maybe you can use boost::python?

http://www.boost.org/doc/libs/1_53_0/libs/python/doc/

Cave: I haven't used it and don't know if it is up-to-date.

Christian

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


Re: Writing to same file from two threads

2013-02-27 Thread Jens Thoms Toerring
Antoine Pitrou  wrote:
> Jens Thoms Toerring  toerring.de> writes:
> > 
> > Paul Rubin  nospam.invalid> wrote:
> > > jt  toerring.de (Jens Thoms Toerring) writes:
> > > > in garbled output (i.e. having some output from A inside a
> > > > line written by B or vice versae) because the "main thread" or
> > 
> > > Yes they do get garbled like that.  Preferred Python style is put a
> > > single thread in charge of all the i/o to that file, and communicate
> > > with it by message passing through Queue objects.  That is safer than
> > > directly using locks.
> > 
> > Thank you for confirmig my suspicion But you have induced
> > another question: why is using a Queue safer than locking (not
> > that I doubt that it might be more elegant etc.). Is it "safer"
> > because it's less likely that one gets it wrong (e.g. by for-
> > grtting to acquire the lock) or is there something inherently
> > unsafe about locks?

> For the record, binary files are thread-safe in Python 3, but text files
> are not.
> Locks are safe if you use them well. As you point out, if you forget
> to acquire your lock, or if you devise a situation where there is a
> deadlock between competing locks, you can have difficult to diagnose
> issues. Queues have their internal locking all done for you.

Thank you for your kind answers!
  Best regards, Jens
-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Django error tracebacks

2013-02-27 Thread John Gordon
I've been developing in Django for a while now and I often find that when
there is an exception in a view I'm working on, the error traceback screen
does not show the actual error; instead it claims the error occurred in
django itself (usually .../django/core/handlers/base.py).

Why is this?

(I'm using Django 1.3 instead of the current 1.4 version, but still, this
seems like a pretty basic thing to get wrong.)

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Nuitka now supports Python 3.2

2013-02-27 Thread Michael Torrie
On 02/26/2013 05:18 AM, Steven D'Aprano wrote:
> Nuitka now supports Python 3.2 syntax and compiles the full CPython 3.2 
> test suite.

Interestingly, GvR seemed to be quite critical of it in his comment at
the end of this post:
https://ep2013.europython.eu/conference/talks/nuitka-the-python-compiler

Not sure why.  Nuitka is a very interesting little project.  If nothing
else, it might be a good way of providing an executable bundle for a
python-based program, and a little speed-up is a bonus.

I find it pretty interesting that he can statically compile a dynamic
language.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Nuitka now supports Python 3.2

2013-02-27 Thread Jean-Michel Pichavant
- Original Message -
> On 02/26/2013 05:18 AM, Steven D'Aprano wrote:
> > Nuitka now supports Python 3.2 syntax and compiles the full CPython
> > 3.2
> > test suite.
> 
> Interestingly, GvR seemed to be quite critical of it in his comment
> at
> the end of this post:
> https://ep2013.europython.eu/conference/talks/nuitka-the-python-compiler
> 
> Not sure why.  Nuitka is a very interesting little project.  If
> nothing
> else, it might be a good way of providing an executable bundle for a
> python-based program, and a little speed-up is a bonus.
> 
> I find it pretty interesting that he can statically compile a dynamic
> language.
> --
> http://mail.python.org/mailman/listinfo/python-list
> 

Be careful, anyone could have signed up as GvR, or so I hope, because the GVR 
in the comment kinda act like an ass. The poster, GvR or not, makes good 
points, but he could have spared the "laughable effort" to someone that is 
sharing his work with the world.

Or did I miss something ?...

JM



-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python newbie trying to embed in C++

2013-02-27 Thread Terry Reedy

On 2/27/2013 3:51 AM, Marwan wrote:

Hello all,

I'm new to Python and just starting to learn it. For he needs of my
project, I need to call some specific methods in Python scripts from C++.

For now, I just compiled the example in the Python documentation about
Pure Embedding to try it out (
http://docs.python.org/2/extending/embedding.html#pure-embedding ).

I'm trying to test it on an extremely simple script called test.py which
contains the following:

def testPY( value ):
print('You input ', value )

  def Hello():
 print('Hello')


I hope that the second def is not really indented in your original ;-).


When I run the generated exe, I get errors about the functions not
existing...

TestPython.exe test Hello
AttributeError: 'module' object has no attribute 'Hello'
Cannot find function "Hello"

My Python version is 2.7.3 because that's the version used in the module


The windows 2.7 on python.org is compiled with VS2008.


we need to access. And I'm using VS2010 SP1 for compiling my C++ because
that's the version used to generate our DLLs and EXEs.


Mixing VS compilers can be a problem, though I don't know if that is the 
case here. Even if not, it might be for your real application.


You can try compiling 2.7.3 (or later from repository) with vs2010. I 
know people have tried it. I presume it has been done. I don't know if 
there is an (unofficial) vs2010 project file in the repository.


Python.org 3.3 *is* compiled with 2010. You can also try running the 
module with that, possibly with the help of 2to3. It might not take too 
work. The author of the module might be interested in a port anyway, 
though maybe not. Or maybe extract just the part of the module you need 
for conversion.


You might start with 3.3 for your tests and initial learning to make 
sure that compiler mismatch is not a factor. When you get that to work, 
then decide what to do.


I suppose the worst alternative might be to regenerate all the needed 
dlls and exes with 2008.


--
Terry Jan Reedy

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


mp3

2013-02-27 Thread fabriceS

Hi,

Is anybody know how to get the lenght (in seconds) of a mp3 file ?

I try with pygame.mixer but without success...


Thanks

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


Re: mp3

2013-02-27 Thread Rick Johnson
On Wednesday, February 27, 2013 3:58:03 PM UTC-6, fabriceS wrote:
> Is anybody know how to get the lenght (in seconds) of a mp3 file ?

Well Mp3's have a huge header with tons of info stuffed inside. And i remember 
seeing a nice recipe on the Python cookbook (or maybe SO) for parsing the data. 
I am sure the duration will be in there somewhere. Hopefully the mp3 is encoded 
in CBR, if however it was VBR; who the heck knows what to believe!

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


Python Speed

2013-02-27 Thread Terry Reedy

On 2/27/2013 3:21 AM, jmfauth hijacked yet another thread:
> Some are building, some are destroying.

We are still waiting for you to help build a better 3.3+, instead of 
trying to 'destroy' it with mostly irrelevant cherry-picked benchmarks.


> Py33
 timeit.repeat("{1:'abc需'}")
> [0.2573893570572636, 0.24261832285651508, 0.24259548003601594]

On my win system, I get a lower time for this:
[0.16579443757208878, 0.1475787649924598, 0.14970205670637426]

> Py323
> timeit.repeat("{1:'abc需'}")
> [0.11000708521282831, 0.0994753634273593, 0.09901023634051853]

While I get the same time for 3.2.3.
[0.11759353304428544, 0.0948244802968, 0.09532802044164157]

It seems that something about Jim's machine does not like 3.3.
*nix will probably see even less of a difference. Times are in 
microseconds, so few programs will ever notice the difference.


In the meanwhile ... Effort was put into reducing startup time for 3.3 
by making sure that every module imported during startup actual needed 
to be imported, and into speeding up imports.


The startup process is getting a deeper inspection for 3.4
http://python.org/dev/peps/pep-0432/
'Simplifying the CPython startup sequence'
with some expectation for further speedup.

Also, a real-world benchmark project has been established.
http://speed.python.org/
Some work has already been done to port benchmarks to 3.x, but I suspect 
there is more to do and more volunteers needed.


--
Terry Jan Reedy


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


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Mitya Sirenef

On 02/27/2013 08:22 AM, Antoine Pitrou wrote:

Mitya Sirenef  lightbird.net> writes:

>> I think the issue with python documentation is that it ignores the 95/5
>> rule: 95% of people who land on a module's page are only looking for 5%
>> of its information.
>
> The 95/5 rule is generally a fallacy which ignores that the 5% which the
> readers are expecting to learn about is not the same 5% from reader 
to reader.

> (*)
>
> Which means that in the end you would really want a diversity of HOWTOs
> targeted at different usages of the stdlib. But it is a lot of work to
> write *and* maintain.
>
> (*) cf. http://www.joelonsoftware.com/items/2006/12/09.html
>
> Regards
>
> Antoine.
>
>

It would be absurd on my part to claim that they're precisely the same
5%. But then again, they don't have to be. Consider that some topics are
covered in the official tutorial while others are omitted -- the authors
of the tutorial were following the same rough 95/5 concept and the idea
that some readers will find stuff they don't need in the tutorial while
at the same time not finding some of what they DO need -- did not stop
them from writing the tutorial, nor does it mean the tutorial is not
useful. -m



--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

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


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Rick Johnson
On Wednesday, February 27, 2013 7:22:44 AM UTC-6, Antoine Pitrou wrote:
> Which means that in the end you would really want a diversity of HOWTOs
> targeted at different usages of the stdlib. But it is a lot of work to
> write *and* maintain.

So instead we maintain a "simple", albeit broken, doc that experienced 
pythonista's  prefer to read, whilst newbies loath? Is not the *target* 
audience noobs?

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


ANN: Wing IDE 4.1.11 released

2013-02-27 Thread Wingware

Hi,

Wingware has released version 4.1.11 of Wing IDE, our integrated development
environment designed specifically for the Python programming language.

Wing IDE provides a professional quality code editor with vi, emacs, and 
other
key bindings, auto-completion, call tips, refactoring, context-aware 
auto-editing,
a powerful graphical debugger, version control, unit testing, search, 
and many

other features.  For details see http://wingware.com/

This minor release includes:

  * Right click on tool tabs to assign a key binding to the tool
  * Allow auto-stripping trailing white space to be limited to project 
files

  * Support for Subversion version 1.7.x
  * Allow introduce variable refactoring in more contexts
  * Support opening files with Wing via the Linux .desktop file
  * Improve auto-editing fixups
  * Fix keep external console open under Python 3
  * Restore original editor and focus after refactoring operations complete
  * Show skipped icon for groups of unit tests that were all skipped
  * 13 other bug fixes and minor improvements

For a complete change log see 
http://wingware.com/pub/wingide/4.1.11/CHANGELOG.txt


Free trial: http://wingware.com/wingide/trial
Downloads: http://wingware.com/downloads
Feature matrix: http://wingware.com/wingide/features
More information: http://wingware.com/
Sales: http://wingware.com/store/purchase
Upgrades: https://wingware.com/store/upgrade

Questions?  Don't hesitate to email us at sa...@wingware.com.

Thanks,

--

Stephan Deibel
Wingware | Python IDE
Advancing Software Development

www.wingware.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread rurpy
On 02/26/2013 05:54 AM, Steven D'Aprano wrote:
> One week ago, "JoePie91" wrote a blog post challenging the Python 
> community and the state of Python documentation, titled:
> 
> "The Python documentation is bad, and you should feel bad".
> 
> http://joepie91.wordpress.com/2013/02/19/the-python-documentation-is-bad-
> and-you-should-feel-bad/
> 
> It is valuable to contrast and compare the PHP and Python docs:

tl;dr? tb

I haven't used PHP or its documentation so I can't compare it 
to Python's.  I have used Python's documentation and can say 
I agree with many of the criticisms made by JoePie91.

One of the problems with "fixing" the Python reference docs
(by which I mean primarily the Language and Library References)
it that there is no common agreement about what a "good"
reference should be.  In the Python development community
that controls the overall structure and contents of the
Python documentation, there seems to be strong minimalist
streak.  It often seems like the documentation is the 
product of a contest to find the minimum number of words to 
describe something and still be able to defend it as correct.

Any documentation must be written with a target audience in 
mind and IMO the audience for the Python reference docs should 
be programmers familiar with one or two procedural or OO 
languages at an intermediate level.  (Obviously different 
sections of documentation can modify this.  Later documentation
will assume knowledge of basic concepts like Python objects, 
argument passing and assignment semantics and so forth that
were presented earlier, and documentation for specialized 
problem domain modules, eg an SMTP module, would assume some
knowledge of email, smtp and networking.)

As JoePie91 pointed out, reference material should describe
its subject matter completely and accurately.  Once documentation
has archived that minimum bar of viability, its quality is 
determined by how effectively it transfers that information
to the reader.  I distinguish reference from tutorial material 
in that the former is optimized for looking up information
and presenting it concisely, the latter for presenting (quite 
possibly the same) information in a linear fashion with no 
forward references and presenting it verbosely and experientially.
I distinguish a language reference from a language standard 
in that the audience for the latter are language implementors
rather than users.  I would describe a reference document for 
those already competent with Python and as a big cheat-sheet.

A frequent failing of the Python docs is just plain poor
writing.  When explaining something, start with a description
of what the something is, does, etc, in a form understandable 
by the target audience.  Is there anyone who can understand
what the very useful collections.defaultdict does without
multiple rereadings?  According to its docs, it "returns a 
new dictionary-like object."  That is underspecified -- many 
things return dictionary-like objects.  It continues "it 
overrides one method and adds one writable instance variable." 
OK, but WTF does it *do*?!  It then goes on to describe its
use which one has to understand without an overarching context
and then reason backwards to eventually figure out that it is
a dict that provides for user-specified behavior when accessed 
with a key that doesn't exist [*1]

Important quality enablers are good tables of contents, 
indexes, glossaries, cross references and examples.

Examples should be used to illustrate a textual description
and never used as a substitute for textual descriptions.

Cross references are particularly important in tying together
related material that is found in disparate doc locations.  
For example, information on Python's "+" operator is found in:
 Lang: 2.5. Operators
 Lang: 3.3.7. Emulating numeric types
 Lang: 6.5. Unary arithmetic and bitwise operations
 Lang: 6.6. Binary arithmetic operations
 Lang: 6.15. Summary (mislabeled, actually operator precedence)
 Lib: 4.4. Numeric Types
 Lib: 4.6.1. Common Sequence Operations
 Lib: 10.3. operator
and probably other places I did not think to look.
The index is not much help in tying any of these together:
 "add"  -> Lib: 2.5
 "+"-> Lib: 4.4
 "plus" -> Lang: 6.5
There are also more obscure uses that should be findable such
as in float hex strings (4.4.3. Additional Methods on Float)

Cross references to similar information can help cover for
failings in the index -- if you can find some similar function 
or concept, there is (or should be) a good chance of a cross-
reference to what you really wanted.

Good documentation will anticipate the questions a reader
will have and answer them.


Rebuttals to common responses to criticism of Python docs:

Python docs are already good
* Criticisms of Python's docs pop up on the Python 
 maillist and blogs with regularity.
* Many people confuse "usable", "i've learned to use
 despite", "look impressive", etc with "good".

Google / blogs / stackoverf

Display video in tkinter?

2013-02-27 Thread eli m
Is there a way to display video (an avi) in tkinter without having to download 
other modules? If not then are there any other options? 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread alex23
On Feb 27, 1:13 pm, Rick Johnson  wrote:
> Terry (with all due respect), do you /really/ expect that people
> have the time to open an issue on the bug tracker?

If someone can write a paragraph on their blog or this list
complaining about a problem, then yes, they have the time to open an
issue on the bug tracker.

This is the price of using open source software: you give back. You
don't get to say "I don't have the time for this, *someone else* fix
it". Who do you expect to give up *their* time to solve *your* issues?

Ranting on public forums is nothing but posturing at best, and at
worst an attempt to blackmail-by-shame people into doing something for
you. Same goes for calls for "the community" to "fix" things.

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


Re: Python Speed

2013-02-27 Thread Christian Heimes
Am 27.02.2013 23:24, schrieb Terry Reedy:
> On 2/27/2013 3:21 AM, jmfauth hijacked yet another thread:
>> Some are building, some are destroying.
> 
> We are still waiting for you to help build a better 3.3+, instead of
> trying to 'destroy' it with mostly irrelevant cherry-picked benchmarks.

PEP 412 [1] causes a slow down in the dict instantiation code, see [2].

$ for PY in python2.7 python3.2 python3.3 ./python; do cmd="$PY -R -m
timeit -n 1000 '{};{};{};{};{};{};{};{};{};{}'"; echo $cmd; eval
$cmd; done
python2.7 -R -m timeit -n 1000 '{};{};{};{};{};{};{};{};{};{}'
1000 loops, best of 3: 0.163 usec per loop
python3.2 -R -m timeit -n 1000 '{};{};{};{};{};{};{};{};{};{}'
1000 loops, best of 3: 0.139 usec per loop
python3.3 -R -m timeit -n 1000 '{};{};{};{};{};{};{};{};{};{}'
1000 loops, best of 3: 0.663 usec per loop
./python -R -m timeit -n 1000 '{};{};{};{};{};{};{};{};{};{}'
1000 loops, best of 3: 0.382 usec per loop

(./python is a patched 3.3 dev version)

Christian

[1]  http://www.python.org/dev/peps/pep-0412/
[2] http://bugs.python.org/issue16465


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


Re: mp3

2013-02-27 Thread alex23
On Feb 28, 7:58 am, fabriceS  wrote:
> Is anybody know how to get the lenght (in seconds) of a mp3 file ?

Try eyeD3: https://pypi.python.org/pypi/eyeD3

>>> import eyed3
>>> mp3 = eyed3.load(r'pygame\examples\data\house_lo.mp3')
>>> mp3.info.time_secs
7
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Speed

2013-02-27 Thread Ian Kelly
On Wed, Feb 27, 2013 at 3:24 PM, Terry Reedy  wrote:
>> Py33
> timeit.repeat("{1:'abc需'}")
>> [0.2573893570572636, 0.24261832285651508, 0.24259548003601594]
>
> On my win system, I get a lower time for this:
> [0.16579443757208878, 0.1475787649924598, 0.14970205670637426]
>
>> Py323
>> timeit.repeat("{1:'abc需'}")
>> [0.11000708521282831, 0.0994753634273593, 0.09901023634051853]
>
> While I get the same time for 3.2.3.
> [0.11759353304428544, 0.0948244802968, 0.09532802044164157]
>
> It seems that something about Jim's machine does not like 3.3.
> *nix will probably see even less of a difference. Times are in microseconds,
> so few programs will ever notice the difference.

Running the same tests in IDLE on my Windows XP laptop, I see similar
results to what jmf reports.  But from what Christian posted, it
sounds like this regression may have more to do with PEP 412 than PEP
393.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Project Based python tutorials

2013-02-27 Thread alex23
On Feb 27, 6:31 pm, Alvin Ghouas  wrote:
> Yet despite my numerouse web searchs for project based tutorials,i cant
> seem to find any good ones.

Welcome to the python list.

Guides on writing large projects are definitely few and far between. I
can only think of a few, but they're all specifically for frameworks
like Plone, and even then are generally not describing overly complex
projects. I think this knowledge is something most programmers gain
through trial & error, and when you're working on a large project you
generally don't have the time to write a tutorial telling someone else
how to do the sort of thing you're doing.

> So, is there anyone out there willing to share some experience?

I have a few recommendations:

1. Read the code of large open-source projects. This is where all the
real project-oriented experience is stored.

2. Find an open-source project you're interested in and start helping
out. Read their bug tracker and see if there's anything you think you
can fix. Become used to submitting patches and working with a team of
developers.

3. Find blogs by developers working on large projects. While not
tutorials as such, you'll learn a lot by reading about what problems
they hit and what they're currently focused on resolving.

Good luck in taking your coding to the next level!

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


Jim Hodges, 6StringStu, Six String Stu, James Stuart Hodges 3463

2013-02-27 Thread Trailer Trash Suzie
3463


577 SW Dexter Cir, Apt 201
1442 SW Haygood Loop, Apt 101
Lake City, FL 32025
(386) 438-8968
Local PD: (386) 752-4344

From: "6StringStu" 
Newsgroups: alt.social-security-disability
Date: Fri, 2 Apr 2010 01:02:30 -0500
" Of the three felonies on  my record,
1: Violation of the Mann act (federal kidnapping...)
2nd Felony arrest Homicide
3rd felony arrest assault with intent
Lots of misdomeanors. fighting hand to hand  stuff.."

From: "SixStringStu" 
Newsgroups: 
alt.social-security-disability,alt.comp.blind-users,free.UseNet,free.spam,free.spirit
Date: Mon, 10 Sep 2012 21:39:02 -0400
"My criminal record consists of one count of driving under the influance of 
alchohol"

From: "6StringStu" 
Newsgroups: alt.social-security-disability
Date: Fri, 2 Apr 2010 01:02:30 -0500
"I used to own quite a few firearms. When I awoke from my coma they had 
been "liquidated".  Nowadys I have..a 357mag revolver 
(I'd hate to drop a shell casing when doing that close up action. 
A 30-06 with a good scope that I can hit a fist sized target at 500 
yards..."

From: "SixStringStu" 
Newsgroups: alt.social-security-disability
Date: Fri, 19 Aug 2011 08:49:53 -0400
"Of the five guys that jummped me, three are rotting corpses, one is 
walking around with a pronounced limp and no orbs in their sockets and one 
pisses his pants everytime a car backfires. "
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Project Based python tutorials

2013-02-27 Thread Rick Johnson
On Wednesday, February 27, 2013 2:31:11 AM UTC-6, Alvin Ghouas wrote:

> First of all: Im new to this group and i dont know if
> there are any "rules" or jargon around her. If so; pleas
> fill me in.

The only rules are there are no rules. All we can hope is that everyone will 
"try" to play nicely. If you want to read some general rules you can live by 
when participating in online groups then a good launch point would be here:

 http://en.wikipedia.org/wiki/Etiquette_%28technology%29

> So, I desided to start learning programming a few months
> ago and by now i feel pretty confident about the basics of
> the python language, and programming in general.
> Variables, loops, conditionals, data structures, methods
> and even some object oriented programming, are all
> familiar consepts.

Congratulations on your accomplishment. However, what you describe would only 
be a good grasp of *very* basic and very *generic* aspects of programming in 
general. There is much MUCH more to learn before you start authoring a resume 
to Google or jump head first into a large scale open source project.

> As i want to become a better programmer, i figured the
> next step would be to start working on some bigger and
> more complex projects.Yet despite my numerouse web searchs
> for project based tutorials,i cant seem to find any good
> ones.

Hold on just a minute! 

Before you decide to start participating in outside projects may we have a list 
of some of the software you've written for yourself? (With all due respect) I 
very seriously doubt that someone with only a "few months" of programming 
experience is ready for the real world.

> I have no trouble with understanding the concepts of
> programming, however I find it quite difficult to take it
> to the next "level". So, is there anyone out there willing
> to share some experience? I would be really grateful.

Well how can we possibly know what "the next level" means to you when you 
failed to offer examples of your experience besides: "loops", "variables", 
"data structures", etc... Please provide a list of the types of programs you 
have written. Have you written any system tool? What about GUI applications? 
What about every programmers wet dream: THE WORLDS BEST TEXT EDITOR! What about 
libraries? Details, details!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Steven D'Aprano
On Wed, 27 Feb 2013 15:20:04 -0800, rurpy wrote:

> As JoePie91 pointed out, reference material should describe its subject
> matter completely and accurately.  Once documentation has archived that
> minimum bar of viability, its quality is determined by how effectively
> it transfers that information to the reader.

Those priorities are backwards.

Badly written reference materials that are ineffective at transferring 
information is potentially useless, no matter how complete and accurate, 
and there's often not much you can do to make it better written other 
than throwing it away and starting again.

But well-written reference material that is incomplete can be 
incrementally added to, eventually making it complete.

If anyone thinks that being complete is more important than being 
readable, let me point out that the Python source code is a 100% complete 
and accurate reference to the behaviour of Python. So we're done, yes?

No of course not.


[...]
> Documentation is the ultimate authority for what it is *supposed* to do.

Incorrect. If that were true, then there could never be a documentation 
bug. Documentation can be buggy, just as software can be buggy. If 
function f() is documented as doing X, but actually does Y, which one is 
correct? In general there is no way to tell. In practice, the ultimate 
authority is the consensus (if any!) of the people who write the software.



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


Re: Writing to same file from two threads

2013-02-27 Thread Steven D'Aprano
On Wed, 27 Feb 2013 13:26:18 +, Antoine Pitrou wrote:

> For the record, binary files are thread-safe in Python 3, but text files
> are not.

Where is this documented please?



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


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread rurpy
On 02/26/2013 11:43 AM, Terry Reedy wrote:
> On 2/26/2013 7:54 AM, Steven D'Aprano wrote:
>> One week ago, "JoePie91" wrote a blog post challenging the Python
>> community and the state of Python documentation, titled:
>>
>> "The Python documentation is bad, and you should feel bad".
>>
>> http://joepie91.wordpress.com/2013/02/19/the-python-documentation-is-bad-
>> and-you-should-feel-bad/

In which JoePie91 writes:
  ...the community around Python is one of the most hostile and
  unhelpful communities around any programming-related topic that
  I have ever seen...

> To me, this is a lying troll rant worth less than most of RantingRick's 
> posts.

Rather making his point, aren't you?

>[...]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Roy Smith
In article <54967758-e84c-4b9c-a09c-10fbdbec2...@googlegroups.com>,
 Rick Johnson  wrote:

> do you /really/ expect that people have the 
> time to open an issue on the bug tracker? 

There's a certain amount of socialism involved in OSS.  "From each 
according to his ability," really is the way it works.  If your ability 
is that you've discovered that the documentation isn't as good as it 
should be, you owe the project a few minutes of your time to create a 
ticket describing the problem (and, even better, suggesting how it could 
be improved).

Looking at my bugs.python.org activity, I see I've opened 30 bugs over 
the past 9-1/2 years.  Of those, 16 were explicitly against the docs, 
and a few more were of the "I'm not sure if this is a docs bug or a code 
bug, but it doesn't do what it says it does" variety.

> Do you really think that everyone 
> who uses python even knows about the bug tracker?

Everybody?  No.  But, anybody who uses OSS should understand that any 
non-trivial project has a bug tracker.  And even if they don't know 
where it is, they should be capable of typing "python bug tracker" into 
a search engine and finding it.

> Do you really think that people will believe that their opinion is 
> worthy of placing on the bug tracker?

In my experience, it's far more likely for people to over-estimate the 
important of their own opinion than to under-estimate it :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Mark Lawrence

On 28/02/2013 01:17, ru...@yahoo.com wrote:

On 02/26/2013 11:43 AM, Terry Reedy wrote:

On 2/26/2013 7:54 AM, Steven D'Aprano wrote:

One week ago, "JoePie91" wrote a blog post challenging the Python
community and the state of Python documentation, titled:

"The Python documentation is bad, and you should feel bad".

http://joepie91.wordpress.com/2013/02/19/the-python-documentation-is-bad-
and-you-should-feel-bad/


In which JoePie91 writes:
   ...the community around Python is one of the most hostile and
   unhelpful communities around any programming-related topic that
   I have ever seen...


To me, this is a lying troll rant worth less than most of RantingRick's
posts.


Rather making his point, aren't you?


[...]


No.

--
Cheers.

Mark Lawrence

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


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Rick Johnson
On Wednesday, February 27, 2013 5:25:25 PM UTC-6, alex23 wrote:
> Ranting on public forums is nothing but posturing at best, and at
> worst an attempt to blackmail-by-shame people into doing something for
> you. Same goes for calls for "the community" to "fix" things.

What you call ranting is most times people venting frustrations BECAUSE they 
want to help, but nobody is allowing them to be a contributing member of the 
community.

When someone tries to offer help, in the form of constructive criticism, and 
then somebody snaps at them, they then loose the will to help. I myself would 
love to contribute my "quite awesome" re-write of the Tkinter GUI library, but 
due to the friction i've encountered on this list, i am resigned to keep it to 
myself (at least for the time being). Which is sad because python (and python 
programmers) could greatly benefit from a polished Tkinter. 

Alex i can assure you, there DOES exist a very harsh attitude to outside 
opinions within this community. Case in point: Why should ANYBODY need to voice 
Python problems on various blogs around the web? I think it would be in the 
interest of the Python community to have these opinions voiced here, on the 
list, for all to discuss. 

This is why i will AGAIN mention my PyWarts list (Hypothetical at this point). 
We need an official place for the many problems of Python to be discussed in a 
fair and open manner. A place that will be open to noobs and frequented by 
pythonisitas (including the BDFL himself!)


 Path of a Python Issue

1. All perceived problems with python get voiced on the PyWarts list
2. After considerable discussion, and if we can widdle the problem down to a 
tangible bug, then a bug gets opened on the tracker.
3. Hopefully the bug will be resolved and closed ASAP.

This is a linear path of inclusion that will prompt people to participate. You 
and i both know we need more people working at the tracker, and there are many 
who want to participate, but they will never participate at the "bug tracker 
level" when they get nothing but friction at the "python-list level". We all 
need to tone down the hostility and lower the bar for those who wish to help. 
Neither this community nor this language can survive without a steady adoption 
of new members.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Speed

2013-02-27 Thread Terry Reedy

On 2/27/2013 7:15 PM, Ian Kelly wrote:

On Wed, Feb 27, 2013 at 3:24 PM, Terry Reedy  wrote:

Py33

timeit.repeat("{1:'abc需'}")

[0.2573893570572636, 0.24261832285651508, 0.24259548003601594]


On my win system, I get a lower time for this:
[0.16579443757208878, 0.1475787649924598, 0.14970205670637426]


Py323
timeit.repeat("{1:'abc需'}")
[0.11000708521282831, 0.0994753634273593, 0.09901023634051853]


While I get the same time for 3.2.3.
[0.11759353304428544, 0.0948244802968, 0.09532802044164157]

It seems that something about Jim's machine does not like 3.3.
*nix will probably see even less of a difference. Times are in microseconds,
so few programs will ever notice the difference.


Running the same tests in IDLE on my Windows XP laptop, I see similar
results to what jmf reports.


Whereas I run win 7 on a pentium i7 desktop. For this, I suspect the 
processor difference more than the OS. To really investigate, one should 
separately time string creation from dict creation with a pre-built string.


repeat('pass')  # .013 to .02 on both
repeat("'abc需'") # same, untimeable
repeat("'abc需'*10") # .12 versus .14 on 3.2 and 3.3
repeat("{1:s}", "s='abc需'")  # .10 versus .14

There is a problem with timer overhead for sub-microsecond operations. 
In interactive use, the code is compiled within a function that gets 
called. The string 'abc需' should be stored as a constant in the code 
object. To force repeated string operation, one should either time from 
command line or do an operation, as with the example above. I notice 
that the first of 3 times is almost always higher for some reason.



But from what Christian posted, it
sounds like this regression may have more to do with PEP 412 than PEP
393.


That change traded a space saving and for a small initial time cost.
Christian also showed that initial cost has since been cut. There may be 
more internal dict tweaks before 3.4.


--
Terry Jan Reedy


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


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Roy Smith
In article <287852cd-09ee-4768-9591-c1f31fe04...@googlegroups.com>,
 Rick Johnson  wrote:

> When someone tries to offer help, in the form of constructive criticism, and 
> then somebody snaps at them, they then loose the will to help. I myself would 
> love to contribute my "quite awesome" re-write of the Tkinter GUI library, 
> but due to the friction i've encountered on this list, i am resigned to keep 
> it to myself (at least for the time being). Which is sad because python (and 
> python programmers) could greatly benefit from a polished Tkinter.

So, put it on github (or whatever), and announce its availability.  If 
the Tkinter user community finds it valuable, they'll use it.  There's 
plenty of third party packages that are better than what's packaged with 
the core system (requests vs urllib, for example).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Terry Reedy

On 2/27/2013 8:17 PM, ru...@yahoo.com wrote:

On 02/26/2013 11:43 AM, Terry Reedy wrote:



In which JoePie91 writes:
   ...the community around Python is one of the most hostile and
   unhelpful communities around any programming-related topic that
   I have ever seen...


To me, this is a lying troll rant worth less than most of RantingRick's
posts.


Rather making his point, aren't you?


Not at all. Over the past 15 years I have make 1000s of polite helpful 
responses to perhaps 100s of different people. Others have done much the 
same. The fact that I am hostile to and occasionally make an exception 
to not responding to lying troll rants does not at all prove his lie. 
Indeed, Joe did not post here, and I was not speaking to him. I intended 
my complete post to be overall helpful to people who do read here. If 
Joe ever does post a polite question here, I hope and expect he would 
get a polite response.


--
Terry Jan Reedy

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


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread llanitedave
I just completed my first Python app for public consumption, and I was learning 
as I was coding.  I've played on the outskirts of the language for a few years, 
but until this project I'd never really immersed myself in it.  I ended up 
being confused a lot.  So, I DO have some relevant thoughts:

1.  The Python official documentation is not great, but it's not bad either.  
Some of it seems outdated, some of it is a bit hard to parse, some of it 
assumes more background knowledge on the part of the reader than is justified.

Somebody mentioned the Django documentation.  I've looked at it a bit, and it's 
*very* nice.  I do think that the PSF could take some clues from its style and 
approach. 
But those are pretty minor gripes.  I've learned a lot from referencing the 
documentation, and its still my first go-to source when I'm stuck.

2.  The Python Community:  Jopie91 wrote "I will no doubt piss off quite a few 
people with this statement, but the community around Python is one of the most 
hostile and unhelpful communities around any programming-related topic that I 
have ever seen – and with that I am not just referring to #python on Freenode, 
but to communities with a dense population of Python developers in general. 
This point actually consists of several separate attitudes and issues."

There, I'd have to say he's very, very wrong.  When I have on occasion asked 
questions on this group I've never been flamed, and I've always had people give 
me thoughtful answers that obviously took some effort to compose.

My most recent question here concerned something that was thought to be a bug, 
but was due more to my own unfamiliarity with the material combined with what 
I'd suggest really was some ambiguity on the part of the documentation.  
Nevertheless, even with the misunderstandings, my questions were treated 
respectfully, and that's all I ask.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Chris Angelico
On Thu, Feb 28, 2013 at 1:05 PM, Rick Johnson
 wrote:
> This is why i will AGAIN mention my PyWarts list (Hypothetical at this 
> point). We need an official place for the many problems of Python to be 
> discussed in a fair and open manner. A place that will be open to noobs and 
> frequented by pythonisitas (including the BDFL himself!)
>
> 
>  Path of a Python Issue
> 
> 1. All perceived problems with python get voiced on the PyWarts list
> 2. After considerable discussion, and if we can widdle the problem down to a 
> tangible bug, then a bug gets opened on the tracker.
> 3. Hopefully the bug will be resolved and closed ASAP.

Go start the list. When you get something that's worth posting, go
post it on the tracker. And if you post something with an actual
patch, then maybe it'll be accepted.

Why are you demanding that busy people attend to you? You are
effectively demanding that Guido, who has a full-time job as well as
being head of a large project, should - without compensation - read
and actively respond to every one of your whiny posts. That is simply
not going to happen unless he *wants to*. It's up to you to make it
worth his while, or at least interesting. That's how things work.

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


Re: Project Based python tutorials

2013-02-27 Thread llanitedave
On Wednesday, February 27, 2013 12:31:11 AM UTC-8, Alvin Ghouas wrote:
> Hi everyone!
> 
> 
> 
> First of all: Im new to this group and i dont know if there are any "rules" 
> or jargon around her. If so; pleas fill me in.
> 
> 
> 
> So, I desided to start learning programming a few months ago and by now i 
> feel pretty confident about the basics of the python language, and 
> programming in general. 
> 
> Variables,loops, conditionals, data structures, methods and even some object 
> oriented programming, are all familiar consepts.
> 
> 
> 
> As i want to become a better programmer, i figured the next step would be to 
> start working on some bigger and more complex projects.Yet despite my 
> numerouse web searchs for project based tutorials,i cant seem to find any 
> good ones.   
> 
> I have no trouble with understanding the concepts of programming, however I 
> find it quite difficult to take it to the next "level".
> 
> 
> 
> So, is there anyone out there willing to share some experience? I would be 
> really grateful!
> 
> 
> 
> Greetings from Norway!

There's no teacher like trial and error.  My main advice, as one who's not far 
beyond raw beginner myself, is to build your complex project in small 
increments.  Think of the functionality you want to implement, and break it up 
into individual modules that focus on one aspect of it.

Functions can be simple and short, and always remember that the output of one 
function can be passed as input into another.

Global variables should be minimized as much as possible, but there are most 
likely going to be a few that you'll need anyway.  So don't completely prohibit 
them from your thinking.  Make sure you label them clearly.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Project Based python tutorials

2013-02-27 Thread llanitedave
On Wednesday, February 27, 2013 4:40:41 PM UTC-8, Rick Johnson wrote:
> 
> Before you decide to start participating in outside projects may we have a 
> list of some of the software you've written for yourself? (With all due 
> respect) I very seriously doubt that someone with only a "few months" of 
> programming experience is ready for the real world.
>

Nobody is ready for the real world when they start working on their first 
"real-world" application.  If they develop their skills while developing their 
program, then with luck they'll be ready for the real world when they finish.
-- 
http://mail.python.org/mailman/listinfo/python-list


How would you do this?

2013-02-27 Thread eli m
How would you find the slope, y intercept, and slope-intercept form equation 
for a line in python?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Rick Johnson
On Wednesday, February 27, 2013 8:44:08 PM UTC-6, Chris Angelico wrote:
> On Thu, Feb 28, 2013 at 1:05 PM, Rick Johnson wrote:
> > This is why i will AGAIN mention my PyWarts list
> > (Hypothetical at this point). We need an official place
> > for the many problems of Python to be discussed in a
> > fair and open manner. A place that will be open to noobs
> > and frequented by pythonisitas (including the BDFL
> > himself!)
> > [...]
> > 
> Go start the list. 

But with that statement you keep missing the point. We DON'T need yet another 
list on yet another corner of the web. What we DO need is a list that is local 
to the community. Are you asking me to start a pywarts usenet list? Does the 
community want it to be titled "PyWarts"? How about showing me that you are 
really interested by offering some name ideas. I am quite partial to PyWarts 
because i think the name is "catchy", but i am open to outside ideas, have at 
it!

> When you get something that's worth posting, go
> post it on the tracker. And if you post something with an actual
> patch, then maybe it'll be accepted.

Yes, that's step two. First step: discussion to find the definition of the bug, 
second step: open a bug report. Having people voicing opinions on the tracker 
is diverting the time and energy of the good people who volunteer there. We 
need to move the discussion somewhere else (PyWarts)

> Why are you demanding that busy people attend to you? You are
> effectively demanding that Guido, who has a full-time job as well as
> being head of a large project, should - without compensation - read
> and actively respond to every one of your whiny posts. 

I understand the responsibilities that Guido is tasked, and i do not expect him 
to answer frivolous questions on the list. What i DO expect is that he at 
minimum publicly support the following:

1. Guido needs to wield his power by announcing (politely) that the community 
should be more open to outside opinions and methods of solving problems. This 
is the most important step and the start of a recovery process.

2. Guido should also announce that in order to achieve this goal, we need a 
very public and very intuitive path of solving Python issues. This path starts 
at a list for sharing Python related greivances (call it PyWarts if you like) , 
which HOPEFULLY he will at least make an attempt to visit from time to time. 
This list (and this path) needs to be mentioned quite prominately on the 
python.org website (which itself needs quite a bit of polishing!)

GvR has not even shown his face on python-list list for around a decade or 
more. He only posts at "py-ideas" (that i know of). This is why the community 
is in such disarray. It is paramount that he make some public appearance and 
speak of his dreams for the future. 

 "How can GvR go and declare himself a BDFL and then sail off into the sunset 
to his little island paridise of "py-ideas" without ever giving validity to his 
people and his creation? If does not want to lead anymore, fine! Say so. If he 
does, fine! Make an announcment!"

> That is simply
> not going to happen unless he *wants to*. It's up to you to make it
> worth his while, or at least interesting. That's how things work.

All i ask is for Guido to lead. That's all.

He is the only person in this whole damn community who has the influence to 
speak and have people listen. If he will publicly endorse some "good will" 
within the community, and admit that we desperately need a streamed-lined and 
linear path for solving python's many problems, i can guarantee that we will 
see a great influx of really smart people. I myself will commit every second i 
can to help move along the evolution. 

I also wish he would speak publicly about the stale nature of Tkinter and IDLE. 
Allowing these two modules to become so outdated is really tarnishing the image 
of Python's stdlib. Whether you think the modules should be in the stdlib or 
not, is *not* the question. They are there, so we must try to improve them. 

Python is a great language, but we need diverse ideas to keep the cogs of 
evolution turning. Guido can start the ball rolling 10 minutes from now, all it 
will take is for him to make a public announcement...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread llanitedave
On Wednesday, February 27, 2013 7:43:58 PM UTC-8, Rick Johnson wrote:
> 
> Python is a great language, but we need diverse ideas to keep the cogs of 
> evolution turning. Guido can start the ball rolling 10 minutes from now, all 
> it will take is for him to make a public announcement...

Geez, dude, let the man get some sleep!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread alex23
On Feb 28, 12:05 pm, Rick Johnson 
wrote:
> On Wednesday, February 27, 2013 5:25:25 PM UTC-6, alex23 wrote:
> > Ranting on public forums is nothing but posturing at best, and at
> > worst an attempt to blackmail-by-shame people into doing something for
> > you. Same goes for calls for "the community" to "fix" things.
>
> What you call ranting is most times people venting frustrations
> BECAUSE they want to help, but nobody is allowing them to be a
> contributing member of the community.

You claim that no one has time to write a bug report. I point out that
if they can spend the time ranting about the bug, then they have the
time. You then proceed to try and reframe the discussion to something
else entirely.

Venting frustrations isn't contributing. If someone is confused about
how to contribute, they could just *ask*, as people _regularly_ do
here, and are always given reasonable direction how to do so.

> When someone tries to offer help, in the form of constructive criticism, and 
> then somebody snaps at them, they then loose the will to help. I myself would 
> love to contribute my "quite awesome" re-write of the Tkinter GUI library, 
> but due to the friction i've encountered on this list, i am resigned to keep 
> it to myself (at least for the time being). Which is sad because python (and 
> python programmers) could greatly benefit from a polished Tkinter.

Insisting your personal project is shoved into the standard library
isn't helping. Write a PEP. Put the code up on PyPI. There's a well-
established path for progressing code from "look what I done make!"
into something that is considered part of Python.

> Alex i can assure you, there DOES exist a very harsh attitude to outside 
> opinions within this community.

Don't extend this list's reaction to you and your particular blend of
idiocy to the general response to opinions.

> Case in point: Why should ANYBODY need to voice Python problems on various 
> blogs around the web?

The two main reasons seem to be: vanity, and an unwillingness to
listen to criticism.

> This is why i will AGAIN mention my PyWarts list (Hypothetical at this point).

"Hypothetical" sums up pretty much all of your supposed contributions
to date.

> We need an official place for the many problems of Python to be discussed in 
> a fair and open manner. A place that will be open to noobs and frequented by 
> pythonisitas (including the BDFL himself!)

Starting a new forum just fragments the discussion even further.

> 
>  Path of a Python Issue
> 
> 1. All perceived problems with python get voiced on the PyWarts list
> 2. After considerable discussion, and if we can widdle the problem down to a 
> tangible bug, then a bug gets opened on the tracker.
> 3. Hopefully the bug will be resolved and closed ASAP.

Ah, so it's your way or no way, yet again.

THERE ALREADY EXISTS A PATH FOR DEALING WITH ISSUES.

> This is a linear path of inclusion that will prompt people to participate.

Right, until someone doesn't get the response they want and they
agitate for this to happen on Stackoverflow, or IRC, or their brand
new forum they've set up. You're not the first person to want to
impose your own brand of tyranny on the process.

> You and i both know we need more people working at the tracker

No one is going to be "working at the tracker", because no one is
*paid* to do such "work". People can participate by contributing, or
they can choose not to. The latter should also STFU if they're not
willing to contribute, but this seems to be a position you're unable
or unwilling to understand.

> Neither this community nor this language can survive without a steady 
> adoption of new members.

The current process is not doing anything like the damage to the
uptake of Python that you constantly claim it is, but you do love your
hyperbole.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread alex23
On Feb 28, 1:43 pm, Rick Johnson  wrote:
> Guido can start the ball rolling 10 minutes from now, all it will
> take is for him to make a public announcement...

Can you please stop this *constant* insistence that Guido talk to
you / do what you think is important? It's pointless posturing and
empty rhetoric and we've had to put up with it for *years* now. The
man has a job and at least one side project that is clearly of far
more interest & importance to him than jumping through hoops for one
incessant whiner.

Stop being so damn arrogant and insulting.

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


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Rick Johnson
On Wednesday, February 27, 2013 10:18:46 PM UTC-6, alex23 wrote:
> You claim that no one has time to write a bug report. I point out that
> if they can spend the time ranting about the bug, then they have the
> time. 

And i would like to point out that all your nay-saying and condemnations are 
taking some valuable time also. Time that could be better spent finding new 
ways for our "new friends" to contribute. 

* Do you care about the evolution of Python or just give it lip service?
* Do you have an ideas for the name of a Python grievance list?
* What are your opinions of the state of both Tkinter and IDLE? Are you proud 
of these modules/packages? 
* Why do you support Guido's continued reign of silence?
* But most importantly, do you not want the community/language to evolve or 
remain static?

What is your opinion on anything "Python related" Alex? All i've heard from you 
is negativity, condemnation, and insults -- with exception of your statements 
about the GG's interface the other day, all your other posts have been nothing 
but lectures to myself and other concerned Python uses.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Jason Friedman
> Python has a nice Tutorial for beginners. It is an integral part of the doc
> set. To ignore that (and the indexes) in discussing the usability of Python
> docs by beginners is to lie. (If beginners who actually read the tutorial
> have problems with particular paragraphs, improvements can be and have been
> made.)

I never thought about the quality of the Python docs until reading
these posts.  I started with Python by reading the tutorial and
browsing the module pages and have reached some level of competency.
I suppose the module pages could stand to have more examples, but as
Chris Angelico says this list should be considered part of the
documentation, in which case the documents plus this list effectively
give me any example I am wanting.  I am very grateful to those who
have given their time writing the existing documentation, answering
questions on this list, and of course writing the language!  Python
has allowed me to be more successful at my job than the other
languages I considered.

The lazy and workable approach is to read the module documentation,
make a reasonable effort, follow
http://www.catb.org/esr/faqs/smart-questions.html, and voilà.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Chris Angelico
On Thu, Feb 28, 2013 at 3:59 PM, Jason Friedman  wrote:
> The lazy and workable approach is to read the module documentation,
> make a reasonable effort, follow
> http://www.catb.org/esr/faqs/smart-questions.html, and voilà.

The Force is strong with this one.

If only others would follow this lazy approach...

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


How to edit offline vmx file using python

2013-02-27 Thread sasikiran2k7
Hi,

I am new to python, how can we edit a .vmx file offline or just simply a file 
containing the data in the below format.

My file sample.vmx contains data

pciBridge7.virtualDev = "pcieRootPort"
pciBridge7.functions = "8"
vmci0.present = "TRUE"
hpet0.present = "TRUE"
nvram = "testvmdk.nvram"
virtualHW.productCompatibility = "hosted"
powerType.powerOff = "soft"
powerType.powerOn = "hard"


I need to update those values and the updated file should contains the data

pciBridge7.virtualDev = "pcieRootPort"
pciBridge7.functions = "8"
vmci0.present = "TRUE"
hpet0.present = "TRUE"
nvram = "testing.nvram"
virtualHW.productCompatibility = "hosted"
powerType.poweroff='hard"
powerType.poweron="sof't"


Can anyone please help me in solving this problem

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


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread rurpy
On 02/27/2013 06:05 PM, Steven D'Aprano wrote:
> On Wed, 27 Feb 2013 15:20:04 -0800, rurpy wrote:
> 
>> As JoePie91 pointed out, reference material should describe its subject
>> matter completely and accurately.  Once documentation has archived that
>> minimum bar of viability, its quality is determined by how effectively
>> it transfers that information to the reader.
> 
> Those priorities are backwards.
> 
> Badly written reference materials that are ineffective at transferring 
> information is potentially useless, no matter how complete and accurate, 
> and there's often not much you can do to make it better written other 
> than throwing it away and starting again.

Why assume "useless"?  The claim is that much of the 
current Python documentation is badly written but it 
is hardly useless.  Is it even possible to be "complete 
and accurate" and totally "useless" at the same time?

> But well-written reference material that is incomplete can be 
> incrementally added to, eventually making it complete.

And badly written documentation can be incrementally rewritten 
so I don't see your point.  If you going to start with the 
premise of docs so badly written they are *totally* "useless"
then start with an equally extreme incompleteness premise: 
there is no documentation at all (including source code if 
you want to consider that, "documentation"). 

> If anyone thinks that being complete is more important than being 
> readable, let me point out that the Python source code is a 100% complete 
> and accurate reference to the behaviour of Python. 

It may be a complete and accurate if poorly readable 
reference for those who already know Python and C well
(and Java and C#/.net if you want to cover Python generally)
but the presumed target audience of the documentation does 
not necessarily know them.

And since you're claiming that readable is more important 
than complete and accurate, ask yourself which *you* would 
prefer if you could have only one: readable but incomplete
and inaccurate docs or the poorly readable but complete and 
accurate source code?

> So we're done, yes?

How so?  You have source code that is not useful for the 
intended audience of the documentation and no documentation.

> No of course not.

Right.

Perhaps a better way to look at it than I (or you) stated 
is to consider accuracy and completeness very important 
qualities of reference documentation, as is of course the 
writing quality.

> [...]
>> Documentation is the ultimate authority for what it is *supposed* to do.
> 
> Incorrect. If that were true, then there could never be a documentation 
> bug. Documentation can be buggy, just as software can be buggy. If 
> function f() is documented as doing X, but actually does Y, which one is 
> correct? In general there is no way to tell. In practice, the ultimate 
> authority is the consensus (if any!) of the people who write the software.

Correct documentation is the ultimate authority for what 
it is supposed to do.  In context, that was in contrast
to the oft-recommended technique of seeing what the software
does without reference to the documentation.  I take your 
point that when behavior and documentation disagree, it 
may not be immediately clear which is at fault but without 
reference to the documentation you will never even 
notice the discrepancy.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread alex23
On Feb 28, 2:53 pm, Rick Johnson  wrote:
> On Wednesday, February 27, 2013 10:18:46 PM UTC-6, alex23 wrote:
> > You claim that no one has time to write a bug report. I point out that
> > if they can spend the time ranting about the bug, then they have the
> > time.
>
> And i would like to point out that all your nay-saying and condemnations are 
> taking some valuable time also. Time that could be better spent finding new 
> ways for our "new friends" to contribute.

This is a false conclusion. Why would I spend time doing this when I
don't believe it's necessary?

> * Do you care about the evolution of Python or just give it lip service?

I don't see any problems with how Python is developing now. Then
again, I am pretty busy using it to write code.

> * Do you have an ideas for the name of a Python grievance list?

http://bugs.python.org/

> * What are your opinions of the state of both Tkinter and IDLE? Are you proud 
> of these modules/packages?

I don't use them, nor do I need to feel "pride" about any part of the
Python standard library. Either something is useful to me or not.

> * Why do you support Guido's continued reign of silence?

Why do you inject hyperbole into everything you write?

> * But most importantly, do you not want the community/language to evolve or 
> remain static?

I already answered that above. You, on the other hand, constantly
dodge any direct questions or criticisms. Can you provide a link to
your "improved" tkinter package on PyPI? Where is your draft PEP for
its inclusion in the standard library? How is RickPython proceeding?

> What is your opinion on anything "Python related" Alex?

My biggest opinion is that you're a ridiculous little blowhard that
this "community" would be better off without. My biggest regret re
Python is that you found it more appealing than Ruby and we got
saddled with you instead.

Other than that, I use it daily to *get real work done*. What do you
do with it other than use it as a soapbox for your ego?

> All i've heard from you is negativity, condemnation, and insults -- with 
> exception of your statements about the GG's interface the other day, all your 
> other posts have been nothing but lectures to myself and other concerned 
> Python uses.

And here you descend into slander. I condemn *you* because you're a
contemptible twit with delusions of grandeur. I lecture *you* because
you'e particularly slow and dim-witted. As for "other concerned Python
uses", the last few threads we've both posted in I've provided
pragmatic advice, if not explicit code samples, while you have done
your usual posturing and grandiose bulshytt. You responded to a
request for advice on learning how to handle complex projects with:

"Before you decide to start participating in outside projects may we
have a list of some of the software you've written for yourself? (With
all due respect) I very seriously doubt that someone with only a "few
months" of programming experience is ready for the real world."

And you have the audacity to claim that I'm the one lecturing other
people... Who do you think you are, the Python-participation police?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How would you do this?

2013-02-27 Thread Dave Angel

On 02/27/2013 10:32 PM, eli m wrote:

How would you find the slope, y intercept, and slope-intercept form equation 
for a line in python?



First, I'd form a more complete description of the problem.  Specify 
what the overall constraints are (eg. Python version, OS portability, 
where input is to be gotten, and what the input values are to mean, how 
results are to be represented)


Then, I'd write a series of tests, especially showing both parameters 
that will work, and parameters that should give exceptions.


Then, I'd break the problem description into steps in a pseudo code 
form.  For example, maybe get the input parameters (which are they, and 
in what order) from the command line. Validate the inputs, and make sure 
an answer is possible.  Then apply this formula, and print the result. 
Apply that formula and print the result.  Apply the third formula and 
print the result.  Exit the program.


Next, I'd translate that pseudo code into actual Python statements, and 
type it into a text editor.


Then run those tests, and for each that fails, either revise the test or 
the code, depending on which is wrong.


If you run into trouble on one of these steps, show us your work, and 
somebody will undoubtedly be able to help there.


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


Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Chris Angelico
On Thu, Feb 28, 2013 at 4:57 PM, alex23  wrote:
> My biggest regret re Python is that [Ranting Rick] found it more
> appealing than Ruby and we got saddled with [him] instead.

Having used Ruby a little this past couple of weeks (trying to install
a Rails application), I fully understand Rick's preference for Python;
it just proves that he wants to use a language that's actually ready
to use.

In discussion with my brother about the problems I'd been having with
Ruby, he summed up the status in one pithy phrase: Critical lack of
polish. Setting up Ruby + Rails + Spree + all the other gems that
those three require, instead of being a fairly simple half-hour job,
took me over a day.

The main issue is that Ruby functions like a niche language, but is
trying to be mainstream. Installing a gem requires that code be
compiled, and sometimes that code doesn't compile and I need to fetch
some development libraries. That's something I'm quite capable of, as
a Linux-based developer, but it's not a job for a systems
administrator. How are Ruby-based sites supposed to be deployed?

Additionally, there are a number of critical-yet-minor problems. The
standard way to invoke Rails is 'rails server' which invokes WEBrick
on port 3000. You can change that port, but to use one <=1024, you
have to be root... and there's no way to have it drop privileges
afterwards. So a Ruby on Rails system, accessible on port 80, will
have to run everything as root. No thanks. Alternatively, you can set
up firewall rules to redirect port 80 to port 3000... or have an
Apache load-balancing proxy... or, my personal favorite, set up an SSH
tunnel to localhost. All this because there's no standard way to drop
privileges after binding (nor a standard way to accept a socket passed
from another process, and listen on that - which is possible with
Ruby, just not conventional).

So, yeah. We're stuck with Rick because we have the better language+library.

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


Re: How to edit offline vmx file using python

2013-02-27 Thread Dave Angel

On 02/28/2013 12:29 AM, sasikiran...@gmail.com wrote:

Hi,

I am new to python, how can we edit a .vmx file offline or just simply a file 
containing the data in the below format.

My file sample.vmx contains data

pciBridge7.virtualDev = "pcieRootPort"
pciBridge7.functions = "8"
vmci0.present = "TRUE"
hpet0.present = "TRUE"
nvram = "testvmdk.nvram"
virtualHW.productCompatibility = "hosted"
powerType.powerOff = "soft"
powerType.powerOn = "hard"


I need to update those values and the updated file should contains the data

pciBridge7.virtualDev = "pcieRootPort"
pciBridge7.functions = "8"
vmci0.present = "TRUE"
hpet0.present = "TRUE"
nvram = "testing.nvram"
virtualHW.productCompatibility = "hosted"
powerType.poweroff='hard"
powerType.poweron="sof't"




Since the file is tiny, start by reading it all into memory, into a 
list.  Then replace last two line's 16th character with a lowercase "O" 
 And replace the last line's string following the equals sign with the 
string "\"sof't\"


There are also some spacing differences, but they're harder to describe, 
and I suspect they were accidental.


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


Re: How would you do this?

2013-02-27 Thread Michael Torrie
On 02/27/2013 08:32 PM, eli m wrote:
> How would you find the slope, y intercept, and slope-intercept form
> equation for a line in python?

Well, how do you do it by hand?  Once you have the basic formula or
algorithm down, just translate it into python.  Math is math.  We can
answer specific questions of course.  Like, how would I represent the
equation in python?  Well put each term in a variable.  For example,
3x^2-2x+4 = 0, you would store the 3, 2, and 4 in variables.  Then run
your formula on them.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Nuitka now supports Python 3.2

2013-02-27 Thread Stefan Behnel
Steven D'Aprano, 26.02.2013 13:18:
> Nuitka is an implementation of Python written in C++. At the moment it is 
> claimed to be about 2.5 times as fast as CPython running the pystone 
> benchmark.

Could we please get to the habit of not citing results of "benchmarks" that
*any* static analysis phase will just optimise away either completely or in
major parts? It's not surprising that an empty loop runs faster than one
that actually does something. And most real-world code avoids empty loops
rather deliberately.

Stefan


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


Re: Python Speed

2013-02-27 Thread Steven D'Aprano
On Wed, 27 Feb 2013 21:11:25 -0500, Terry Reedy wrote:

> There is a problem with timer overhead for sub-microsecond operations.
> In interactive use, the code is compiled within a function that gets
> called. The string 'abc需' should be stored as a constant in the code
> object. To force repeated string operation, one should either time from
> command line or do an operation, as with the example above. I notice
> that the first of 3 times is almost always higher for some reason.

I am not an expert on this, but I suspect the problem may have something 
to do with CPU pipelines and cache. The first time the timer runs, the 
cache is empty, and you get a slightly higher time. Subsequently there 
are not as many CPU cache misses, and the code runs more quickly.

Or, I could be talking out of my arse. Once upon a time CPUs were simple 
enough for me to understand what make code faster or slower, but no 
more...


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


Re: python 3 problem: how to convert an extension method into a class Method

2013-02-27 Thread Steven D'Aprano
On Wed, 27 Feb 2013 21:49:04 +1100, Chris Angelico wrote:

> On Wed, Feb 27, 2013 at 9:36 PM, Robin Becker 
> wrote:
>> However, in my case the method takes
>>
>>
>>
>>   py  C
>> utf8 bytes50  20 usec
>> unicode   39  15
>>
>> here py refers to a native python method and C  to the extension method
>> after adding to the class. Both are called via an instance of the
>> class.
> 
> Which raises the obvious question: Does it even matter? Will the saving
> of a few microseconds really make a difference? Python's best feature is
> its clarity of code, not its blazing performance; its performance goal
> is "fast enough", and for many MANY purposes, you won't be able to tell
> the difference between that and "awesome". Don't sacrifice your code's
> clarity to the little tin god of efficiency until you're sure you
> actually get something back.


While this is true, I point out that we're not really talking about a 
"few" microseconds, but over 15µs per call, more than doubling the speed 
of the function call. That's not insignificant, and calls to that 
function could well be a bottleneck determining the application's total 
processing time. Robin's very first sentence in this thread states:

"In python 2 I was able to improve speed of reportlab using a C extension
to optimize some heavily used methods."

which suggests rather strongly that, yes, it does matter.

Re-writing critical sections of code in C is a well-known, recommended 
approach to speeding up Python. You will see it in the Python library, 
where there are accelerated C versions of modules such as decimal, pickle 
and bisect. There's a standard library module in CPython for calling C 
code directly from your Python code (ctypes), and at least two others 
(cffi from PyPy, and weave), at least two projects for interfacing Python 
with C or C++ (boost, swig), and three projects for writing C code using 
Python-like syntax (pyrex, cython and numba).



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


Re: Python Speed

2013-02-27 Thread jmfauth
On 27 fév, 23:24, Terry Reedy  wrote:
> On 2/27/2013 3:21 AM, jmfauth hijacked yet another thread:
>  > Some are building, some are destroying.
>
> We are still waiting for you to help build a better 3.3+, instead of
> trying to 'destroy' it with mostly irrelevant cherry-picked benchmarks.
>
>  > Py33
>   timeit.repeat("{1:'abc需'}")
>  > [0.2573893570572636, 0.24261832285651508, 0.24259548003601594]
>
> On my win system, I get a lower time for this:
> [0.16579443757208878, 0.1475787649924598, 0.14970205670637426]
>
>  > Py323
>  > timeit.repeat("{1:'abc需'}")
>  > [0.11000708521282831, 0.0994753634273593, 0.09901023634051853]
>
> While I get the same time for 3.2.3.
> [0.11759353304428544, 0.0948244802968, 0.09532802044164157]
>
> It seems that something about Jim's machine does not like 3.3.
> *nix will probably see even less of a difference. Times are in
> microseconds, so few programs will ever notice the difference.
>
> In the meanwhile ... Effort was put into reducing startup time for 3.3
> by making sure that every module imported during startup actual needed
> to be imported, and into speeding up imports.
>
> The startup process is getting a deeper inspection for 
> 3.4http://python.org/dev/peps/pep-0432/
> 'Simplifying the CPython startup sequence'
> with some expectation for further speedup.
>
> Also, a real-world benchmark project has been 
> established.http://speed.python.org/
> Some work has already been done to port benchmarks to 3.x, but I suspect
> there is more to do and more volunteers needed.
>
> --
> Terry Jan Reedy

-

Terry,

As long as you are attempting to work with a "composite" scheme
not working with a unique set of characters, not only it will
not work (properly/with efficiency), it can not work.

This not even a unicode problem. This is true for every coding
scheme. That's why we have, today, all these coding schemes, "coding
scheme": == "set of characters"; != "set of encoded characters".

jmf

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