Re: How come StopIteration.__base__ is not BaseException?

2013-08-26 Thread Marco Buttu
On 08/26/2013 10:10 PM, random...@fastmail.us wrote: The reason KeyboardInterrupt and SystemExit inherit from BaseException is because you often want them to escape (allowing the program to quit) from code that would otherwise catch them (by catching Exception). On the contrary, StopIteration is

Re: How come StopIteration.__base__ is not BaseException?

2013-08-26 Thread Marco Buttu
On 08/27/2013 08:17 AM, Marco Buttu wrote: But if I want to catch it specifically (except BaseIteration), Sorry, except StopIteration... -- Marco Buttu -- http://mail.python.org/mailman/listinfo/python-list

Re: Missing something on exception handling in Python 3

2013-08-26 Thread Skip Montanaro
I found this question/answer on Stack Overflow: http://stackoverflow.com/questions/15123137 but after fiddling around with it, I can't find a solution that works for Python 3.2 and 3.3, let alone 2.x. In 3.2, exceptions have both __cause__ and __context__ attributes. I tried setting both to Non

Phonon error: libv4l2: error getting pixformat: Invalid argument

2013-08-26 Thread tausciam
Here is my code. I'm just trying to play an mp3 that I've clicked in a PyQT listwidget: @pyqtSlot() def item_clicked(self): row = self.listWidget.currentRow() song = musiclist[row] QCoreApplication.setApplicationName("Phonon") output = Phonon.AudioOutput(Ph

Re: Missing something on exception handling in Python 3

2013-08-26 Thread Ethan Furman
On 08/26/2013 07:49 PM, Skip Montanaro wrote: Do this: raise LockFailed("Failed to create %s" % self.path) from None Thanks. Is there some construct which will work in 2.x and 3.x? Something like this (untested): exc = None try: write_pid_to_lockfile(somefile) excep

Re: TypeError: 'int' object is not callable

2013-08-26 Thread Krishnan Shankar
Hi, The problem is in the second line. a = time.daylight() The daylight is not a method in time module. It is clear here, http://docs.python.org/2/library/time.html Since it is not a method we cannot call it. It is just a integer variable . It returns zero if DST timezone is not defined and ret

TypeError: 'int' object is not callable

2013-08-26 Thread autobotprime . 17
dear friends when i try to execute following lines import time a = time.daylight() print(a) result is TypeError: 'int' object is not callable why is this error and how can i solve this problem? -- http://mail.python.org/mailman/listinfo/python-list

Re: Missing something on exception handling in Python 3

2013-08-26 Thread Skip Montanaro
> Do this: > > raise LockFailed("Failed to create %s" % self.path) from None Thanks. Is there some construct which will work in 2.x and 3.x? Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Missing something on exception handling in Python 3

2013-08-26 Thread MRAB
On 27/08/2013 02:48, Skip Montanaro wrote: I have code in the pylockfile package that looks roughly like this (apologies for the indentation - I'm growing to dislike Gmail for typing code fragments): try: write_pid_to_lockfile(somefile) except OSError as exc: if conditions_i_can_handle

Missing something on exception handling in Python 3

2013-08-26 Thread Skip Montanaro
I have code in the pylockfile package that looks roughly like this (apologies for the indentation - I'm growing to dislike Gmail for typing code fragments): try: write_pid_to_lockfile(somefile) except OSError as exc: if conditions_i_can_handle: do_other_stuff... else: ra

Re: Imaplib & Gmail - cannot move from inbox to custom folder (message remains in both)

2013-08-26 Thread rob
On Monday, August 26, 2013 5:56:09 PM UTC-6, MRAB wrote: > On 27/08/2013 00:34, r...@attoenterprises.com wrote: > > > I am using Imaplib and connecting to a Gmail account. I am issuing > > commands to copy the email to a custom folder then issuing delete. After > > expunge message still remain

Re: Imaplib & Gmail - cannot move from inbox to custom folder (message remains in both)

2013-08-26 Thread MRAB
On 27/08/2013 00:34, r...@attoenterprises.com wrote: I am using Imaplib and connecting to a Gmail account. I am issuing commands to copy the email to a custom folder then issuing delete. After expunge message still remains in inbox and customer folder. # COPY EMAIL TO FOLDER

Imaplib & Gmail - cannot move from inbox to custom folder (message remains in both)

2013-08-26 Thread rob
I am using Imaplib and connecting to a Gmail account. I am issuing commands to copy the email to a custom folder then issuing delete. After expunge message still remains in inbox and customer folder. # COPY EMAIL TO FOLDER copyStatus = m.copy(emailid, 'CIRIMPORTED') pri

Re: Checking homogeneity of Array using List in Python

2013-08-26 Thread Joshua Landau
On 26 August 2013 14:49, Neil Cerutti wrote: > On 2013-08-25, sahil301...@gmail.com wrote: >> >> eg. my input is ['1', ' ', 'asdasd231231', '1213asasd', '43242'] >> I want it to be interpreted as: >> [1, [None], [None], [None], 43242] >> >> NOTE: NO INBUILT FUNCTION BE USED. > > Impossible. I thi

Re: How to check client shutdown?

2013-08-26 Thread Grant Edwards
On 2013-08-26, Paul Pittlerson wrote: > I'm currently learning about the socket module. My question is how > can I detect if a connection is closed from the other side, recv() will return an empty value of ''. send() will eventually throw an exception. [You may be able to call send() once or t

Re: How to check client shutdown?

2013-08-26 Thread MRAB
On 26/08/2013 20:45, Paul Pittlerson wrote: I'm currently learning about the socket module. My question is how can I detect if a connection is closed from the other side, for example a KeyboardInterrupt as I frequently use. My code below: [snip] When reading from a socket, it'll return as much

Re: Which DLL did fail to load

2013-08-26 Thread Miki Tebeka
> Wouldn't it > better to add a feature to Python to write the name of DLL which load > has been failed? If you start Python with the -v (verbose) flag, you can see all the calls to dlopen. -- http://mail.python.org/mailman/listinfo/python-list

Re: How come StopIteration.__base__ is not BaseException?

2013-08-26 Thread random832
On Mon, Aug 26, 2013, at 15:37, Marco Buttu wrote: > Since StopIteration is not an error, how come does it inherit directly > from Exception and not from BaseException? The reason KeyboardInterrupt and SystemExit inherit from BaseException is because you often want them to escape (allowing the pr

Re: How to check client shutdown?

2013-08-26 Thread Chris Angelico
On Tue, Aug 27, 2013 at 5:45 AM, Paul Pittlerson wrote: > I'm currently learning about the socket module. My question is how can I > detect if a connection is closed from the other side, for example a > KeyboardInterrupt as I frequently use. My code below: > Once the remote end has terminated (

How to check client shutdown?

2013-08-26 Thread Paul Pittlerson
I'm currently learning about the socket module. My question is how can I detect if a connection is closed from the other side, for example a KeyboardInterrupt as I frequently use. My code below: ## #server script: class client(threading.Th

How come StopIteration.__base__ is not BaseException?

2013-08-26 Thread Marco Buttu
Since StopIteration is not an error, how come does it inherit directly from Exception and not from BaseException? Thanks in advance, Marco -- Marco -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting request's source site

2013-08-26 Thread random832
On Mon, Aug 26, 2013, at 11:03, Guy Tamir wrote: > Thanks for reply, > In what cases will i have this header? In practice, you'll usually have it, except in cases where the user has bookmarked your site, typed/pasted the URL directly, had it opened by an external program, or taken action to block

Re: optparse question (python 2.6)

2013-08-26 Thread Peter Otten
Andy Kannberg wrote: > Hi python-guru's, > > I am new to Python, coming from a long history of Unix/linux shell > programming. > I am creating a Python script (In Python 2.6) which should be able to > read command line options and arguments. > So far, I figured out how to do that with optparse.

optparse question (python 2.6)

2013-08-26 Thread Andy Kannberg
Hi python-guru's, I am new to Python, coming from a long history of Unix/linux shell programming. I am creating a Python script (In Python 2.6) which should be able to read command line options and arguments. So far, I figured out how to do that with optparse. I can add options (and arguments ) .

Re: Python Global variable

2013-08-26 Thread MRAB
On 26/08/2013 10:54, chandan kumar wrote: Hi all, Please see the below code,in which i'm verifying the global value in python. CHK=10 def test1(): print "Value of CHK in test1",CHK def test2(): CHK=40 print "Value of CHK in test2",CHK test1() def test3(): global CH

Re: Python Global variable

2013-08-26 Thread Joel Goldstick
On Mon, Aug 26, 2013 at 5:54 AM, chandan kumar wrote: > Hi all, > > Please see the below code,in which i'm verifying the global value in python. > > CHK=10 > > def test1(): > print "Value of CHK in test1",CHK > > def test2(): > CHK=40 > print "Value of CHK in test2",CHK > test1()

Python Global variable

2013-08-26 Thread chandan kumar
Hi all, Please see the below code,in which i'm verifying the global value in python. CHK=10 def test1(): print "Value of CHK in test1",CHK def test2(): CHK=40 print "Value of CHK in test2",CHK test1() def test3(): global CHK test2() test3() When i ran above code ,I

Re: python eval function

2013-08-26 Thread Mohsen Pahlevanzadeh
On Mon, 2013-08-26 at 00:55 +, Steven D'Aprano wrote: > On Sun, 25 Aug 2013 23:48:34 +0430, Mohsen Pahlevanzadeh wrote: > > > Dear all, > > > > eval doesn't run my code at the following link: > > http://stackoverflow.com/questions/18432198/eval-function-doesnt-work- > in-python > > > Are yo

Re: Getting request's source site

2013-08-26 Thread Joel Goldstick
On Mon, Aug 26, 2013 at 11:03 AM, Guy Tamir wrote: > On Monday, August 26, 2013 5:25:49 PM UTC+3, Steven D'Aprano wrote: >> On Mon, 26 Aug 2013 06:10:41 -0700, Guy Tamir wrote: >> >> >> >> > Hi all, >> >> > >> >> > I was wondering how i can get the source from which the request came >> >> > from.

Re: Getting request's source site

2013-08-26 Thread Guy Tamir
On Monday, August 26, 2013 5:25:49 PM UTC+3, Steven D'Aprano wrote: > On Mon, 26 Aug 2013 06:10:41 -0700, Guy Tamir wrote: > > > > > Hi all, > > > > > > I was wondering how i can get the source from which the request came > > > from. If a user posted a link that directs to my server on faceb

Re: Getting request's source site

2013-08-26 Thread Steven D'Aprano
On Mon, 26 Aug 2013 06:10:41 -0700, Guy Tamir wrote: > Hi all, > > I was wondering how i can get the source from which the request came > from. If a user posted a link that directs to my server on facebook i'd > like to know that a specific click was from facebook or twitter etc.. That would be

Re: Checking homogeneity of Array using List in Python

2013-08-26 Thread Neil Cerutti
On 2013-08-25, sahil301...@gmail.com wrote: > I am unable to check homogeneity of Array. > I have take Array type Int to be default for my code. > > Instead of getting Error on NON-INT Values. > I want to take input as string. > Then check if all input is in (0-9) form, I typecast it into int and

Getting request's source site

2013-08-26 Thread Guy Tamir
Hi all, I was wondering how i can get the source from which the request came from. If a user posted a link that directs to my server on facebook i'd like to know that a specific click was from facebook or twitter etc.. Thanks -- http://mail.python.org/mailman/listinfo/python-list

Peasy: an easy but powerful parser

2013-08-26 Thread Simeon Chaos
I've released Peasy, which is an easy but powerful parser. Peasy brings a new method to write the parser. with Peasy, you write the parser by hand, just like to write any other kind of program. Do not be confused by "by hand", with the method brought by Peasy, it's easier and more powerful

Resetting state of http.client/httplib HTTPSConnection objects

2013-08-26 Thread Chris Down
This is a crosspost from python-tutor upon suggestion. I am experiencing intermittent issues where an exception will be raised when calling getresponse(), which makes the entire connection stuck in Request-sent state. Is it possible to reset to idle state somehow without reinstantiating the HTTPSC

Re: About executable

2013-08-26 Thread Fábio Santos
On 25 Aug 2013 21:47, "Luis José Novoa" wrote: > > Hi All. I am trying to create an executable file containing an optimization code using the pyomo package for optimization modeling along with ither packages like Numpy. When using py2exe to perform the task it generates the executable file, but wh