I have a bunch of functions that do various utility-type tasks in an
application (such as prettifying date strings, etc.), and they are used in many
modules. Much of the time, I have just been lazily copying and pasting the
functions into whichever modules need them. I realize that is very ba
> Would Pygame allow me to code all of the bricks instead of drawing them out?
I've never used Pygame; I have no idea. What I was suggesting was just getting
a picture of a real or Lego-like brick from somewhere and using that image in
your program. No drawing required.
> How would I go about creating custom GUI elements? For example,
> if I wanted to make a simple LEGO maker app, how would I write the
> code for the bricks so that the user could drag them around and then
> build LEGO models?
For 2D legos, using the wxPython widget toolkit, you could probab
> The other day, I wrote a little database just to fiddle around,
> but when I try to run it it says that it has an unexpected indent.
> From what I can tell, it doesn't. Here's the code. I'm using SPE.
In the future, you should copy/paste error message you get into
your email. This way it ind
> #, showing his output. We need to make sure we are on the same playing
> ground with numpy and scipy. I don't think we are. He barely knows
> Python, but did, supposedly, a install of it, numpy and scipy from the
> same written direction I use. I think he mistakenly installed a
> different
> > But, the issue is, I have many places where I write to the database and
> > would have to embed each of these in a try/except block. I can do that,
> > but wondered if there is a "global" way to catch this 'database is locked'
> > error? I found someone asking this sort of question onlin
Thanks, Alan, for this set of helpful pointers. Just a few responses.
> Actually web apps are all pretty similar. They consist of three basic
> parts
> (maybe 4):
> 1) A mechanism for mapping a URL to a Python function or method.
> 2) A mechanism for generating HTML with embedded data values
A week or two back I asked this list about how to deal with SQLite database
errors like 'database is locked'. Since then I figured out one way to
reproduce that error (*see p.s. below if anyone is interested). I can also
then catch the error with a try/except block and prevent it from causing
> Che, from the analogies you made, it looks like you might not have very
> clear what Unit Testing is for.
>
> True, UT is a way to automate tests that otherwise you should do
> manually (as per your analogy), but the test you automate with UT are
> not a "one off" thing (as it is processing t
> > The idea of unit testing/test driven development has remained
> > foreign to me throughout my time trying to learn Python--by choice.
> > I want to make desktop GUI applications and I don't use MVC, so
> > the idea of writing tests strikes me as far more work--and a major
> > delayer of gett
> > There is a myriad of python web development frameworks. Here's a link
> > with a ton of info:
> >
> > http://wiki.python.org/moin/WebFrameworks
> I had looked into Django before. What is confusing me is that it
> sounds like it is meant to be run on the server directly. I do not
> have direc
> Do any of you have any feedback, strategies and best practices
> related to unit testing within Python. This is a relatively new topic
> for me. I was thinking of starting with reading the documentation
> associate with the unittest module.
The idea of unit testing/test driven development
Date: Tue, 20 Jul 2010 07:28:45 +0200
From: cwi...@compuscan.co.za
To: pine...@hotmail.com
CC: tutor@python.org
Subject: Re: [Tutor] SQLite database locked problem
On 20/07/2010 06:48, Che M wrote:
I'm
using an SQLite3 database (with Python 2.5) and every so ofte
I'm using an SQLite3 database (with Python 2.5) and every so often the
application crashes or hangs because somewhere there is this error, or
something like it:
OperationalError: database is locked.
This is probably because I am viewing and sometimes changing the database
through SQLite Data
> I won't continue to divert this thread from good books, but I will continue
> to look
> for more and more tutorials and will post it The more the more merrier...
> Becky
Just on that topic of tutorials, have you seen www.ShowMeDo.com?
They have right now 516 screencast tutorials relat
> But the reason I ask this, is because there are SO many different approaches
> you could
> take to a single problem,
I guess that depends a lot on what sorts of problems you are thinking in terms
of. At least in many cases, perhaps one of the points of the Zen of Python is
useful:
"Ther
> My problem, though, is I still find it difficult to write meaningful code or
> use the built in libraries
> effectively and/or correctly because I can't find example code to mimic. I
> tried sifting through
> ActiveState recipes page, but most of the code seems uninteresting or useful
>
Thank you to all who replied. That does help me get a better
idea of all this. I think if I apply a number of the thoughts
expressed I can come to a good, readable re-do of these
longer functions.
Che
_
I have some functions that seem kind of long to me. One of them, with
white space, comments, print statements, and some commented-out lines,
is 118 lines long. If I remove all that, it is 57 lines long. I get the sense
that is inappropriately long for a Python function.
The length of it is d
> Date: Tue, 24 Nov 2009 10:27:05 -0600
> From: jammer10...@gmail.com
> To: tutor@python.org
> Subject: [Tutor] Class understanding
>
> Hi all... Have been attempting to understand classes... Been getting
> along without them for a while now and feel it's time to jump in
>
> What I want to
> That is a surprise to me. I did not know that Python would work with
SQLite.
Sure, as someone else said, Python comes with a LOT of libraries built right
in when you download Python. This is known as "batteries included", that is,
what comes with the standard distribution of Python.
>
Ken,
I would also recommend trying out databases, if you have an interest.
I found them a fun new aspect of using Python. I would recommend using
SQLite, which very conveniently comes with Python. Alan Gauld's
tutorial that you've read part of has a nice section on Working with Databases,
> It's working fine now, but actually I didn't write exactly what you
> suggested.
> The "commit" method belongs to the connection, not to the cursor. Therefore,
> in my script it should be conn.commit().
Whoops, you're quite right. Went a little too fast there. :D
Che
> I've got a functions that should update an sqlite database, among other
> things. However
> the database doesn't get updated. When used in isolation, the update
> statement works
> fine. What am I doing wrong?
> Below is the function. The whole script can be found at
> http://past
> In particular, I'm trying to run a simple prisoner's dilemma game, and
> I want to make a "game" object that has a method which returns the
> "game" object with the payoffs reversed; that is, the payoff matrix
> from the other player's point of view. Basically a kind of transpose
> wh
> programming language. The problem is, I don't know which to learn. I want a
> language
> that will be good for me to learn,
Good for you in what way? Is there a general "good for you" for programming,
or do you need to achieve a certain goal? From a jobs point of view, Java
seems prett
> I wrote this code but I know its wrong. Although it works properly:
> flips=0
> h='heads'
> t='tails'
> while True:
>flips+=1
>if flips>100:
>break
>if True:
>print(flips,'=',h or t)
> But
it prints every number with the string 'heads'. I'm really blank at
this. It
Date: Wed, 9 Sep 2009 15:52:53 -0400
From: krissy.amb...@gmail.com
To: tutor@python.org
Subject: [Tutor] wxpython question
Hi,
I'm not sure if I could ask questions about wx in this list or not, hopefully
it's okay? If not I guess disregard this question.
But, does anyone have any idea of if i
> I would like to make some simple plots using matplotlib (or any python
> plotting
> modules) and I can find lots of examples that generate random data and then
> plot those, but I cannot find any that read in data from excel or a text
> file,
> manipulate the data and then plot the data. D
> Start a CMD window and run the python command by typing the command
> at the DOS prompt.
>
> eg
>
> C:\Windows> python some\path\to\myscript.py
>
>
> That way you will still see the error message after the
> program finishes.
Or what about using IDLE?
_
> To: tutor@python.org
> From: alan.ga...@btinternet.com
> Date: Fri, 31 Jul 2009 17:09:48 +0100
> Subject: Re: [Tutor] mnemonics to better learn Python
>
>
> "Eduardo Vieira" wrote
>
> > Hello, would anybody have a good memorization technique for boolean
> > results? Like when using 'or'/'a
Did you actually look at what happens when you click that
link? (i.e. where you are brought to?).
Because upon viewing this I achieved enlightenment! :D
Date: Thu, 30 Jul 2009 10:02:39 +0200
From: zebr...@gmail.com
To: amit.pureene...@gmail.com
CC: tutor@python.org
Subject: Re: [Tutor] Curr
> > The "answer" to each function is then used in the next function.
> > I can think of two ways to make that answer available ...
> > 1) pass it in, or
> > 2) declare it as self.answer
Thank you Alan, Kent, and Dave. Full agreement, and it makes sense
to me. (Maybe this is also an example
This is another very basic structural question, related to one I asked last
week, and again is not necessarily germane only to Python.
Let's say you have a sequence of two calculations or manipulations you need to
do, each one done as a function called by an overall calculate_something()
funct
> I am scanning a text file and replacing words with alternatives. My
> difficulty
> is that all occurrences are replaced (even if they are part of another
> word!)..
Could you search for the string ' word ' with the white spaces around it?
Shouldn't
that only replace words that are not par
> From: fredp...@mac.com
> To: tutor@python.org
> Date: Sat, 25 Jul 2009 16:24:13 -0700
> Subject: [Tutor] Need to start learning again
>
> I started learning python, but then life got busy... I need some help
> finding good resources to start learning again.
>
> My main need for python at
> Date: Thu, 23 Jul 2009 14:05:36 +0800
> From: ld...@gmx.net
> To: Tutor@python.org
> Subject: [Tutor] mnemonics to better learn Python
>
> Dear List,
>
> in order to memorize which Python sequences are mutable or immutable, I
> focused on the SHAPE of the brackets that are associated with ea
> To: tutor@python.org
> From: alan.ga...@btinternet.com
> Date: Wed, 22 Jul 2009 08:46:04 +0100
> Subject: Re: [Tutor] code structure terminology and advice
>
>
> "Che M" wrote
>
> You pretty much answered your own question.
>
> The ultima
Hi, this is really more of a general programming question than a Python
question, though perhaps there is a Python-relevant set of terms/answers to
it... I'm trying to refactor some code to be more structurally "proper", more
easily maintained, etc. Doing some "thinking out loud", and I have t
So, I'm just wondering what I should be doing at this point. Sorry for the
vague question, but I'm pretty lost right now and this is about as specific as
I can be. Thanks in advance for any help.
Michae
I started from scratch a 3 years ago and my advice would be:
- Accept confusion. Marinate
> Date: Sat, 18 Jul 2009 01:09:32 +0200
> From: sander.swe...@gmail.com
> To: tutor@python.org
> Subject: Re: [Tutor] weather scraping with Beautiful Soup
>
> 2009/7/17 Che M :
> > table = soup.find("td",id="dataTable tm10")
>
> Almos
OK, got the very basic case to work when using Beautiful Soup 3.0.7a and
scraping the Weather Underground Lite page. That gives me the current
temperature, etc. Good.
But now I would like the average temperature from, say, yesterday. I am again
having trouble finding elements in the soup.
> 2009/7/17 Michiel Overtoom :
> > This is actually the first time I see that BeautifulSoup is NOT able to
> > parse a webpage...
>
> Depends on which version is used. If 3.1 then it is much worse with
> malformed html than prior releases. See [1] for more info.
>
> Greets
> Sander
>
> [1] htt
> Date: Fri, 17 Jul 2009 20:02:22 +0200
> From: mot...@xs4all.nl
> To: tutor@python.org
> CC: pine...@hotmail.com
> Subject: Re: [Tutor] weather scraping with Beautiful Soup
>
> Che M wrote:
>
> > "http://www.wund.com/cgi-bin/findweather/getForecast?query=Wo
> Date: Fri, 17 Jul 2009 08:09:10 -0400
> Subject: Re: [Tutor] weather scraping with Beautiful Soup
> From: ken...@tds.net
> To: pine...@hotmail.com
> CC: tutor@python.org
>
> On Thu, Jul 16, 2009 at 11:21 PM, Che M wrote:
> > Hi,
> >
> > I am interested
> Date: Fri, 17 Jul 2009 12:27:36 +0200
> From: mot...@xs4all.nl
> To: tutor@python.org
> CC: pine...@hotmail.com
> Subject: Re: [Tutor] weather scraping with Beautiful Soup
>
> Che M wrote:
>
> > The 60.3 is the value I want to extract.
>
> soup.find(&
> The posts basocally say go and look at the HTML and find the
> right tags for the data you need. This is fubndamental to any kind of web
> scraping, you need to understand the HTML tree well enough to identify
> where yourt data exists.
>
> How familiar are you with HTML and its structures?
R
Hi,
I am interested in gathering simple weather data using Beautiful Soup, but am
having trouble understanding what I'm doing. I have searched the archives and
so far haven't found enough to get me moving forward.
Basically I am trying to start off this example:
Grabbing Weather Underground
> From: jfabi...@yolo.com
> To: tutor@python.org
> Date: Wed, 18 Feb 2009 15:55:05 -0800
> Subject: Re: [Tutor] confused with dates and which way to start
>
> On Wednesday 18 February 2009 03:10:41 pm johnf wrote:
> > Hi,
> >
> > I need to develope a routine that will provide the some dates bet
> To: tutor@python.org
> From: alan.ga...@btinternet.com
> Date: Mon, 26 Jan 2009 10:13:15 +
> Subject: Re: [Tutor] clipboard questions
>
>
> "Che M" wrote
>
>> I'm curious about how to interact with the
I'm curious about how to interact with the contents of the clipboard
effectively and have a couple of questions...
1) Is there one cross-platform way to read the clipboard, or does one
have to have a different way to do it for Win, Mac, and Linux? (I have
seen some ways with the win32clipboard
> Date: Fri, 16 Jan 2009 21:26:52 -0800
> From: st...@alchemy.com
> To: pine...@hotmail.com
> CC: tutor@python.org
> Subject: Re: [Tutor] referring to subfolders
>
> Che M wrote:
>> I have been using absolute paths in my progr
I have been using absolute paths in my programs, but
want to get out of the habit as I try to run them on
other computers. I was surprised to find that this
type of reference didn't work:
path = '/subfolder/myfile.py'
But instead I did it this way and it works:
import os.path
self.currentdir =
Date: Thu, 15 Jan 2009 12:20:45 -0600
From: sri...@gmail.com
To: pine...@hotmail.com
Subject: Re: [Tutor] running & debugging in python interactive shel
CC: tutor@python.org
On Wed, Jan 14, 2009 at 8:18 PM, Che M wrote:
>> I'd like to add to this question and expand
> Date: Wed, 14 Jan 2009 16:44:11 -0800
> From: artie.z...@gmail.com
> To: tutor@python.org
> Subject: [Tutor] running & debugging in python interactive shell
>
> Greetings.
>
> I am attempting to search archives, however I thought it would be OK to
> ask while I search... thank you to those w
> I can't see any obvious reasons for your problems, I'm afraid, but I
> do have a comment on your SQL: the sqlite module supports using ? to
> indicate parameters. So you could rewrite your select statements as:
>
> cur.execute("select code from codes where code != '' and style = ? and
> start
> I'm quite willing to help on this, but it's just not quite
> clear enough what's happening. Can I suggest that you
> post a *really small, self-contained* example which demonstrates
> the problem you're having. You might actually realise what's
> wrong as you do that, or if not someone like me
(struggling to make an informative subject line)
Hi, I have what is no-doubt a dumb problem, but I can't get past it...
Given a list of items, I want to loop through the list, use the item in a
SELECT
statement to query an SQLite database, and use the returned data from a
.fetchall() to add
> However if all that one does is read and does no updates or deletes then you
> could just copy the database over to the 'client' user.
No, both DBs are going to be writing and updating.
Thanks, Chad.
Che
On Tue, Sep 9, 2008 at 6:56 PM, Che M <[EMAIL PROTECTED]> wrote:
> "Che M" <[EMAIL PROTECTED]> wrote in message
>
> > I'd like to get ideas about how I could extend the application so
> > that the
> > databases on each computer could be kept "synchronized"
>
> How do you intend to get the two
> > I'd like to get ideas about how I could extend the application so that the
> > databases on each computer could be kept "synchronized" (not sure that is
> > the right term here); that is, each new change on either computer would
> > be updated on the other computer(s), given a bit of help fr
Hi list,
I have been trying to create a small desktop application with Python
that uses a small SQLite database. Recently I've got use of a 2nd computer
(for my job) and have thought now about using the app on that one as well.
I'd like to get ideas about how I could extend the application s
Thank you both to Tim Golden and Jeff Younker for your helpful
responses last week [see archive] about ORMs in Python/SQLite. Very
helpful, and I'll get around to giving it a try one of these days...
Che
From: [EMAIL PROTECTED]
To: tutor@python.org
Subject: when is object relational mapping for
Hi Michael,
> Since my background is web, I want to learn Python and how it relates
> to the web. I have been told that I need to learn and understand the
> basics in "standard/general" Python before I move onto something like
> "django" but really, how much Python do I need to know before
(tried to write a descriptive subject line)
I'm curious whether I should consider learning either SQLObject
or SQLAlchemy, and whether my needs would be worth it. I am
learning to use SQlite databases for fairly simple storage and later
search, and have only recently learned about object relati
ED]> wrote:
> > On 17/05/2008, Che M <[EMAIL PROTECTED]> wrote:
> >> >>> datetime.datetime(2008, 05, 08)
> >> SyntaxError: invalid token
> >
> > It's simpler than that... Try this:
> >
> >>>> x = 08
> > File "&
From: [EMAIL PROTECTED]
To: tutor@python.org
Subject: datetime syntax error for May 8th and 9th 2008??
Date: Sat, 17 May 2008 00:09:03 -0400
Am I missing something? Why does May 7th
and other dates work but I'm getting "invalid
token" for May 8th and 9th? (I have not tested
many other
Am I missing something? Why does May 7th
and other dates work but I'm getting "invalid
token" for May 8th and 9th? (I have not tested
many other dates of the year in this way) This
is from a freshly begun IDLE session:
IDLE 1.2
>>> import datetime
>>> datetime.datetime(2008,05,07)
dateti
Thank you, everyone, for all the responses! I will wade through them and try
to get some understanding and then will no doubt come back with some questions
in some days. Much appreciated.
-Che
_
More immediate than e-mail? Get i
[I thought I sent a similar msg to this list 2 days ago, but now I'm not sure
it went through, so sorry if I've doubled]
Can someone point me to a start-from-dead-scratch tutorial about the basics of
web programming? I've been learning wxPython for GUI programming, but web
programming (that i
> I am thinking about writing a program which will involve, among other
> things, displaying a plot of a series of numbers. The idea is that
> you could click on the points and move them to change the numbers.
> Reverse-plotting, I suppose. It need not be complex; the numbers
> will
> From: [EMAIL PROTECTED]> To: tutor@python.org> Date: Sun, 23 Dec 2007
> 14:48:54 -0500> Subject: [Tutor] Py2Exe Tutorial> > > I am wondering if there
> is a good tutorial on Py2Exe and its functions?> I have not been able to find
> one. I have samples but that is not good> enough. It would be
> Date: Thu, 13 Dec 2007 01:58:10 -0600
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> CC: tutor@python.org
> Subject: Re: [Tutor] user-given variable names for objects
>
> Che M wrote:
> > I'm sure this is a classic beginner's topic, and I've re
> To: tutor@python.org
> From: [EMAIL PROTECTED]
> Date: Thu, 13 Dec 2007 07:53:36 +
> Subject: Re: [Tutor] user-given variable names for objects
>
>
> "Che M" <[EMAIL PROTECTED]> wrote
>
> > I'm sure this is a classic beginner's t
I'm sure this is a classic beginner's topic, and I've read a bit about it
online already, but I'd like to ask about it here as well. I want to assign
names to objects based on what a user inputs so that I can later keep track of
them.
In particular, I want to time multiple events by gett
Re: date matching with python and sqlite3
I sorry, maybe I am stupid at the moment but I cannot follow your
question,
I'm sorry, I didn't describe that too clearly...have coffee now, let's
try that again.
The user will have a choicebox that has options of "today", "this week",
"this mont
I'm trying to allow users to select data from an sqlite database using
Python by choosing either a date or a range of dates. I'm stuck at just
allowing the to select data that entered the database "today" and return
values from a column called duration. I have this mess at the moment:
#assume
> > Hi, I am curious about ways in Python to approach the idea of "tagging"
> > pieces of information much in the way that one can tag favorite websites
> > like on the site Del.icio.us. I'm not sure if tagging is the best term
>for
> > this (due to confusion with HTML tags), but the idea would
Hi, I am curious about ways in Python to approach the idea of "tagging"
pieces of information much in the way that one can tag favorite websites
like on the site Del.icio.us. I'm not sure if tagging is the best term for
this (due to confusion with HTML tags), but the idea would be a way to
ass
Thank you Alan and Roel for the insight, and Roel thank you for all the
suggested ways to get around it. It's always nice when something goes from
making no sense to making complete sense in a snap.
Che
_
Booking a flight? Know wh
Hi, I am trying to simply create an SQLite database with Python. I find
that when I try to create a new database file, *sometimes* it lets me do it,
and sometimes it doesn't, and the only thing I am changing is the name of
the database. I am baffled as to why some names appear to work and som
regarding making an executable file from a python file, Alan Gauld said:
>Assuming you are on Windows you can use py2exe but
>its non trivial to use. (Not hard, just not trivial)
>
>But first ask why you need to.
>I've been using Python for over 10 years now and never once needed
>to do this. (I d
gt;
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
reply-type=original
"Che M" <[EMAIL PROTECTED]> wrote
> Hi, searched a bit for this but haven't found much.
> Is it possible to use Python to monitor the use of
> other applicati
Hi, searched a bit for this but haven't found much. Is it possible to use
Python to monitor the use of other applications? (anything...Word, Excel,
browsers, etc.)
At minimum, I wan't to know that the application was running, but even
better would be some sense of the use or content, such as
I'm not sure what the whole indentation thing is for. And now I'm having
trouble with the if statement things.
Maybe your if statement troubles have been solved by others by now, but I'll
just add that "the indentation thing" is a vital feature of Python, it is
the way to separate code blocks
John Fouhy said:
Can you post the full error message (including stack trace and line
numbers) and the code for the last function in the stack trace?
(i.e. the code where the NameError occurs)
It is now working (so I won't post the code/errors unless you think it is
useful for people to see),
Hi. Alan G helped me a week or two back with how to pass a list of points
to a class which could use it to draw a graph.. Now I am doing it again,
but with different code (based on an example of embedding a matplotlib plot
in wxPython) and having trouble.
That same basic issue is: I need to
>Instead of using the class create an instance(aka object)
>
>self.plotPanel = PlotPanel(mypoints,self.notebook1)
>
>That creates an instance passing the mypoints list in
>to youir init method along with the notebook1 that you
>pass when you create an instance later (see below).
This wor
Thank you, Alan. I started by adding a method called addPoints() to my
class as you recommend. But now I don't know how to pass a list of points
to the addPoints() method. Here's the relevant code, adding in your
suggestions:
class PlotPanel(wx.lib.plot.PlotCanvas):
def __init__(self,
Hi, this is some *really* beginner Python stuff, hope you folks could help
me.
I've been trying to make basic plots (line graphs) using the pyplot module
(wx.lib.plot) in wxPython. So far, so good. To start, I can use a class
like this (adapted from a demo) to draw a pre-defined graph:
cla
I'd like to learn to use basic plotting in a wxPython GUI app,
with plots embedded in the GUI. Some questions about this:
1) Of pyplot or matplotlib, which might you recommend? My needs are:
- embedded plots in GUI (either can AFAIK)
- basic point/line/pie/bar graphs, regression lines, clickabl
Thank you Bob and Alan. That helps alot. I will store text as
files and index them somehow in the database (and yes Alan's
section on SQL on his site is a great resource for this). -Che
_
The average US Credit Score is 675. The cos
92 matches
Mail list logo