Re: Python Interview Questions

2012-09-04 Thread charvigroups
Hi Guys, Finally I have decided to put best interview question and answers. Please visit http://www.f2finterview.com/web/CorePython/ for core python and http://www.f2finterview.com/web/PythonAdvanced/ for advanced python On Tuesday, October 30, 2007 11:44:01 PM UTC+5:30, Krypto wrote: > Hi, >

Re: why did the WindowsError occur?

2012-09-04 Thread Benjamin Kaplan
On Tue, Sep 4, 2012 at 11:30 PM, Levi Nie wrote: > my code: > import os > os.startfile(r'C:\Program Files\Internet Explorer.exe') > > the error: > os.startfile(r'C:\Program Files\Internet Explorer.exe') > WindowsError: [Error 2] : 'C:\\Program Files\\Internet Explorer.exe' > There's no such thing

[Ann] superfixer - stop hardcoding class names in super calls

2012-09-04 Thread Marcin Tustin
Hi All, I have a small library which supplies a metaclass superfixer, which when applied to a class, provides every method with a variable __class__, which refers to the class in which the method is defined. This avoids the need to refer to the current class name in calls to super. If there's any

Re: is implemented with id ?

2012-09-04 Thread Benjamin Kaplan
On Tue, Sep 4, 2012 at 11:30 PM, Franck Ditter wrote: > Hi ! > a is b <==> id(a) == id(b) in builtin classes. > Is that true ? > Thanks, > > franck No. It is true that if a is b then id(a) == id(b) but the reverse is not necessarily true. id is only guaranteed to be unique among objects alive

is implemented with id ?

2012-09-04 Thread Franck Ditter
Hi ! a is b <==> id(a) == id(b) in builtin classes. Is that true ? Thanks, franck -- http://mail.python.org/mailman/listinfo/python-list

why did the WindowsError occur?

2012-09-04 Thread Levi Nie
my code: import os os.startfile(r'C:\Program Files\Internet Explorer.exe') the error: os.startfile(r'C:\Program Files\Internet Explorer.exe') WindowsError: [Error 2] : 'C:\\Program Files\\Internet Explorer.exe' -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginners question

2012-09-04 Thread charvigroups
Hi, I have attached python interview questions and answers for beginners. Please visit http://www.f2finterview.com/web/CorePython/ for core python and http://www.f2finterview.com/web/PythonAdvanced/ for advanced python On Thursday, August 30, 2012 5:24:08 PM UTC+5:30, (unknown) wrote: > Hello

Re: Why derivated exception can not be pickled ?

2012-09-04 Thread Dieter Maurer
Mathieu Courtois writes: > Here is my example : > > > import cPickle > > ParentClass = object # works > ParentClass = Exception # does not > > class MyError(ParentClass): > def __init__(self, arg): > self.arg = arg > > def __getstate__(self): > print '#DBG pass in get

Re: sockets,threads and interupts

2012-09-04 Thread Dieter Maurer
loial writes: > I have threaded python script that uses sockets to monitor network ports. > > I want to ensure that the socket is closed cleanly in all circumstances. This > includes if the script is killed or interupted in some other way. The operating system should close all sockets automatic

Re: python docs search for 'print'

2012-09-04 Thread Ramchandra Apte
On Wednesday, 5 September 2012 09:35:43 UTC+5:30, Terry Reedy wrote: > On 9/4/2012 11:22 PM, Ramchandra Apte wrote: > > > > > I was actually planning to write a bug on this. > > > > If you do, find the right place to submit it. > > bugs.python.org is for issues relating to the cpython repos

Re: How to tell people to ask questions the smart way

2012-09-04 Thread rusi
On Sep 5, 4:27 am, Mark Lawrence wrote: > On 05/09/2012 00:05, Ben Finney wrote: > > > > > > > > > > > Andreas Perstinger writes: > > >> On 04.09.2012 11:34, Paolo wrote: > >>> how do I know if a JTextField has the focus? > >>> thank to all > > >> Look there: > >>http://www.catb.org/esr/faqs/smar

Re: python docs search for 'print'

