Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-09 Thread Jon Ribbens via Python-list
On 2024-09-08, Greg Ewing wrote: > On 8/09/24 9:20 am, Karsten Hilbert wrote: >> try: >> do something >> except: >> log something >> finally: >> .commit() >> >> cadence is fairly Pythoni

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-09 Thread Karsten Hilbert via Python-list
Am Mon, Sep 09, 2024 at 01:48:32PM +1200 schrieb Greg Ewing via Python-list: > That code doesn't inspire much confidence in me. It's far too > convoluted with too much micro-management of exceptions. It is catching two exceptions, re-raising both of them, except for re-raising one of them as anot

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-09 Thread Karsten Hilbert via Python-list
Am Mon, Sep 09, 2024 at 01:48:32PM +1200 schrieb Greg Ewing via Python-list: > That code doesn't inspire much confidence in me. It's far too > convoluted with too much micro-management of exceptions. > > I would much prefer to have just *one* place where exceptions are > caught and logged. I am o

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-08 Thread Greg Ewing via Python-list
On 9/09/24 2:13 am, Karsten Hilbert wrote: For what it's worth here's the current state of code: That code doesn't inspire much confidence in me. It's far too convoluted with too much micro-management of exceptions. I would much prefer to have just *one* place where exceptions are caught and l

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-08 Thread Greg Ewing via Python-list
On 8/09/24 11:03 pm, Jon Ribbens wrote: On 2024-09-08, Greg Ewing wrote: try: do something .commit() except: log something .rollback() What if there's an exception in your exception handler? I'd put the rollback in the 'finally' handler, s

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-08 Thread Karsten Hilbert via Python-list
Am Sun, Sep 08, 2024 at 02:58:03PM +0100 schrieb Rob Cliffe via Python-list: > >Ugly: > > > > try: > > do something > > except: > > log something > > finally: > > try: > >

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-08 Thread Rob Cliffe via Python-list
() call in case I am overlooking benefits and drawbacks of choices. The try: do something except: log something finally: .commit() cadence is fairly Pythonic and elegant in that it ensures the the .commit() will always be

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-08 Thread Karsten Hilbert via Python-list
Am Sun, Sep 08, 2024 at 12:48:50PM +1200 schrieb Greg Ewing via Python-list: > On 8/09/24 9:20 am, Karsten Hilbert wrote: > > try: > > do something > > except: > > log something > > finally: > > .commit(

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-08 Thread Karsten Hilbert via Python-list
Am Sun, Sep 08, 2024 at 12:48:50PM +1200 schrieb Greg Ewing via Python-list: > On 8/09/24 9:20 am, Karsten Hilbert wrote: > > try: > > do something > > except: > > log something > > finally: > > .commit(

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-07 Thread Greg Ewing via Python-list
On 8/09/24 9:20 am, Karsten Hilbert wrote: try: do something except: log something finally: .commit() cadence is fairly Pythonic and elegant in that it ensures the the .commit() will always be reached regardless of

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-07 Thread Karsten Hilbert via Python-list
est place that .commit() call in case I am overlooking benefits and drawbacks of choices. The try: do something except: log something finally: .commit() cadence is fairly Pythonic and elegant in that it ensures the the .commit()

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-07 Thread Karsten Hilbert via Python-list
Am Sat, Sep 07, 2024 at 01:03:34PM -0700 schrieb Adrian Klaver: > In the case you show you are doing commit() before the close() so any errors > in the > transactions will show up then. My first thought would be to wrap the > commit() in a > try/except and deal with error the

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-07 Thread Karsten Hilbert via Python-list
ncurrently or not -- are set to SERIALIZABLE. They are not psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT, for that matter. > > curs = conn.cursor() > > try: > > curs.execute(SOME_SQL) > > except PSYCOPG2-Exception: > > some

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-07 Thread Rob Cliffe via Python-list
On 07/09/2024 16:48, Karsten Hilbert via Python-list wrote: Dear all, unto now I had been thinking this is a wise idiom (in code that needs not care whether it fails to do what it tries to do^1): conn = psycopg2.connection(...) curs = conn.cursor() try

psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-07 Thread Karsten Hilbert via Python-list
Dear all, unto now I had been thinking this is a wise idiom (in code that needs not care whether it fails to do what it tries to do^1): conn = psycopg2.connection(...) curs = conn.cursor() try: curs.execute(SOME_SQL) except PSYCOPG2-Exception

Is the bug reported to python Recently i upgraded my python version and its directory But when i try to download pyqt5 it gives out a holy error Do i have to install py 3.9 again pls help me take a lo

2021-10-17 Thread Umme Salma
-- https://mail.python.org/mailman/listinfo/python-list

Re: try to install Python3.9.2 / setup failed

2021-03-02 Thread Mats Wichmann
n external actor, like an antivirus program). Often these kinds of problems don't have a lot to do with the thing being installed, and do have a lot to do with other conditions. In my experience, this means you need to run some of the fixit tools to make sure your system doesn't ha

Re: try to install Python3.9.2 / setup failed

2021-03-01 Thread manfred . schmidt
Hello Python Team, i tried to install SW above; the installation stopped with the message "one or more issues caused the setup to fail. Please the issues and then retry 0x80070642 installation stopped by user" What must i do go get the SW installed? Windows 10, file "python-3.9.2-amd64.exe" Be

Re: try/except in loop

2020-11-27 Thread Cameron Simpson
en_lock: token = self._auth_token if (token and token.timestamp + FM_TOKEN_LIFESPAN - FM_TOKEN_LIFESPAN_SKEW > time.time()): break try: token = self._get_new_auth_token()

Re: try/except in loop

2020-11-27 Thread Jason Friedman
nt.folder('0').get_items(): >> logger.debug("Using existing access token.") >> return access_token >> >> # So I use try/except >> try: >> for _ in client.folder('0').get_items(): >> logger.debug("Using exist

Re: try/except in loop

2020-11-27 Thread Bob Gailer
or _ in client.folder('0').get_items(): > > logger.debug("Using existing access token.") > > return access_token > > > # So I use try/except > > try: > > for _ in client.folder('0').get_items(): > > logger.debug("Using exi

try/except in loop

2020-11-27 Thread Jason Friedman
have an expired access token. # This next line does not throw an error: client.folder('0').get_items() # But iteration does (maybe this is a lazy fetch?) for _ in client.folder('0').get_items(): logger.debug("Using existing access token.") return access_token

Re: try..except or type() or isinstance()?

2020-08-16 Thread Alexa Oña
n-list@python.org Asunto: Re: try..except or type() or isinstance()? On Sun, 16 Aug 2020 09:40:12 +0200 Manfred Lotz wrote: > On Sat, 15 Aug 2020 12:20:48 -0400 > Dennis Lee Bieber wrote: > > > On Sat, 15 Aug 2020 15:31:56 +0200, Manfred Lotz > > declaimed the following: &

Re: try..except or type() or isinstance()?

2020-08-16 Thread Manfred Lotz
On Sun, 16 Aug 2020 09:40:12 +0200 Manfred Lotz wrote: > On Sat, 15 Aug 2020 12:20:48 -0400 > Dennis Lee Bieber wrote: > > > On Sat, 15 Aug 2020 15:31:56 +0200, Manfred Lotz > > declaimed the following: > > > > >On Sat, 15 Aug 2020 11:47:03 +0200 > > >Sibylle Koczian wrote: > > > > >

Re: try..except or type() or isinstance()?

2020-08-16 Thread Manfred Lotz
On 15 Aug 2020 14:49:48 GMT r...@zedat.fu-berlin.de (Stefan Ram) wrote: > Manfred Lotz writes: > >Here a minimal example > > main.py > > source=""" > sehr gut > 1 > """[ 1: -1 ].split( "\n" ) > > class grades: > names =[ "sehr gut" ] > @staticmethod > def is_numeric( text ): >

Re: try..except or type() or isinstance()?

2020-08-16 Thread Manfred Lotz
On Sat, 15 Aug 2020 12:20:48 -0400 Dennis Lee Bieber wrote: > On Sat, 15 Aug 2020 15:31:56 +0200, Manfred Lotz > declaimed the following: > > >On Sat, 15 Aug 2020 11:47:03 +0200 > >Sibylle Koczian wrote: > > > > >> if the value comes from a file, isn't it a > >> string in any case? A string

Re: try..except or type() or isinstance()?

2020-08-15 Thread Manfred Lotz
On Sat, 15 Aug 2020 11:47:03 +0200 Sibylle Koczian wrote: > Am 15.08.2020 um 10:14 schrieb Manfred Lotz: > > Hi Chris, > > Thanks a lot for you advice. > > > > On Sat, 15 Aug 2020 16:15:29 +1000 > > Chris Angelico wrote: > > > >> On Sat, Aug 15, 2020 at 3:36 PM Manfred Lotz > >> wrote: > >>

Re: try..except or type() or isinstance()?

2020-08-15 Thread Sibylle Koczian
Am 15.08.2020 um 10:14 schrieb Manfred Lotz: Hi Chris, Thanks a lot for you advice. On Sat, 15 Aug 2020 16:15:29 +1000 Chris Angelico wrote: On Sat, Aug 15, 2020 at 3:36 PM Manfred Lotz wrote: I have an object which I could initialize providind an int or a str. ... For my use case I do

Re: try..except or type() or isinstance()?

2020-08-15 Thread Manfred Lotz
. > >> > >> I am not sure which of the following is best to use > >> - try/except > >> - if type(int)... > >> - if isinstance(v, int) > >> > >> Here a minimal example > >> > >> def get_id(fromname): > >&g

Re: try..except or type() or isinstance()?

2020-08-15 Thread Manfred Lotz
f the following is best to use > > - try/except > > - if type(int)... > > - if isinstance(v, int) > > > > Here a minimal example > > > > def get_id(fromname): > > # do something with `fromname` > > return 0 > > > > def get_name

Re: try..except or type() or isinstance()?

2020-08-14 Thread Peter Otten
Chris Angelico wrote: > On Sat, Aug 15, 2020 at 3:36 PM Manfred Lotz wrote: >> >> I have an object which I could initialize providind an int or a str. >> >> I am not sure which of the following is best to use >> - try/except >> - if type(int)... >>

Re: try..except or type() or isinstance()?

2020-08-14 Thread Chris Angelico
On Sat, Aug 15, 2020 at 3:36 PM Manfred Lotz wrote: > > I have an object which I could initialize providind an int or a str. > > I am not sure which of the following is best to use > - try/except > - if type(int)... > - if isinstance(v, int) > > Here a minimal exam

try..except or type() or isinstance()?

2020-08-14 Thread Manfred Lotz
I have an object which I could initialize providind an int or a str. I am not sure which of the following is best to use - try/except - if type(int)... - if isinstance(v, int) Here a minimal example def get_id(fromname): # do something with `fromname` return 0 def get_name(fromid

Re: "OSError: [Errno 9] Bad file descriptor" When I try to Install the library in conda prompt

2020-07-21 Thread dn via Python-list
On 7/22/20 4:46 PM, Mathiyazhagan S wrote: Dear Sir/Madam, I'm new to the python program. I'm trying to install the "numby" or anything to add into the library by using the windows command prompt I'm getting some error please find the attachment. So please help me to resolve this issue.

"OSError: [Errno 9] Bad file descriptor" When I try to Install the library in conda prompt

2020-07-21 Thread Mathiyazhagan S
Dear Sir/Madam, I'm new to the python program. I'm trying to install the "numby" or anything to add into the library by using the windows command prompt I'm getting some error please find the attachment. So please help me to resolve this issue. Thank you -- https://mail.python.org/mailman/

Re: python 3.7 - I try to close the thread without closing the GUI is it possible?

2018-09-15 Thread Michael Torrie
On 09/15/2018 01:23 AM, Albert-Jan Roskam wrote: > > I try to close the thread without closing the GUI is it possible? > > > Qthread seems to be worth investigating: > https://medium.com/@webmamoffice/getting-started-gui-s-with-python-pyqt-qthread-class-1b796203c18c Or bette

Re: python 3.7 - I try to close the thread without closing the GUI is it possible?

2018-09-15 Thread Michael Torrie
Here's a small PyQt example of using Qt's asynchronous facilities: http://zetcode.com/pyqt/qnetworkaccessmanager/ That should get the original poster started. -- https://mail.python.org/mailman/listinfo/python-list

Re: python 3.7 - I try to close the thread without closing the GUI is it possible?

2018-09-15 Thread Albert-Jan Roskam
> I try to close the thread without closing the GUI is it possible? Qthread seems to be worth investigating: https://medium.com/@webmamoffice/getting-started-gui-s-with-python-pyqt-qthread-class-1b796203c18c -- https://mail.python.org/mailman/listinfo/python-list

Re: python 3.7 - I try to close the thread without closing the GUI is it possible?

2018-09-14 Thread dieter
alon.naj...@gmail.com writes: > python 3.7 - I try to close the thread without closing the GUI is it > possible? I assume that with "close a thread" you mean "terminate a thread". It is difficult to terminate a thread from the outside, because on many platforms, t

python 3.7 - I try to close the thread without closing the GUI is it possible?

2018-09-14 Thread alon . najman
python 3.7 - I try to close the thread without closing the GUI is it possible? here is my code, sorry I'm am new with python and generally with code XD . thanks all # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'AlonStockMarket.ui' # # Creat

Re: (new try) - Running a second wsgi script from within the first wsgi script

2018-09-10 Thread Alister via Python-list
http://superhost.gr/' + page ) > pdata = pdata.text + counter page = the location of another wsgi app. > > The error i'am getting when for i.e i try to load > http://superhost.gr/clientele > > mod_wsgi (pid=7152): Exception occurred processing WSGI script > '

I try to run selenium with firefox on RasberyPi3 ARM7 , any idea if it possible?

2018-09-09 Thread alon . najman
I try to run selenium with firefox on RasberyPi3 ARM7 , any idea if it possible? what should I do? I don't mind to change to another driver -- https://mail.python.org/mailman/listinfo/python-list

Re: I try to edit and find data from a text file with python 2.7 (data from stock market)

2018-09-07 Thread Peter Otten
alon.naj...@gmail.com wrote: > hi, > > I try to edit a text file with python 2.7: > > * AAPL * > Date: September 07 2018 > Time: 14:10:52 > Price: ,068,407 > Ask: None > High: None > Low: None > Previous Close: ,068,407 > Volume: $ 227.35 / $ 22

I try to edit and find data from a text file with python 2.7 (data from stock market)

2018-09-07 Thread alon . najman
hi, I try to edit a text file with python 2.7: * AAPL * Date: September 07 2018 Time: 14:10:52 Price: ,068,407 Ask: None High: None Low: None Previous Close: ,068,407 Volume: $ 227.35 / $ 221.30 Market Cap: 20.23 but when I write it to a file I get: {'previous_close':

Re: Python shuts down when I try to run a module

2018-07-23 Thread Michael Torrie
On 07/23/2018 01:00 AM, Lyra wrote: > Hello, > I’ve just started to learn Python coding, and downloaded version 3.7.0 from > the website.  I’ve written 5 or 6 small programs and saved them, but whenever > I try to run them, Python doesn’t work right.  The user answers the first &g

Re: Python shuts down when I try to run a module

2018-07-23 Thread Neil Cerutti
On 2018-07-23, Calvin Spealman wrote: > This is an unfortunate property of running command line > programs on Windows. If you run the script directly (like by > double clicking on it?) the console window will close when the > program is done, so you can't see the final output. > > To get around th

Re: Python shuts down when I try to run a module

2018-07-23 Thread Calvin Spealman
n 5 or 6 small programs and saved them, but > whenever I try to run them, Python doesn’t work right. The user answers > the first question and presses ENTER, but then the Python window just > closes, disappears, and shuts down. My programs are all written correctly, > and work just like they’

Python shuts down when I try to run a module

2018-07-23 Thread Lyra
Hello, I’ve just started to learn Python coding, and downloaded version 3.7.0 from the website.  I’ve written 5 or 6 small programs and saved them, but whenever I try to run them, Python doesn’t work right.  The user answers the first question and presses ENTER, but then the Python window just

Re: try except inside a with open

2018-07-21 Thread Cameron Simpson
Please try to preserve the attribution lines of previous authors. The inner quote below comes from Steven D'Aprano. On 21Jul2018 15:13, Ganesh Pal wrote: (1) Since this function always returns True (if it returns at all), what is the point? There's no point checking the return res

Re: try except inside a with open

2018-07-21 Thread Ganesh Pal
turns None. But would it be better if for the function i.e modify_various_line(f) to atleast catch or handle exceptions and log it for debugging purpose Example: def modify_various_line(f): """ Try modifiying various line """ try: f.write('

Re: try except inside a with open

2018-07-20 Thread Steven D'Aprano
On Fri, 20 Jul 2018 23:29:21 +0530, Ganesh Pal wrote: > Dear python Friends, > > > I need a quick suggestion on the below code. > > def modify_various_line(f): > """ Try modifiying various line """ > try: > f.write(&#

Re: try except inside a with open

2018-07-20 Thread MRAB
On 2018-07-20 18:59, Ganesh Pal wrote: Dear python Friends, I need a quick suggestion on the below code. def modify_various_line(f): """ Try modifiying various line """ try: f.write('0123456789abcdef') f.seek(5) # Go to

try except inside a with open

2018-07-20 Thread Ganesh Pal
Dear python Friends, I need a quick suggestion on the below code. def modify_various_line(f): """ Try modifiying various line """ try: f.write('0123456789abcdef') f.seek(5) # Go to the 6th byte in the file print f.read(

Re: variable scope in try ... EXCEPT block.

2018-07-13 Thread Chris Angelico
On Fri, Jul 13, 2018 at 10:43 PM, Ed Kellett wrote: > On 2018-07-12 18:00, Chris Angelico wrote: >> What do you mean by "fix"? Make the 'x' bind eagerly? That would break >> basically every other use of closures. > > No. I mean make each x a new variable--closures would work as before, > for-loops

Re: variable scope in try ... EXCEPT block.

2018-07-13 Thread Ed Kellett
On 2018-07-12 18:00, Chris Angelico wrote: > What do you mean by "fix"? Make the 'x' bind eagerly? That would break > basically every other use of closures. No. I mean make each x a new variable--closures would work as before, for-loops would change. If we have subscopes, it seems natural that ent

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread Chris Angelico
.err.1", ".err.2"), so they won't conflict with each other. >> >> ChrisA > > Simpler is better. The point is that something like this would accomplish > both: > > 1. Break the reference cycle. > > 2. Avoid what is (IMHO) an unexpected behavior of a

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread codewizard
hen an exception has been assigned using as target, it is cleared at > >> the end of the except clause. This is as if > >> > >> except E as N: > >> foo > >> > >> was translated to > >> > >> except E as N:

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread aleiphoenix
On Thursday, July 12, 2018 at 5:45:52 PM UTC+8, Ben Bacarisse wrote: > > Yes, it's intentional, but it's not exactly a scope. In > > https://docs.python.org/3/reference/compound_stmts.html#try > > -- > Ben. Thank you for the reply. Never thought of this

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread Chris Angelico
se. This is as if >> >> except E as N: >> foo >> >> was translated to >> >> except E as N: >> try: >> foo >> finally: >> del N > > Is there a downside of implementing > it simil

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread Ben Bacarisse
Just word on quoting... codewiz...@gmail.com writes: > On Thursday, July 12, 2018 at 5:45:52 AM UTC-4, Ben Bacarisse wrote: >> >> [snip] You cut everything I wrote. What you left is what I quoted from the Python documentation. In fairness to the authors you should probably have cut the attrib

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread codewizard
oo > > was translated to > > except E as N: > try: > foo > finally: > del N Is there a downside of implementing it similarly to this (untested): # generate a unique name for __except_N except E as __except_N: if 'N' in locals()

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread Chris Angelico
On Thu, Jul 12, 2018 at 11:23 PM, Ed Kellett wrote: > Could we fix: > > for x in something: > blah(lambda a: a + x) > > while we're at it? What do you mean by "fix"? Make the 'x' bind eagerly? That would break basically every other use of closures. ChrisA -- https://mail.python.org/mailma

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread Ed Kellett
On 2018-07-12 14:03, Chris Angelico wrote: > Dealing with reference cycles is generally done *periodically* rather > than immediately (CPython disposes of unreferenced objects immediately > upon last deref). You can avoid having a dedicated cycle detection > pass by using a mark-and-sweep GC, but t

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread Chris Angelico
ed) is implicitly >> deleted. >> >> You can work around this by explicitly assigning to another local >> variable: >> >> try: >> ... >> except Exception as e: >> err = e # only "e" will be deleted when we exit t

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread Ed Kellett
, it is not a new scope, and yes, it is intentional. It's a nasty hack, > but a *necessary* nasty hack: when the except block exits, the "err" > local variable (or whatever it happens to be called) is implicitly > deleted. > > You can work around th

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread Steven D'Aprano
t a *necessary* nasty hack: when the except block exits, the "err" local variable (or whatever it happens to be called) is implicitly deleted. You can work around this by explicitly assigning to another local variable: try: ... except Exception as e: err = e

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread Ben Bacarisse
aleiphoenix writes: > suppose following code running with Python-3.4.8 and Python-3.6.5 > > > # -*- coding: utf-8 -*- > > > def hello(): > err = None > print('0: {}'.format(locals())) > try: > b = 2 > print('

variable scope in try ... EXCEPT block.

2018-07-12 Thread aleiphoenix
suppose following code running with Python-3.4.8 and Python-3.6.5 # -*- coding: utf-8 -*- def hello(): err = None print('0: {}'.format(locals())) try: b = 2 print('1: {}'.format(locals())) raise ValueError() print('2: {}'

Re: try-except syntax

2018-04-06 Thread ElChino
Steven D'Aprano wrote: imp.find_module is deprecated and should not be used in new code. ... try: block except (ImportError, RuntimeError): block Thanks Steven and others who replied. Looks more elegant. By the way, RuntimeError is almost never something you

Re: try-except syntax

2018-04-05 Thread Steven D'Aprano
On Thu, 05 Apr 2018 23:04:18 +0200, ElChino wrote: > I'm trying to simplify a try-except construct. E.g. how come this: >try: > _x, pathname, _y = imp.find_module (mod, mod_path) > return ("%s" % pathname) imp.find_module is deprecated and should not be

Re: try-except syntax

2018-04-05 Thread Gregory Ewing
Ben Bacarisse wrote: Anyway, to coalesce two or more exception handlers, you are probably looking for except (ImportError, RuntimeError): To the OP: Are you sure you really want to mask RuntimeError here? Usually it means something has gone seriously wrong, and is a symptom that shouldn't be

Re: try-except syntax

2018-04-05 Thread Ben Bacarisse
ElChino writes: > I'm trying to simplify a try-except construct. E.g. how come > this: > try: > _x, pathname, _y = imp.find_module (mod, mod_path) > return ("%s" % pathname) > except ImportError: > pass > except RuntimeError: >

Re: try-except syntax

2018-04-05 Thread Ian Kelly
On Thu, Apr 5, 2018 at 3:04 PM, ElChino wrote: > I'm trying to simplify a try-except construct. E.g. how come > this: > try: > _x, pathname, _y = imp.find_module (mod, mod_path) > return ("%s" % pathname) > except ImportError: > pass

Re: try-except syntax

2018-04-05 Thread Rob Gaddi
On 04/05/2018 02:04 PM, ElChino wrote: I'm trying to simplify a try-except construct. E.g. how come this:   try:     _x, pathname, _y = imp.find_module (mod, mod_path)     return ("%s" % pathname)   except ImportError:     pass   except RuntimeError:     pass     return

try-except syntax

2018-04-05 Thread ElChino
I'm trying to simplify a try-except construct. E.g. how come this: try: _x, pathname, _y = imp.find_module (mod, mod_path) return ("%s" % pathname) except ImportError: pass except RuntimeError: pass return ("") Cannot be simplified into this:

Re: I keep getting this error message when i try to run a program in Python

2018-03-22 Thread Thomas Jollans
On 2018-03-22 19:37, Damjan Stojanovski wrote: > i am sorry but i can not find a way to attach an image here so you can see > what i mean. Please someone tell me how to add an image here. > This is a text only list. -- https://mail.python.org/mailman/listinfo/python-list

Re: I keep getting this error message when i try to run a program in Python

2018-03-22 Thread Terry Reedy
On 3/22/2018 2:37 PM, Damjan Stojanovski wrote: i am sorry but i can not find a way to attach an image here so you can see what i mean. Please someone tell me how to add an image here. You cannot and there is no need. List is text only, no attachments. Reduce code to the minimum needed to ge

Re: I keep getting this error message when i try to run a program in Python

2018-03-22 Thread Larry Martell
On Thu, Mar 22, 2018 at 2:37 PM, Damjan Stojanovski wrote: > i am sorry but i can not find a way to attach an image here so you can see > what i mean. Please someone tell me how to add an image here. You can't. Copy/paste the error. And please include the post you are replying to. -- https://ma

Re: I keep getting this error message when i try to run a program in Python

2018-03-22 Thread Damjan Stojanovski
i am sorry but i can not find a way to attach an image here so you can see what i mean. Please someone tell me how to add an image here. Thanks Dan -- https://mail.python.org/mailman/listinfo/python-list

I keep getting this error message when i try to run a program in Python

2018-03-22 Thread Damjan Stojanovski
Dear all I am totally new in learning Python and i am learning from a beginner's book called automate the boring stuff with Python and i downloaded the Python 64 bit version for Windows and i started writing some examples from the book. At the end whenever i try to run the program i

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-08 Thread Ian Kelly
On Wed, Nov 8, 2017 at 11:34 AM, Chris Angelico wrote: > On Thu, Nov 9, 2017 at 5:20 AM, Ian Kelly wrote: >> On Wed, Nov 8, 2017 at 11:12 AM, Chris Angelico wrote: >>> Except that "yield from" is used by generators to delegate to other >>> generators, and "await" is used by coroutines to delegat

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-08 Thread Chris Angelico
On Thu, Nov 9, 2017 at 5:20 AM, Ian Kelly wrote: > On Wed, Nov 8, 2017 at 11:12 AM, Chris Angelico wrote: >> Except that "yield from" is used by generators to delegate to other >> generators, and "await" is used by coroutines to delegate to other >> coroutines. In an asynchronous generator, "yiel

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-08 Thread Ian Kelly
On Wed, Nov 8, 2017 at 11:12 AM, Chris Angelico wrote: > On Thu, Nov 9, 2017 at 5:05 AM, Ian Kelly wrote: >> On Wed, Nov 8, 2017 at 9:31 AM, Chris Angelico wrote: >>> On Thu, Nov 9, 2017 at 3:19 AM, Ian Kelly wrote: I was not referring to the possible future use of yield from for async >>>

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-08 Thread Chris Angelico
On Thu, Nov 9, 2017 at 5:05 AM, Ian Kelly wrote: > On Wed, Nov 8, 2017 at 9:31 AM, Chris Angelico wrote: >> On Thu, Nov 9, 2017 at 3:19 AM, Ian Kelly wrote: >>> I was not referring to the possible future use of yield from for async >>> generators; I was referring to the possibility *today* of us

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-08 Thread Ian Kelly
On Wed, Nov 8, 2017 at 9:31 AM, Chris Angelico wrote: > On Thu, Nov 9, 2017 at 3:19 AM, Ian Kelly wrote: >> I was not referring to the possible future use of yield from for async >> generators; I was referring to the possibility *today* of using "yield >> from" as a synonym for *await*. As far as

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-08 Thread Chris Angelico
On Thu, Nov 9, 2017 at 3:19 AM, Ian Kelly wrote: > I was not referring to the possible future use of yield from for async > generators; I was referring to the possibility *today* of using "yield > from" as a synonym for *await*. As far as I know the only major > obstacle to that is that the author

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-08 Thread Ian Kelly
On Tue, Nov 7, 2017 at 2:42 PM, Chris Angelico wrote: > On Wed, Nov 8, 2017 at 8:16 AM, Ian Kelly wrote: >>> Not one of these is syntactically invalid. Why should "else without >>> break" be trapped by the parser? Your other examples mostly have good >>> parser-level reasons for being errors >> >

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-07 Thread Ian Kelly
On Tue, Nov 7, 2017 at 4:28 PM, Steve D'Aprano wrote: > On Wed, 8 Nov 2017 04:28 am, Ian Kelly wrote: > >> Steve's manufactured interactive example ("manufactured" because >> who really uses for-else interactively? If I really care that much >> about output formatting I'm going to put it in a scr

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-07 Thread Steve D'Aprano
On Wed, 8 Nov 2017 04:28 am, Ian Kelly wrote: > Steve's manufactured interactive example ("manufactured" because > who really uses for-else interactively? If I really care that much > about output formatting I'm going to put it in a script). Me. As I have said. I really don't appreciate you imp

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-07 Thread Chris Angelico
On Wed, Nov 8, 2017 at 8:16 AM, Ian Kelly wrote: > All of these are things that a linter should probably catch and warn > about. If you had said that the break syntax suggestion was a good > idea but probably better suited as a linter warning than as a > SyntaxError integrated into the parser, the

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-07 Thread Ian Kelly
red" because >> who really uses for-else interactively? If I really care that much >> about output formatting I'm going to put it in a script). If there is >> any extant code that would actually be broken by this, it's very >> likely buggy. > > There are many

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-07 Thread Chris Angelico
eption > of Steve's manufactured interactive example ("manufactured" because > who really uses for-else interactively? If I really care that much > about output formatting I'm going to put it in a script). If there is > any extant code that would actually be broken

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-07 Thread Ian Kelly
On Sat, Nov 4, 2017 at 6:40 AM, Chris Angelico wrote: > On Sat, Nov 4, 2017 at 11:25 PM, Jon Ribbens > wrote: >> On 2017-11-04, Ben Finney wrote: >>> To respond to the criticism of an idea – criticism containing no mention >>> of the person – as though it “clearly refers to the [person]”, is of

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-07 Thread Ian Kelly
On Fri, Nov 3, 2017 at 11:55 PM, Ben Finney wrote: > Ian Kelly writes: > >> Please stop defending the use of incivility on this list. > > Please stop conflating people, who deserve civility, with ideas. We must > not allow the civility deserved by people, to prevent us from > criticising any idea

Re: replacing `else` with `then` in `for` and `try`

2017-11-06 Thread Random832
I haven't read over every message in the thread, so sorry if this has been suggested before, but how about "if not break:" and "if not except:" as synonyms for the current 'else' clause? They're already keywords, and this sequence of keywords has no current meaning. -- https://mail.python.org/mail

Re: replacing 'else' with 'then' in 'for' and 'try'

2017-11-06 Thread ROGER GRAYDON CHRISTMAN
Just a little two-cent opinion from the peanut gallery: I've been following all the discussion on this go by, sometimes getting a bit heated at times, and just sitting nice and safe and secure in my little ivory tower, where I simply tell my students to not use 'break'. As a stodgy educator,

Re: replacing `else` with `then` in `for` and `try`

2017-11-06 Thread Ned Batchelder
On 11/6/17 8:05 AM, Jon Ribbens wrote: On 2017-11-06, Chris Angelico wrote: If you start with the assumption that "intuitively obvious" doesn't actually mean "intuitively obvious" but actually means something completely different, then your statement definitely means something non-contradictory

Re: replacing `else` with `then` in `for` and `try`

2017-11-06 Thread Chris Angelico
On Tue, Nov 7, 2017 at 12:05 AM, Jon Ribbens wrote: > On 2017-11-06, Chris Angelico wrote: >> If you start with the assumption that "intuitively obvious" doesn't >> actually mean "intuitively obvious" but actually means something >> completely different, then your statement definitely means somet

Re: replacing `else` with `then` in `for` and `try`

2017-11-06 Thread Jon Ribbens
On 2017-11-06, Chris Angelico wrote: > If you start with the assumption that "intuitively obvious" doesn't > actually mean "intuitively obvious" but actually means something > completely different, then your statement definitely means something > non-contradictory. But if you start with the assump

Re: replacing `else` with `then` in `for` and `try`

2017-11-06 Thread Chris Angelico
On Mon, Nov 6, 2017 at 10:34 PM, Jon Ribbens wrote: > On 2017-11-06, Ben Finney wrote: >> Jon Ribbens writes: >>> On 2017-11-05, Ben Finney wrote: >>> > Jon Ribbens writes: >>> >> I've provided you with a way of thinking about 'for...else' that makes >>> >> its purpose and meaning intuitively

  1   2   3   4   5   6   7   8   9   10   >