Re: replacing `else` with `then` in `for` and `try`
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 obvious. >> > >> > I've read that sentence several times, and I still can't make it >> > anything but a contradiction in terms. >> >> Well, keep at it and I'm sure you'll work it out eventually. > > You don't want to provide me with a way of thinking about it that makes > it mean something non-contradictory? :-) It already does mean something non-contradictory. This is comp.lang.python (or python-list), not alt.english.remedial. If you start from the wrong premise, as Steve is doing, then even the most obvious of things can be rendered opaque and confusing. As I said, I've provided a solution to the problem, what more do you want? This feels very much like you're arguing for argument's sake, which is a game I'm not willing to play along with for much longer. -- https://mail.python.org/mailman/listinfo/python-list
Re: replacing `else` with `then` in `for` and `try`
On 06/11/2017 02:28, Steve D'Aprano wrote: On Sat, 4 Nov 2017 03:57 pm, Michael Torrie wrote: Can you be more specific? What are some of these "many" ways of aborting a loop? Help a guy out here. Aside from more exotic methods such as os.abort, os._exit and signal handlers, the common ways of breaking out of a loop are: - raise - return - break Am I being pedantic? Of course I am. But we're programmers -- if we don't have an accurate and complete understanding of code, who will? Given how many people find it difficult to understand the semanics of for...else, I think we need to be pedantic about it. Take this for-loop: for I in R: A else: B C Here are the various ways of exiting the loop, with Y or N indicating whether that particular block (or 'suite') is executed: B C Normal termination: Y Y Break from A: N Y Raise/return/etc from A:N N Here, we're only interested in whether B and C have different entries, as that would be the only reason to have an 'else' part in the first place. And that only happens when the loop is terminated with a Break. Unless someone knows of any other circumstances where B is not executed but C is. (Both B and C also contain raise, return, exit(), infinite loops etc, but that shouldn't effect this point.) Break inside the loop can also be conditional (I think it has to be if you want more than one iteration!), which means that sometimes, it will never break, then you get the Y/Y (or N/N) result. But the expectation is that there the break COULD be executed, so you will need the 'else'. -- bartc -- https://mail.python.org/mailman/listinfo/python-list
Re: replacing `else` with `then` in `for` and `try`
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 obvious. >>> > >>> > I've read that sentence several times, and I still can't make it >>> > anything but a contradiction in terms. >>> >>> Well, keep at it and I'm sure you'll work it out eventually. >> >> You don't want to provide me with a way of thinking about it that makes >> it mean something non-contradictory? :-) > > It already does mean something non-contradictory. This is > comp.lang.python (or python-list), not alt.english.remedial. > If you start from the wrong premise, as Steve is doing, then > even the most obvious of things can be rendered opaque and > confusing. 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 assumption that "intuitively obvious" really does mean that the purpose and meaning of for-else can be understood easily without external information, then your statement contradicts itself. This is comp.lang.python, not alt.english.remedial, so we expect you to use English competently, or at least accept correction when you misuse words. > As I said, I've provided a solution to the problem, what more > do you want? This feels very much like you're arguing for > argument's sake, which is a game I'm not willing to play along > with for much longer. Except that you haven't. Your proposed solution is incorrect and false. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: replacing `else` with `then` in `for` and `try`
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 assumption that > "intuitively obvious" really does mean that the purpose and meaning of > for-else can be understood easily without external information, then > your statement contradicts itself. I didn't say that 'for...else' was inherently "intutively obvious". In fact I said the opposite of that. I said that *if* you start from the right premise then it *becomes* intuitively obvious. > This is comp.lang.python, not alt.english.remedial, so we expect you > to use English competently, or at least accept correction when you > misuse words. I'm glad your expectations are being met then. You might want to work on also reading English competently, and then everyone will be happy! >> As I said, I've provided a solution to the problem, what more >> do you want? This feels very much like you're arguing for >> argument's sake, which is a game I'm not willing to play along >> with for much longer. > > Except that you haven't. Your proposed solution is incorrect and false. Yes, your logical argument there as to why is undeniable. I must admit that your little gang's assertion that I'm foolish and mistaken because I find Python's syntax simple to understand and you find it hard to understand seems a little contradictory. -- https://mail.python.org/mailman/listinfo/python-list
Re: Read Firefox sqlite files with Python
On Monday, November 6, 2017 at 8:42:29 AM UTC+5:30, Steve D'Aprano wrote:
> On Mon, 6 Nov 2017 12:39 am, Paul Moore wrote:
>
> > On 5 November 2017 at 01:22, Steve D'Aprano wrote:
> >> On Sun, 5 Nov 2017 04:32 am, Steve D'Aprano wrote:
> >>
> >>> I'm trying to dump a Firefox IndexDB sqlite file to text using Python 3.5.
> >>>
> >>>
> >>> import sqlite3
> >>> con = sqlite3.connect('foo.sqlite')
> >>> with open('dump.sql', 'w') as f:
> >>> for line in con.iterdump():
> >>> f.write(line + '\n')
> >>
> >>
> >> Never mind. I dumped the file using the sqlite3 command line tool. Thank
> >> you to all those who answered.
> >>
> >> The file contains three INSERT statements, the first two don't have
> >> anything of interest, and the third (which presumably contains all the data
> >> I'm trying to recover) is an opaque 600+ KB blob.
> >>
> >> Naturally. Why would you use a database as a database, when instead you
> >> could just dump a big ball of mud into it?
> >
> > Hmm, *.sql files normally contain SQL source code (as this one does).
>
> The .sql file is the result of running .dump from the sqlite command line
> tool. The original source database is 'foo.sqlite'. To be precise, it is the
> database used by the Firefox Add-On "One Tab".
>
> /home/steve/.mozilla/firefox/2z5po7dx.default/storage/permanent/indexeddb+++extension-at-one-tab-dot-com/idb/1832832054obnaet.sqlite
>
> One Tab provides an alternative bookmark-like function, allowing you to record
> URLs in groups for later use -- a bit like bookmarks. So I've been using this
> for some months, until the add-on stopped working. (Yet again an automatic
> update has screwed me and broken functionality.) So now I'm trying to
> retrieve the bookmarks.
[Not python-related and likely not an answer… Just what I would try]
1. Get hold of an old live ubuntu (say 12.4) ISO/flash/CD and boot
2. Mount /home
3. Make livecd~/.mozilla symlink to home/~steven/.mozilla
Do you see your bookmarks?
--
https://mail.python.org/mailman/listinfo/python-list
Re: solutions manual, test bank for Industrial Organizational Psychology 4e Paul Levy, contact direct by email at studentshelp(at)hotmail(dot)com
for any test bank or solutions manual please contact :tbsmtext(at)gmail(dot)com -- https://mail.python.org/mailman/listinfo/python-list
Re: solutions manual, test bank for Psychological Testing Principles, Applications, and Issues, 9e Robert Kaplan, Dennis Saccuzzo, contact direct by email at studentshelp(at)hotmail(dot)com
for any test bank or solutions manual please contact :tbsmtext(at)gmail(dot)com -- https://mail.python.org/mailman/listinfo/python-list
Re: replacing `else` with `then` in `for` and `try`
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 something >> non-contradictory. But if you start with the assumption that >> "intuitively obvious" really does mean that the purpose and meaning of >> for-else can be understood easily without external information, then >> your statement contradicts itself. > > I didn't say that 'for...else' was inherently "intutively obvious". > In fact I said the opposite of that. I said that *if* you start from > the right premise then it *becomes* intuitively obvious. If you have to start by explaining a premise, it's not intuitive. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: replacing `else` with `then` in `for` and `try`
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. But if you start with the assumption that "intuitively obvious" really does mean that the purpose and meaning of for-else can be understood easily without external information, then your statement contradicts itself. I didn't say that 'for...else' was inherently "intutively obvious". In fact I said the opposite of that. I said that *if* you start from the right premise then it *becomes* intuitively obvious. This is comp.lang.python, not alt.english.remedial, so we expect you to use English competently, or at least accept correction when you misuse words. I'm glad your expectations are being met then. You might want to work on also reading English competently, and then everyone will be happy! As I said, I've provided a solution to the problem, what more do you want? This feels very much like you're arguing for argument's sake, which is a game I'm not willing to play along with for much longer. Except that you haven't. Your proposed solution is incorrect and false. Yes, your logical argument there as to why is undeniable. I must admit that your little gang's assertion that I'm foolish and mistaken because I find Python's syntax simple to understand and you find it hard to understand seems a little contradictory. Ugh, can't we all just give each other the benefit of the doubt, and use the principle of charity? It's easy to miscommunicate in a purely textual medium. Everyone just take your foot off the "i'm right and you're wrong" gas pedal for moment. --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: FW: Reading a remove csv file
On 2017-11-03 00:40, Stefan Ram wrote: > I knew I reïnvented something. Maybe it was »map«. Quite. If you really need that one-argument callable, you can curry map() with functools.partial. Also, that tréma is highly unorthodox. -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list
DJANGO app loose path from batch file
I try to learn more about Django celery and rabbitmq to create some async tasks and I have some question. Some programs can provide PYTHON API to can some development to use modules from this program in python. one most way to take that PYTHON API from this program is to use batch file like this : @echo off SET PROGRAM_ROOT=C:\main-folder call "%PROGRAM_ROOT%"\bin\some-batch-file.bat SET PYCHARM="C:\Program Files\JetBrains\PyCharm 2017.1.5\bin\pycharm64.exe" set PYTHONPATH=%PYTHONPATH%;%PROGRAM_ROOT%\python; set PYTHONPATH=%PYTHONPATH%;%PROGRAM_ROOT%\site-packages; start "PyCharm aware of PROGRAM" /B %PYCHARM% %* if I run this batch file can I use all imports and modules from this program. that to release if add celery in my app and broker url rabbitmq server then if i use some module or some import from this python api then I take error message : no module name some_module_from_program (for all other modules celery and rabbitmq app work fine). that mean in celery and rabbitmq server loose that paths from batch file and I take this error. my question how to can define rabbitmq server to start server with that paths like batch file before to avoid this error? -- https://mail.python.org/mailman/listinfo/python-list
Re: replacing 'else' with 'then' in 'for' and 'try'
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, I usually restrict them for these two reasons: 1) the loop condition should describe your expected loop conditions, and 2) the exception handling structure allows more control over where the exceptional circumstances will be handled (including which function) When it comes to searching an iterable collection, my ivory-tower view point tells me that the looping condition is based on whether the item is found, and is not a for loop traversing the entirety. To me, that is the 'one obvious way to do it' If I expect the item will be found, but fear that it will not, I can always compare a subscript to len(), or if that seems too hard, catch the StopIteration exception. I only recommend the for loop when the true expectation is to visit the entire collection (which can later be moderated with iter's sentinel parameter, or some of the filters in itertools) And I see that simply removing 'break' from my vocabulary, this whole 'else on a loop' issue completely dissolves. So thank you for, even unintentionally, helping me to feel good about living inside my ivory tower! Roger Christman Pennsylvania State University -- https://mail.python.org/mailman/listinfo/python-list
Re: replacing `else` with `then` in `for` and `try`
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/mailman/listinfo/python-list
Re: Python Mailing list moderators
On Sun, 5 Nov 2017 17:28:05 -0500, Terry Reedy wrote: > On 11/5/2017 4:14 PM, Cameron Simpson wrote: >> On 05Nov2017 13:09, Στέφανος Σωφρονίου >> wrote: >>> Folks, >>> More and more nonsense are coming in and I find it really difficult to >>> follow any new post that may come and I have to either search for >>> specific content or scroll down until I hit it by accident. >>> >>> Can we do something about it? >>> It's getting really frustrating :/ >> >> It seems from the headers on your message that you're actually using the >> comp.lang.python newsgroup and not the mailing list. The newsgroup is >> completed unmoderated. The mailing list is far less noisy. >> >> Go here: >> >> https://mail.python.org/mailman/listinfo/python-list >> >> and subscribe, and see if things seem better than the newsgroup. > Or point your newsreader to news.gmane.org group > gmane.comp.python.general, which mirrors python-list. [snip] Or use a newsgroup reader that can be easily taught to ignore certain subjects or posters. Or buy your newsgroup service from a provider that does some filtering. I use slrn to read news from news.individual.net, and see only a handful of spam posts on a typical day. -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list
Incomplete description using sqlite3
I'm using sqlite3 (2.6.0, SQLite version 3.13.0, Python 2.7.13) and
was hoping to introspect the types of a table using the cursor's
description attribute. PEP 249 states: "The first two items (name and
type_code) are mandatory..." I tried this query:
conn = sqlite3("/some/existing/database")
curs = conn.cursor()
curs.execute("select * from mytable limit 1")
curs.fetchall()
Looking at curs.description, I see that it contained a seven-element
tuple for each column, but only the first element (name) was non-None.
Even the type_code field (required, according to the PEP) was None. I
tried the same trick using pyodbc talking to SQL Server (select top(1)
* from mytable). It returned more useful information.
Did I go about things wrong with SQLite, or is the sqlite3 module (or
SQLite database underlying it) not capable enough?
Thx,
Skip
--
https://mail.python.org/mailman/listinfo/python-list
Easiest way to access C module in Python
Hi all, I have successfully used Python to perform unit and integration tests in the past and I'd like to do the same for some C modules I'm working with at work. There seem to be a number of ways of doing this but being busy at work and home I looking for the approach with the least learning curve. I don't want to add the C modules into the CPython build itself as I've never done this and at work it's a real pain getting admin rights to do this, and when you do it lasts just 24 hours. The C modules are likely to change frequently as bugs are found and features added. The other option I'm considering is to use sockets and write a C wrapper round the C modules I want to test. This has the advantage for me that I know about sockets from Python & C points of view and I get complete control of the C compile process. This may be important as the C modules come from an embedded project and I don't want to change them in any way. Are there any other approachs to this problem? I'll be using Python 3.5 (work) and 3.6 (home). Feedback appriciated. -- https://mail.python.org/mailman/listinfo/python-list
Re: Easiest way to access C module in Python
On Tue, Nov 7, 2017 at 10:43 AM, John Pote wrote: > Hi all, > I have successfully used Python to perform unit and integration tests in the > past and I'd like to do the same for some C modules I'm working with at > work. There seem to be a number of ways of doing this but being busy at work > and home I looking for the approach with the least learning curve. > > I don't want to add the C modules into the CPython build itself as I've > never done this and at work it's a real pain getting admin rights to do > this, and when you do it lasts just 24 hours. The C modules are likely to > change frequently as bugs are found and features added. Fortunately, you don't have to modify CPython to do this :) > The other option I'm considering is to use sockets and write a C wrapper > round the C modules I want to test. This has the advantage for me that I > know about sockets from Python & C points of view and I get complete control > of the C compile process. This may be important as the C modules come from > an embedded project and I don't want to change them in any way. > > Are there any other approachs to this problem? > I'll be using Python 3.5 (work) and 3.6 (home). > Feedback appriciated. This. The best way to do this is to create a wrapper... but the best way to create that wrapper is with Cython. (Not to be confused with CPython.) Check out http://cython.org/ to see what it takes to carry information into and out of the C module. You'd compile the Cython wrapper and then import that from Python directly. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Easiest way to access C module in Python
John Pote wrote: Hi all, I have successfully used Python to perform unit and integration tests in the past and I'd like to do the same for some C modules I'm working with at work. There seem to be a number of ways of doing this but being busy at work and home I looking for the approach with the least learning curve. I don't want to add the C modules into the CPython build itself as I've never done this and at work it's a real pain getting admin rights to do this, and when you do it lasts just 24 hours. The C modules are likely to change frequently as bugs are found and features added. The other option I'm considering is to use sockets and write a C wrapper round the C modules I want to test. This has the advantage for me that I know about sockets from Python & C points of view and I get complete control of the C compile process. This may be important as the C modules come from an embedded project and I don't want to change them in any way. Are there any other approachs to this problem? I'll be using Python 3.5 (work) and 3.6 (home). Feedback appriciated. Install Oracle's "Virtual Box" software on your computer. It's free. Then install a version of Linux on it (or something else, if you prefer). Whatever you do, if you don't like it, you can replace your installation in a matter of minutes. -- https://mail.python.org/mailman/listinfo/python-list
Re: Easiest way to access C module in Python
On 07/11/2017 00:58, Chris Angelico wrote: On Tue, Nov 7, 2017 at 10:43 AM, John Pote wrote: Hi all, I have successfully used Python to perform unit and integration tests in the past and I'd like to do the same for some C modules I'm working with at work. There seem to be a number of ways of doing this but being busy at work and home I looking for the approach with the least learning curve. I don't want to add the C modules into the CPython build itself as I've never done this and at work it's a real pain getting admin rights to do this, and when you do it lasts just 24 hours. The C modules are likely to change frequently as bugs are found and features added. Fortunately, you don't have to modify CPython to do this :) The other option I'm considering is to use sockets and write a C wrapper round the C modules I want to test. This has the advantage for me that I know about sockets from Python & C points of view and I get complete control of the C compile process. This may be important as the C modules come from an embedded project and I don't want to change them in any way. Are there any other approachs to this problem? I'll be using Python 3.5 (work) and 3.6 (home). Feedback appriciated. This. The best way to do this is to create a wrapper... but the best way to create that wrapper is with Cython. (Not to be confused with CPython.) Check out http://cython.org/ to see what it takes to carry information into and out of the C module. You'd compile the Cython wrapper and then import that from Python directly. Cython seems very confusing to me. The simplest way for Python to run C is for Python to just run the executable created using C. If that is possible. Otherwise what /I/ would look for is ways to call C functions inside shared libraries (.dll and .so). That requires that the modules under test be wrapped as a shared library, which may be extra effort (but it will still be using C, so with familiar tools and no crossover with Python at this point). To call shared library C functions from Python I think involves the ctypes module (I've never done it). Googling 'ctypes shared library' gives some promising results. -- bartc -- https://mail.python.org/mailman/listinfo/python-list
Re: Easiest way to access C module in Python
On 2017-11-06, John Pote wrote: > I have successfully used Python to perform unit and integration tests in > the past and I'd like to do the same for some C modules I'm working with > at work. There seem to be a number of ways of doing this but being busy > at work and home I looking for the approach with the least learning curve. When I want to test C modules (usually destined for an embedded system) using a Python framework, I use ctypes. https://docs.python.org/3/library/ctypes.html -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: Easiest way to access C module in Python
On Tue, Nov 7, 2017 at 12:52 PM, bartc wrote: > On 07/11/2017 00:58, Chris Angelico wrote: >> >> On Tue, Nov 7, 2017 at 10:43 AM, John Pote >> wrote: >>> >>> Hi all, >>> I have successfully used Python to perform unit and integration tests in >>> the >>> past and I'd like to do the same for some C modules I'm working with at >>> work. There seem to be a number of ways of doing this but being busy at >>> work >>> and home I looking for the approach with the least learning curve. >>> >>> I don't want to add the C modules into the CPython build itself as I've >>> never done this and at work it's a real pain getting admin rights to do >>> this, and when you do it lasts just 24 hours. The C modules are likely to >>> change frequently as bugs are found and features added. >> >> >> Fortunately, you don't have to modify CPython to do this :) >> >>> The other option I'm considering is to use sockets and write a C wrapper >>> round the C modules I want to test. This has the advantage for me that I >>> know about sockets from Python & C points of view and I get complete >>> control >>> of the C compile process. This may be important as the C modules come >>> from >>> an embedded project and I don't want to change them in any way. >>> >>> Are there any other approachs to this problem? >>> I'll be using Python 3.5 (work) and 3.6 (home). >>> Feedback appriciated. >> >> >> This. The best way to do this is to create a wrapper... but the best >> way to create that wrapper is with Cython. (Not to be confused with >> CPython.) Check out http://cython.org/ to see what it takes to carry >> information into and out of the C module. You'd compile the Cython >> wrapper and then import that from Python directly. > > > Cython seems very confusing to me. > > The simplest way for Python to run C is for Python to just run the > executable created using C. If that is possible. > > Otherwise what /I/ would look for is ways to call C functions inside shared > libraries (.dll and .so). That requires that the modules under test be > wrapped as a shared library, which may be extra effort (but it will still be > using C, so with familiar tools and no crossover with Python at this point). > > To call shared library C functions from Python I think involves the ctypes > module (I've never done it). Googling 'ctypes shared library' gives some > promising results. The point of Cython is to make this easier. It's worth learning. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Easiest way to access C module in Python
Am 07.11.17 um 02:59 schrieb Grant Edwards: On 2017-11-06, John Pote wrote: I have successfully used Python to perform unit and integration tests in the past and I'd like to do the same for some C modules I'm working with at work. There seem to be a number of ways of doing this but being busy at work and home I looking for the approach with the least learning curve. When I want to test C modules (usually destined for an embedded system) using a Python framework, I use ctypes. https://docs.python.org/3/library/ctypes.html Another possibility is SWIG http://www.swig.org/ When you already have a C header file, SWIG creates a Python module out of it. In many cases this is sufficient to get a runnable interface, but sometimes you need to add additional functions (like initialisation functions) to your module to make it usable from Python. Christian -- https://mail.python.org/mailman/listinfo/python-list
I am trying to delete duplicates but the job just finishes with an exit code 0
I am trying to delete duplicates but the job just finishes with an exit code 0
and does not delete any duplicates.
The duplicates for the data always exist in Column F and I am desiring to
delete the entire row B-I
Any ideas?
import openpyxl
wb1 = openpyxl.load_workbook('C:/dwad/SWWA.xlsx')
ws1 = wb1.active # keep naming convention consistent
values = []
for i in range(2,ws1.max_row+1):
if ws1.cell(row=i,column=1).value in values:
#pass
#else:
values.append(ws1.cell(row=i,column=1).value)
for value in values:
ws1.append([value])
I have attempted to do this with openpyxl for an excel as well as other methods
(including csv though this deleted rows excessively).
CSV:
with open('1.csv','r') as in_file, open('2.csv','w') as out_file:
seen = set() # set for fast O(1) amortized lookup
for line in in_file:
if line not in seen:
seen.add(line)
out_file.write(line)
--
https://mail.python.org/mailman/listinfo/python-list