2012-09-04 Thread Terry Reedy
On 9/4/2012 11:22 PM, Ramchandra Apte wrote: I was actually planning to write a bug on this. If you do, find the right place to submit it. bugs.python.org is for issues relating to the cpython repository.' I fairly sure that the website search code is not there. If you do find the right place

Zooming and Editing TkInter Images

2012-09-04 Thread jimbo1qaz
How do I zoom in on a tkinter image? And how do I change the selected pixel to a changeable color when the user clicks or drags? -- http://mail.python.org/mailman/listinfo/python-list

Re: python docs search for 'print'

2012-09-04 Thread Dwight Hutto
The generated code can be run without Python installed and does not embed Python. For example: print("Hello World to py2c!") would be translated to #include "iostream" using namespace std; //If you want you can make py2c not add this and use std::cout instead of cout int main() { cout<<"Hell

Re: Error 32 - Broken Pipe . Please Help!!

2012-09-04 Thread Ramchandra Apte
On Tuesday, 4 September 2012 22:38:03 UTC+5:30, Sreenath k wrote: > Error: > > > > > > Exception in thread Thread-1: > > Traceback (most recent call last): > > File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner > > self.run() > > File > "/usr/lib/python2.7/dis

Re: sockets,threads and interupts

2012-09-04 Thread Ramchandra Apte
On Tuesday, 4 September 2012 23:41:13 UTC+5:30, Grant Edwards wrote: > On 2012-09-04, MRAB wrote: > > > On 04/09/2012 16:26, loial wrote: > > >> I have threaded python script that uses sockets to monitor network > > >> ports. > > >> > > >> I want to ensure that the socket is closed cleanly i

Re: python docs search for 'print'

2012-09-04 Thread Ramchandra Apte
On Tuesday, 4 September 2012 23:29:26 UTC+5:30, David Hoese wrote: > A friend made me aware of this: > > When a python beginner (2.x) quick searches for "print" on > > docs.python.org, the print function doesn't even come up in the top 20 > > results. The print statement isn't even listed as

Re: Comparing strings from the back?

2012-09-04 Thread Roy Smith
In article <-9cdnaqjtk6nktvnnz2dnuvz_gedn...@westnet.com.au>, Neil Hodgson wrote: > The memcpy patch was controversial as it broke Adobe Flash An added benefit! -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing strings from the back?

2012-09-04 Thread MRAB
On 05/09/2012 03:18, Neil Hodgson wrote: Roy Smith: I'm wondering if it might be faster to start at the ends of the strings instead of at the beginning? If the strings are indeed equal, it's the same amount of work starting from either end. Most people write loops that go forwards. This

Re: Comparing strings from the back?

2012-09-04 Thread Neil Hodgson
Roy Smith: I'm wondering if it might be faster to start at the ends of the strings instead of at the beginning? If the strings are indeed equal, it's the same amount of work starting from either end. Most people write loops that go forwards. This leads to the processor designers prioritiz

Re: python docs search for 'print'

2012-09-04 Thread Ben Finney
Steven D'Aprano writes: > Gah! Brain meltdown! DDG does better on searches for Python terms with > fewer extraneous meanings, e.g. "python print" finds many links about > fashion, but https://duckduckgo.com/html/?q=python+tuple is all about > Python tuples :) Adding the “site:docs.python.org”

Re: Why derivated exception can not be pickled ?

2012-09-04 Thread Steven D'Aprano
On Tue, 04 Sep 2012 08:57:00 -0700, Mathieu Courtois wrote: > Here is my example : > > > import cPickle > > ParentClass = object # works > ParentClass = Exception # does not [...] > 1. With ParentClass=object, it works as expected. > > 2. With ParentClass=Exception, __getstate__/__setstat

Re: python docs search for 'print'

2012-09-04 Thread Steven D'Aprano
On Tue, 04 Sep 2012 18:28:31 +, Steven D'Aprano wrote: > https://www.google.com.au/search?q=python+print > http://duckduckgo.com/html/?q=python+print > > In this case, google hits the right Python documentation on the first > link. Duckduckgo doesn't do nearly so well, but it comes up with a

