On Sun, Aug 16, 2015 at 7:55 PM, Alan Gauld wrote:
> On 17/08/15 00:52, boB Stepp wrote:
>
>>> sqlite3> .read populate_base_data.sql
>>
>>
>> I am assuming that the .read command would be replaced inside the
>> program by the cursor.executescript() method you mentioned? This will
>> be quite hand
On 17/08/15 00:52, boB Stepp wrote:
sqlite3> .read populate_base_data.sql
I am assuming that the .read command would be replaced inside the
program by the cursor.executescript() method you mentioned? This will
be quite handy, I think.
No.
The executescript() method *replaces* .read
.read is
On Sun, Aug 16, 2015 at 7:36 PM, Danny Yoo wrote:
> By the way, when you're unit testing with Sqlite, you might find it
> convenient to use the ":memory:" option, which keeps the database in
> RAM rather than on disk. That should make the "setup" and "tear-down"
> of the testing environment easi
Hi Bob,
By the way, when you're unit testing with Sqlite, you might find it
convenient to use the ":memory:" option, which keeps the database in
RAM rather than on disk. That should make the "setup" and "tear-down"
of the testing environment easier to maintain.
The principle is similar to that o
On Sun, Aug 16, 2015 at 6:04 PM, Alan Gauld wrote:
> On 16/08/15 23:29, boB Stepp wrote:
>
>> http://www.sqlite.org/download.html
>
>
> You definitely want this.
> You treat it like the >>> prompt in Pyython.
I had just finished installing and testing the installation just
before your email arriv
Hello,
Thank you for your guidance. Using your pseudocode I have put together the
following:
import socket
import csv
in_file = open('top500ips.csv', 'r')
out_file = open('top500ips_out.csv', 'w')
for line in in_file:
try:
name = socket.gethostbyaddr(line.strip())
out_f
On 16/08/15 23:29, boB Stepp wrote:
http://www.sqlite.org/download.html
You definitely want this.
You treat it like the >>> prompt in Pyython.
A place to try out SQL queries before you put
them into your Python code. Also you can write
long sql code in a .sql filer and read them
into the inte
On Sun, Aug 16, 2015 at 4:03 AM, Steven D'Aprano wrote:
> On Sun, Aug 16, 2015 at 01:18:06AM -0500, boB Stepp wrote:
>> 1) It would seem that I need to install a stand-alone version of
>> SQLite, so that I can create this test db. Either that or write a
>> separate Python program whose sole purp
On 16/08/15 22:42, Nym City wrote:
import socket
import csv
You don't need csv, you aren't using it.
in_file = open('top500ips.csv', 'r')
out_file = open('top500ips_out.csv', 'w')
for line in in_file:
try:
name = socket.gethostbyaddr(line.strip())
out_file.write(line + '\
On 2015-08-16 12:45, Laura Creighton wrote:
We have a new mechanism for test discovery in 2.7 and 3.x
https://docs.python.org/3/library/unittest.html
see 26.3.3
It's been backported.
see: https://pypi.python.org/pypi/unittest2
Also, if you are on Python2 and you put your tests in a test
subdi
On 16/08/15 21:28, Joseph Gulizia wrote:
Assume that the grader defines two variables A and B for you. Write a
program which prints out the value
min(A, B)
So far a trivial exercise.
However, there is a catch: your program is not allowed to use the min
function. Instead, use max in a clever
On 16/08/15 20:46, Alex Kleider wrote:
Where/how is the best place/way to set PYTHONPATH?
I've never been clear to me if it's part of the shell (bash)
environment or part of the python interpreter's environment.
The environment is user specific, so whichever shell the
user has (zsh, tcsh, bash
Complicating a simple expression
Coding Exercise: Complication
Assume that the grader defines two variables A and B for you. Write a
program which prints out the value
min(A, B)
However, there is a catch: your program is not allowed to use the min
function. Instead, use max in a clever way to si
In a message of Sun, 16 Aug 2015 12:46:59 -0700, Alex Kleider writes:
>On 2015-08-16 10:45, Alan Gauld wrote:
>
>> Thee are several options.
>> 1) create links from, main to the test files needed
>> 2) alter sys.path so imports can see the test folder
>> 3) alter the PYTHONPATH environment var
>
>>
On 2015-08-16 10:45, Alan Gauld wrote:
Thee are several options.
1) create links from, main to the test files needed
2) alter sys.path so imports can see the test folder
3) alter the PYTHONPATH environment var
I suspect in this case the easiest solution is a link
Thanks Alan.
Creating a li
In a message of Sun, 16 Aug 2015 18:45:31 +0100, Alan Gauld writes:
>On 16/08/15 16:41, Alex Kleider wrote:
>
>>> - src the code
>>> -- lang folder per language used - sql, python, C, bash, etc
>>> --- lib modules/packages - subfolder per package
>>> --- test test code - sub-tree
On 16/08/15 16:41, Alex Kleider wrote:
- src the code
-- lang folder per language used - sql, python, C, bash, etc
--- lib modules/packages - subfolder per package
--- test test code - sub-tree under this, depends on test tools.
--- toolstools used but not shipped - db loa
On 2015-08-16 01:28, Alan Gauld wrote:
Here is my default structure
project
- doc project documents: contracts reqs, designs, test specs etc
- man(*) user docs
- bin(*) the master exe or main.py type files
- lib(*) the shipping libraries
- src the code
-- lang folder per langu
On 16/08/15 09:10, Ben Finney wrote:
So that points to a need for better design: Don't directly issue
arbitrary SQL queries in code which implements higher-level features.
Instead, define a much more specific interface between your feature code
and the lower-level code that interacts with the dat
On Sat, Aug 15, 2015 at 07:04:47PM -0500, boB Stepp wrote:
> On Sat, Aug 15, 2015 at 6:41 PM, Steven D'Aprano wrote:
> > On Sat, Aug 15, 2015 at 02:24:21PM -0500, boB Stepp wrote:
>
> >> I understand your points, but wonder then what is the intended use for
> >> os.path.exists()? That is, in wha
On Sat, Aug 15, 2015 at 06:24:12PM -0500, boB Stepp wrote:
> db = sqlite3.connect("my_db.db")
>
> 1) This will open the db if it exists already, which is normally what
> I will want. But...
>
> 2) My understanding is that if for whatever reason the db file is not
> found, then the connect statem
On Sat, Aug 15, 2015 at 03:38:31PM -0700, Clayton Kirkwood wrote:
> top_directory = "/users/Clayton/Pictures"
> target_directory = top_directory #directory we are checking
> filetypes = ('jpg', 'png', 'avi', 'mp4', 'mov', 'bmp')
>
> imports...
>
> def override_defaults():
> with open( us
Clayton Kirkwood wrote:
>> > Above is the actual code.
Clayton, try to understand how scoping works in Python before you go back to
your actual code. Can you predict what the following snippet will produce?
x = "first global"
def f():
return x
def g():
return x
x = "local"
x = "
On Sun, Aug 16, 2015 at 01:18:06AM -0500, boB Stepp wrote:
> Being committed to TDD for this project, I am not yet ready to write
> code till I figure out how to write the tests. It occurs to me that
> writing tests for code that interacts with the SQLite db may be
> non-trivial (At least for me!)
On 16/08/15 03:10, boB Stepp wrote:
time. I have not ever thought about formal project directory
structures before, so I may need a bit of guidance here.
As you've discovered this varies wildly between projects.
Here is my default structure, but bear in mind most of my
projects have been big
Laura Creighton writes:
> The Python Standard Library, for the most part, uses underscores
> for variable names and CamelCase for class names.
Note a sharp distinction between camelCaseNames, which the Python
community eschews, versus TitleCaseNames, which are embraced for names
of classes.
> S
boB Stepp writes:
> Being committed to TDD for this project, I am not yet ready to write
> code till I figure out how to write the tests. It occurs to me that
> writing tests for code that interacts with the SQLite db may be
> non-trivial (At least for me!).
That's correct.
One of the primary b
On 16/08/15 07:18, boB Stepp wrote:
tonight, it appears that I need to create a test SQLite db. I don't
see any other way that I can test such code without having a db to
test against.
Correct. And it is a non trivial task but immensely useful since you can
populate it with sample data repre
In a message of Sat, 15 Aug 2015 15:20:19 -0700, "Clayton Kirkwood" writes:
>> If you want to locate dangling symlinks, os.path.exists will return
>False, so
>> the symlink is there, but the file it pointed to is long gone.
>
>Can't you do that with os.path.open() and get a value in os.path.status
In a message of Sat, 15 Aug 2015 18:24:53 -0700, D Wyatt writes:
>It seems every book I read these days uses camel case for variable names in
>Python. I was once told that using underscores is preferred. Is there a
>preference in the Python community or does it really matter? I'd like to
>instil
30 matches
Mail list logo