Re: How to tell people to ask questions the smart way

2012-09-04 Thread Dwight Hutto
Just to play advocatus diaboli, what if some seemingly simple questions are asked just to jump in and start talking python? In other words, they just wanna talk shop, no matter what it is. An OT(off topic) so to speak, and have an enlightened, and evolutionary(via brain structured acceptance of da

Re: Comparing strings from the back?

2012-09-04 Thread Oscar Benjamin
On 4 September 2012 22:59, Chris Angelico wrote: > On Wed, Sep 5, 2012 at 2:32 AM, Johannes Bauer > wrote: > > How do you arrive at that conclusion? When comparing two random strings, > > I just derived > > > > n = (256 / 255) * (1 - 256 ^ (-c)) > > > > where n is the average number of character

Re: How to tell people to ask questions the smart way

2012-09-04 Thread Chris Angelico
On Wed, Sep 5, 2012 at 9:28 AM, Mark Lawrence wrote: > On 05/09/2012 00:05, Ben Finney wrote: >> >>> Look there: >>> http://www.catb.org/esr/faqs/smart-questions.html#forum >> >> The “how to ask question the smart way” essay is not a blunt instrument >> for beating people over the head with, and i

Re: How to tell people to ask questions the smart way

2012-09-04 Thread Mark Lawrence
On 05/09/2012 00:05, Ben Finney wrote: Andreas Perstinger writes: On 04.09.2012 11:34, Paolo wrote: how do I know if a JTextField has the focus? thank to all Look there: http://www.catb.org/esr/faqs/smart-questions.html#forum That is an unhelpful response. You aren't giving anything to he

Re: The opener parameter of Python 3 open() built-in

2012-09-04 Thread Terry Reedy
On 9/4/2012 6:18 PM, Chris Angelico wrote: On Wed, Sep 5, 2012 at 5:16 AM, Terry Reedy wrote: io.open depends on a function the returns an open file descriptor. opener exposes that dependency so it can be replaced. I skimmed the bug report comments but didn't find an answer to this: Why not j

How to tell people to ask questions the smart way (was: focus on jtextfield)

2012-09-04 Thread Ben Finney
Andreas Perstinger writes: > On 04.09.2012 11:34, Paolo wrote: > > how do I know if a JTextField has the focus? > > thank to all > > Look there: > http://www.catb.org/esr/faqs/smart-questions.html#forum That is an unhelpful response. You aren't giving anything to help the original poster improve

Re: python docs search for 'print'

2012-09-04 Thread Terry Reedy
On 9/4/2012 6:32 PM, Terry Reedy wrote: On Tue, Sep 4, 2012 at 1:58 PM, David Hoese wrote: A friend made me aware of this: When a python beginner (2.x) quick searches for "print" on docs.python.org, the print function doesn't even come up in the top 20 results. In the Windows Help version o

Re: python docs search for 'print'

2012-09-04 Thread Terry Reedy
On Tue, Sep 4, 2012 at 1:58 PM, David Hoese wrote: A friend made me aware of this: When a python beginner (2.x) quick searches for "print" on docs.python.org, the print function doesn't even come up in the top 20 results. In the Windows Help version of the docs, enter print in the index tab

Re: C Python: Running Python code within function scope

2012-09-04 Thread Terry Reedy
On 9/4/2012 4:28 PM, channel727...@gmail.com wrote: The Python C API function PyEval_EvalCode let's you execute compiled Python code. I want to execute a block of Python code as if it were executing within the scope of a function, so that it has its own dictionary of local variables which don't a

Re: The opener parameter of Python 3 open() built-in

2012-09-04 Thread Chris Angelico
On Wed, Sep 5, 2012 at 5:16 AM, Terry Reedy wrote: > io.open depends on a function the returns an open file descriptor. opener > exposes that dependency so it can be replaced. I skimmed the bug report comments but didn't find an answer to this: Why not just monkey-patch? When a module function ca

Re: Comparing strings from the back?

2012-09-04 Thread Chris Angelico
On Wed, Sep 5, 2012 at 2:32 AM, Johannes Bauer wrote: > How do you arrive at that conclusion? When comparing two random strings, > I just derived > > n = (256 / 255) * (1 - 256 ^ (-c)) > > where n is the average number of character comparisons and c. The > rationale as follows: The first character

Re: python docs search for 'print'

2012-09-04 Thread Mark Lawrence
On 04/09/2012 19:38, William R. Wing (Bill Wing) wrote: On Sep 4, 2012, at 1:58 PM, David Hoese wrote: A friend made me aware of this: When a python beginner (2.x) quick searches for "print" on docs.python.org, the print function doesn't even come up in the top 20 results. The print statemen

Re: Import Problem on WIndows py3

2012-09-04 Thread Jimbo Jim
On Tuesday, September 4, 2012 1:45:55 PM UTC-7, Werner Thie wrote: > On 9/4/12 9:49 AM, jimmyli1528 wrote: > > > I have a main program and a 3rd party module. Trying to import colorama, > > where colorama is a folder with files in it, returns an ImportError: No > > module named colorama. How sho

Re: Import Problem on WIndows py3

2012-09-04 Thread Werner Thie
On 9/4/12 9:49 AM, jimmyli1...@gmail.com wrote: I have a main program and a 3rd party module. Trying to import colorama, where colorama is a folder with files in it, returns an ImportError: No module named colorama. How should I import folders? Do you have a (empty) __init__.py file present

C Python: Running Python code within function scope

2012-09-04 Thread channel727272
The Python C API function PyEval_EvalCode let's you execute compiled Python code. I want to execute a block of Python code as if it were executing within the scope of a function, so that it has its own dictionary of local variables which don't affect the global state. This seems easy enough to

Import Problem on WIndows py3

2012-09-04 Thread jimmyli1528
I have a main program and a 3rd party module. Trying to import colorama, where colorama is a folder with files in it, returns an ImportError: No module named colorama. How should I import folders? -- http://mail.python.org/mailman/listinfo/python-list

Re: The opener parameter of Python 3 open() built-in

2012-09-04 Thread Terry Reedy
On 9/4/2012 8:58 AM, Serhiy Storchaka wrote: On 04.09.12 04:13, Steven D'Aprano wrote: Why does the open builtin need this added complexity? Why not just call os.open directly? Or for more complex openers, just call the opener directly? What is the rationale for complicating open instead of tel

Re: python docs search for 'print'

2012-09-04 Thread Grant Edwards
On 2012-09-04, Joel Goldstick wrote: > On Tue, Sep 4, 2012 at 1:58 PM, David Hoese wrote: >> A friend made me aware of this: >> When a python beginner (2.x) quick searches for "print" on >> docs.python.org, the print function doesn't even come up in the top >> 20 results. > > That's pretty intere

Re: Comparing strings from the back?

2012-09-04 Thread Oscar Benjamin
On 4 September 2012 19:07, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Tue, 04 Sep 2012 18:32:57 +0200, Johannes Bauer wrote: > > > On 04.09.2012 04:17, Steven D'Aprano wrote: > > > >> On average, string equality needs to check half the characters in the > >> string. > > >

Re: focus on jtextfield

2012-09-04 Thread Andreas Perstinger
On 04.09.2012 11:34, Paolo wrote: how do I know if a JTextField has the focus? thank to all Look there: http://www.catb.org/esr/faqs/smart-questions.html#forum Bye, Andreas -- http://mail.python.org/mailman/listinfo/python-list

Re: python docs search for 'print'

2012-09-04 Thread Steven D'Aprano
On Tue, 04 Sep 2012 20:27:38 +0200, Thomas 'PointedEars' Lahn wrote: > ¹ The other mess they created (or allowed to be created) is this mashup >of newsgroup and mailing list, neither of which works properly, In what way do they not work properly? >because >the underlying protocols

Re: python docs search for 'print'

2012-09-04 Thread William R. Wing (Bill Wing)
On Sep 4, 2012, at 1:58 PM, David Hoese wrote: > A friend made me aware of this: > When a python beginner (2.x) quick searches for "print" on docs.python.org, > the print function doesn't even come up in the top 20 results. The print > statement isn't even listed as far as I can tell. Is ther

Re: python docs search for 'print'

2012-09-04 Thread Steven D'Aprano
On Tue, 04 Sep 2012 13:58:43 -0400, David Hoese wrote: > A friend made me aware of this: > When a python beginner (2.x) quick searches for "print" on > docs.python.org, the print function doesn't even come up in the top 20 > results. The print statement isn't even listed as far as I can tell. Is

Re: python docs search for 'print'

2012-09-04 Thread Thomas 'PointedEars' Lahn
David Hoese wrote: > A friend made me aware of this: > When a python beginner (2.x) quick searches for "print" on > docs.python.org, the print function doesn't even come up in the top 20 > results. The print statement isn't even listed as far as I can tell. > Is there something that can be done a

Re: python docs search for 'print'

2012-09-04 Thread Joel Goldstick
On Tue, Sep 4, 2012 at 1:58 PM, David Hoese wrote: > A friend made me aware of this: > When a python beginner (2.x) quick searches for "print" on docs.python.org, > the print function doesn't even come up in the top 20 results. > -Dave > -- > http://mail.python.org/mailman/listinfo/python-list T

Re: sockets,threads and interupts

2012-09-04 Thread Grant Edwards
On 2012-09-04, MRAB wrote: > On 04/09/2012 16:26, loial wrote: >> I have threaded python script that uses sockets to monitor network >> ports. >> >> I want to ensure that the socket is closed cleanly in all >> circumstances. This includes if the script is killed or interupted in >> some other way.

Re: Comparing strings from the back?

2012-09-04 Thread Steven D'Aprano
On Tue, 04 Sep 2012 18:32:57 +0200, Johannes Bauer wrote: > On 04.09.2012 04:17, Steven D'Aprano wrote: > >> On average, string equality needs to check half the characters in the >> string. > > How do you arrive at that conclusion? Take two non-empty strings of the same length, N. If the strin

python docs search for 'print'

2012-09-04 Thread David Hoese
A friend made me aware of this: When a python beginner (2.x) quick searches for "print" on docs.python.org, the print function doesn't even come up in the top 20 results. The print statement isn't even listed as far as I can tell. Is there something that can be done about this to make it easi

Re: Error 32 - Broken Pipe . Please Help!!

2012-09-04 Thread Emile van Sebille
On 9/4/2012 10:08 AM Sreenath k said... Error: Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner self.run() File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/monitor.py", line

Re: Error 32 - Broken Pipe . Please Help!!

2012-09-04 Thread Laszlo Nagy
2012.09.04. 19:08 keltezéssel, Sreenath k írta: Error: Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner self.run() File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/monitor.py

Error 32 - Broken Pipe . Please Help!!

2012-09-04 Thread Sreenath k
Error: Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner self.run() File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/monitor.py", line 575, in run already_pickled=True) File

Re: sockets,threads and interupts

2012-09-04 Thread MRAB
On 04/09/2012 16:26, loial wrote: I have threaded python script that uses sockets to monitor network ports. I want to ensure that the socket is closed cleanly in all circumstances. This includes if the script is killed or interupted in some other way. As I understand it signal only works in the

Re: Comparing strings from the back?

2012-09-04 Thread Johannes Bauer
On 04.09.2012 04:17, Steven D'Aprano wrote: > On average, string equality needs to check half the characters in the > string. How do you arrive at that conclusion? When comparing two random strings, I just derived n = (256 / 255) * (1 - 256 ^ (-c)) where n is the average number of character co

Why derivated exception can not be pickled ?

2012-09-04 Thread Mathieu Courtois
Here is my example : import cPickle ParentClass = object # works ParentClass = Exception # does not class MyError(ParentClass): def __init__(self, arg): self.arg = arg def __getstate__(self): print '#DBG pass in getstate' odict = self.__dict__.copy()

sockets,threads and interupts

2012-09-04 Thread loial
I have threaded python script that uses sockets to monitor network ports. I want to ensure that the socket is closed cleanly in all circumstances. This includes if the script is killed or interupted in some other way. As I understand it signal only works in the main thread, so how can I trap in

CFP: Computing, Networking and Digital Technologies

2012-09-04 Thread sdiwc conferences
We invite participation and submissions to The International Conference on Computing, Networking and Digital Technologies (ICCNDT 2012) that will be held at Gulf University, Sanad, Bahrain from Nov. 11-13, 2012. More details can be found at the conference's official web site, visit http://sdiwc.net

Re: simple client data base

2012-09-04 Thread Wolfgang Keller
> Personally, I wouldn't bother with SQLAlchemy for this. I'd just use > Python as the front end, PostgreSQL for the database, and psycopg2 > for the interface. Then you have to implement the entire logic, "event binding" etc. yourself. If you use e.g. Pypapi (the latest version), implementing

Re: calling loaded DLL function expecting POINT * argument

2012-09-04 Thread Tim Williams
On Tuesday, September 4, 2012 8:16:33 AM UTC-4, Tim Williams wrote: > On Sunday, August 26, 2012 9:23:49 PM UTC-4, Tim Roberts wrote: > > > Tim Williams wrote: > > > > > > > > > > > > >Hello all, > > > > > > > > > > > > > >I'm trying to use the ctypes module to call functions in a DL

Re: The opener parameter of Python 3 open() built-in

2012-09-04 Thread Serhiy Storchaka
On 03.09.12 15:32, Marco wrote: Does anyone have an example of utilisation? http://bugs.python.org/issue13424 -- http://mail.python.org/mailman/listinfo/python-list

Re: The opener parameter of Python 3 open() built-in

2012-09-04 Thread Serhiy Storchaka
On 04.09.12 04:13, Steven D'Aprano wrote: Why does the open builtin need this added complexity? Why not just call os.open directly? Or for more complex openers, just call the opener directly? What is the rationale for complicating open instead of telling people to just call their opener directly

Re: calling loaded DLL function expecting POINT * argument

2012-09-04 Thread Tim Williams
On Sunday, August 26, 2012 9:23:49 PM UTC-4, Tim Roberts wrote: > Tim Williams wrote: > > > > >Hello all, > > > > > >I'm trying to use the ctypes module to call functions in a DLL. I've > > >figured out how to modify my path so the library is found, and I can > > >call LoadLibrary on it, b

Re: Comparing strings from the back?

2012-09-04 Thread Alain Ketterlin
Roy Smith writes: > There's been a bunch of threads lately about string implementations, and > that got me thinking (which is often a dangerous thing). > > Let's assume you're testing two strings for equality. You've already > done the obvious quick tests (i.e they're the same length), and you

focus on jtextfield

2012-09-04 Thread Paolo
how do I know if a JTextField has the focus? thank to all -- http://mail.python.org/mailman/listinfo/python-list

Re: tornado.web ioloop add_timeout eats CPU

2012-09-04 Thread Paul Rubin
Laszlo Nagy writes: > but a threaded server cannot handle 100+ simultaneous (long running) > requests, because that would require 100+ threads to be running. On a reasonable server these days, 100 threads seems to be no big deal. I've run several times that many. I think things get ragged at a f

Re: Comparing strings from the back?

2012-09-04 Thread Mark Lawrence
On 04/09/2012 02:54, Roy Smith wrote: There's been a bunch of threads lately about string implementations, and that got me thinking (which is often a dangerous thing). Let's assume you're testing two strings for equality. You've already done the obvious quick tests (i.e they're the same length)

Re: Comparing strings from the back?

2012-09-04 Thread Mark Lawrence
On 04/09/2012 05:56, Dan Sommers wrote: That said, if I really wanted bloodshed, I would propose = for the third string-equality operator! ;-) Dan Dan "agent provocateur" Sommers? :) -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list

Re: tornado.web ioloop add_timeout eats CPU

2012-09-04 Thread Laszlo Nagy
What's wrong is the 1,135,775 calls to "method 'poll' of 'select.epoll' objects". I was affraid you are going to say that. :-) With five browsers waiting for messages over 845 seconds, that works out to each waiting browser inducing 269 epolls per second. Almost equally important is what the