On Mon, May 25, 2015 at 11:11 PM, Steven D'Aprano st...@pearwood.info wrote:
Let's compare three methods.
def naive(a, b):
return math.sqrt(a**2 + b**2)
def alternate(a, b):
a, b = min(a, b), max(a, b)
if a == 0: return b
if b == 0: return a
return a * math.sqrt(1
On Sat, Aug 2, 2014 at 2:45 AM, Mark Summerfield l...@qtrac.plus.com wrote:
Last week I spent a couple of days teaching two children (10 and 13 -- too
big an age gap!) how to do some turtle graphics with Python. Neither had
programmed Python before -- one is a Minecraft ace and the other had
tools like this, but I am not
even sure what such a system is called. Is there anything like this, in python
preferably?
thanks,
Brian Blais
--
Brian Blais
bbl...@gmail.com
http://web.bryant.edu/~bblais
http://brianblais.wordpress.com/
--
http
?
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list
://mail.python.org/mailman/listinfo/python-list
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list
the former, as it will work even as you change versions,
etc... You should avoid using the shebang with a *specific* python version.
just use #!/usr/bin/env python
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com
these sorts of
models.
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list
')
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 13, 2010, at 12:30 PM, Godson Gera wrote:
On Mon, Dec 13, 2010 at 10:46 PM, Brian Blais bbl...@bryant.edu wrote:
Hello,
I was wondering if there is any standard or suggested way of installing
packages *without* going to the commandline. I often have students who,
from
) .bat file, but I didn't
want to reinvent the wheel. Perhaps there is a better way for me to do this,
ideally in a platform independent way.
thanks,
Brian Blais
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com
!
output:
yay!
yay too!
yay too!
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 13, 2010, at 1:31 AM, Dennis Lee Bieber wrote:
On Fri, 12 Nov 2010 20:48:34 -0500, Brian Blais bbl...@bryant.edu
declaimed the following in gmane.comp.python.general:
turtle.ondrag(turtle.goto)
turtle.pendown()
I'm not familiar with the turtle module but... would it make
On Nov 12, 2010, at 8:48 PM, Brian Blais wrote:
On Nov 12, 2010, at 8:05 PM, Steven D'Aprano wrote:
On Fri, 12 Nov 2010 19:24:50 -0500, Brian Blais wrote:
I'd like to draw on a turtle canvas, but use the mouse to direct the
turtle. I don't see a good way of getting the mouse
)
turtle.reset()
turtle.speed(0)
c=turtle.getcanvas()
c.bind(Button-1, gothere)
turtle.pendown()
but this seemed to draw in the wrong place (like the coordinates were wrong).
Is there a good way to do this?
thanks,
bb
--
Brian Blais
bbl...@bryant.edu
http
On Nov 12, 2010, at 8:05 PM, Steven D'Aprano wrote:
On Fri, 12 Nov 2010 19:24:50 -0500, Brian Blais wrote:
I'd like to draw on a turtle canvas, but use the mouse to direct the
turtle. I don't see a good way of getting the mouse coordinates and the
button state.
I think the right way
0xc2 in position 0: ordinal
not in range(128)
am I doing something stupid here?
of course, as a workaround, I can do: ''.join([c for c in s if ord(c)128])
but I thought the encode call should work.
thanks,
bb
--
Brian Blais
bbl...@bryant.edu
http
for two open source
projects that I own:
http://code.google.com/p/ssdf/
this is fantastic! what a great format! I've been looking for
something like this for quite some time.
thanks!
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http
.
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list
are a bit more irritating than just a print
2) in my quick-and-dirty scripts, I often want to get rid of all of
the prints after it works.
3) being able to redefine print vastly outweighs the irritation
caused by the extra parens
bb
--
Brian Blais
bbl...@bryant.edu
http
On Jun 27, 2010, at 22:37 , Red Forks wrote:
Read you doc file and set the __doc__ attr of the object you want
to change.
On Monday, June 28, 2010, Brian Blais bbl...@bryant.edu wrote:
I know that the help text for an object will give a description of
every method based on the doc string
,
Chris
so that gets back to my original question: can I change this text at
runtime. Doesn't look like I can, because it is defined for classes
rather than instances. Am I thinking about this correctly?
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
to be shown if one does: help(myobject)
thanks,
Brian Blais
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list
On Jun 10, 2010, at 4:28 , Gregory Ewing wrote:
Brian Blais wrote:
In this whole discussion, I haven't seen anyone mention wax (http://
zephyrfalcon.org/labs/wax_primer.html)
Just had a quick look at that. In the third example code box:
def Body(self):
self.textbox
guess that answers that one! :)
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list
Studio
to do it?
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list
://docs.python.org/tutorial/datastructures.html
which describes list comps, and didn't see any mention of this
behavior. it's probably there, but it certainly doesn't jump out.
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com
to other examples of using
multiprocessing, especially with games, would be fantastic.
thanks,
Brian Blais
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python
On Feb 13, 2010, at 12:54 , MRAB wrote:
Brian Blais wrote:
I've been thinking about implementing some simple games
Forget about global variables, they're not worth it! :-)
Think in terms of messages, sent via pipes, sockets or multiprocessing
queues.
okay...let's make this concrete
a button=-1 or something.
thanks,
Brian Blais
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list
, Jan 31, 2010 at 4:27 PM, Brian Blais bbl...@bryant.edu
wrote:
I'm on Python 2.5, but using the updated turtle.py Version 1.0.1 -
24. 9.
2009. The following script draws 5 circles, which it is supposed
to, but
then doesn't draw the second turtle which is supposed to simply move
forward. Any
)
self.turtle.fill(False)
self.turtle.penup()
for i in range(5):
c=Circle(randint(-350,350),randint(-250,250),10,red)
T=Turtle()
T.forward(100)
T.forward(100)
thanks,
bb
--
Brian Blais
bbl...@bryant.edu
http
the turtle can
travel? it seems I can keep moving off of the screen. Is there a
way to make it so that a forward(50) command, at the edge, either
raises an exception (at the wall) or simply doesn't move the turtle
because of the limit?
thanks!
bb
--
Brian Blais
bbl
for my students.
thanks,
Brian Blais
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list
places at the same time.
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list
,
Brian Blais
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
could possibly be used with some sort of random
behavior (if
rand()0.5 ...).
Drunkard's Walk.
yes, that was the kind of thing I was thinking about.
thanks!
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman
?
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
something wrong?
thanks,
Brian Blais
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
parameter)
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
*cos(t)
y=y0+0.1*sin(t)
if t==0: # first time calling
h=plot(x,y,'o')
else:
h[0].set_data(x,y)
draw()
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
.
Jean-Michel
I've heard notepad is pretty good. http://www.notepad.org/
I'm sorry, but ed is the standard editor[1]. :)
bb
[1] http://en.wikipedia.org/wiki/Ed_(text_editor)
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http
://wiki.python.org/moin/PythonEditors
and see how it works for you. Depending on what you need, and how
they feel, you may find what you want with a free editor.
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http
On Apr 19, 2009, at 4:35 , Hendrik van Rooyen wrote:
Brian Blais wrote:
On Apr 18, 2009, at 5:44 , Hendrik van Rooyen wrote:
to untangle some spaghetti code. He did not mention if
the spaghetti was actually doing it's job, bug free, which
IMO is the only rational test for the quality
, because the flow jumps around. It's not just about
aesthetics, but about being able to work with a piece of code.
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
.
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
won't work: it doesn't mutate the
objects at all. In the case of a list or a dict, then one can mutate
them, and the changes are seen in the caller. In both cases, the
object itself is passed the same way.
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu
already posted, by
running it directly from the commandline. Another hack is to put:
x=raw_input(pausing...)
at the end of your script, but this is really a hack and it would be
better to use a different solution.
bb
--
Brian Blais
bbl...@bryant.edu
http
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
with it.
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
to Perl's
CGI::Application?
Or would it just be better to roll my own?
I'd strongly suggest webpy (http://webpy.org/). It is easy, works
with CGI, FastCGI, etc... or you can run its own built-in server.
It's very nice!
bb
--
Brian Blais
bbl...@bryant.edu
http
around with the IDLE code
something easy, or a bit of a challenge?
thanks,
Brian Blais
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
to www.enthought.com and they have a single-download package
geared specifically for scientists.
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
normal(x):
return x/sqrt(x.sum())
or something like that.
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
.
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
/writing/snake-wrangling-for-kids/
it's specifically for Python, and geared for the age of your son.
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
. Not too
convenient, but I think it works.
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
details.
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
= unsortedList.sort()
In [3]:print sortedList
None
In [4]:print unsortedList
['ABC', 'XYZ']
or, better, just:
In [5]:unsortedList = list([XYZ,ABC])
In [6]:unsortedList.sort()
In [7]:print unsortedList
['ABC', 'XYZ']
bb
--
Brian Blais
[EMAIL PROTECTED
more, but
no copy
after this, my python process takes about 80 meg. names like
big_object are just names, and they reference an object in memory.
if you say a=big_object, you are saying that the name a should also
reference that same object.
bb
--
Brian
more, but
no copy
after this, my python process takes about 80 meg. names like
big_object are just names, and they reference an object in memory.
if you say a=big_object, you are saying that the name a should also
reference that same object.
bb
--
Brian
do mean the relative path my/path/way/...
# in current folder
as opposed to the absolute path: /my/path/way
# in root folder
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python
Matlab. I
haven't regretted it since.
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
also had to manually re-point python, pydoc,
idle, etc... in /usr/local/bin
Is there a reason for this, or is it just a small oversight on the
install script?
thanks,
Brian Blais
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu
it into a python dict.
It misses anything not a scalar, but you can easily modify it to
include arrays, etc... in the xml.
hope it's useful. certainly a neat site!
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
from __future__ import
matplotlib for the plots?
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
Is there a way to stream an unzip, so it behaves more like a file?
thanks,
Brian Blais
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
?
You: What is Eliza?
Eliza: Does that question interest you?
(http://www-ai.ijs.si/eliza/eliza.html)
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
would be avi, mov, and flv (for youtube videos).
thanks,
Brian Blais
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
,
author=Brian Blais,
ext_modules=[
Extension(myproject/train,[myproject/train.pyx]),
],
packages=['myproject'],
cmdclass = {'build_ext': build_ext}
)
and my project has one directory, myproject, with two files.
train.pyx is:
def func(blah):
print blah
and an __init__.py
Blais
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
out the mex documentation.
Or, you can use Python with numpy for matrices, and use Pyrex for the
c-extensions and make your life a *lot* easier.
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo
the point of the
while: all that power to check for conditions, and you just use it to
check True, and then use a break inside. It's readable, I guess, but
not a programming construct I am immediately drawn to.
Brian Blais
--
Brian Blais
[EMAIL PROTECTED]
http
say:
a=1
it is *really* a pointer to a 1-object, and that
b=1 points to the same 1-object.
In [4]:id(a)
Out[4]:25180552
In [5]:b=1
In [6]:id(b)
Out[6]:25180552
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http
customizable in Python? I can be more
specific about my requirements if that would help.
thanks,
Brian Blais
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
into
the development.
Any advice for this sort of thing?
Brian Blais
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
():
a=10
# comment at the end of the file
it seems like a comment at the end breaks the parse command, but not
parseFile. Is this reproducible by others?
am I doing something wrong?
thanks,
Brian Blais
--
Brian Blais
[EMAIL PROTECTED]
http
On Oct 21, 2007, at Oct 21:1:15 PM, Gabriel Genellina wrote:
En Sun, 21 Oct 2007 13:36:46 -0300, Brian Blais [EMAIL PROTECTED]
escribi�:
I am experiencing a problem with the compiler module. Is this a bug,
or am I doing something wrong?
I think it's a well-known fact...
it seems like
On Oct 21, 2007, at Oct 21:2:05 PM, Gabriel Genellina wrote:
The parseFile function does exactly that, along with this comment:
thanks!
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
, (id,name) in enumerate(result):
stringBuffer.write('''
tr class=%s
td%d/td
td%s/td
/tr
''' % (value,id,name)
value,other_value=other_value,value # swap the value
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
-
configuration files, is there a recommended procedure/place for these?
thanks,
Brian Blais
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
, so I'd like to learn how I am supposed to do it.
thanks,
Brian Blais
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
help me?
thanks,
Brian Blais
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
to have the headers from the source of tcl? I just don't want
to break something that is already there.
thanks!
bb
--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
On Jun 30, 2007, at 2:31 AM, felix seltzer wrote:
Does any one know of a good matlab interface?
I would just use scipy or numpy, but i also need to use
the matlab neural network functions. I have tried PyMat, but am
having
a hard time getting it to install correctly.
What problems are
,
Brian Blais
--
-
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
, and take out all of the non-pickleable objects? I could
replace them with something else (a tag of some sort, for me to reconstruct
things
later).
thanks,
Brian Blais
--
-
[EMAIL PROTECTED]
http://web.bryant.edu
such a wrapper. I wish I were more clever, and had more time,
to take
over the maintenance of wax because I think it is the most straightforward,
practical, and pythonic solution out there.
Do others think like me here?
thanks,
Brian Blais
fumanchu wrote:
On May 22, 6:38 pm, Brian Blais [EMAIL PROTECTED] wrote:
I'd like to start trying out some cherrypy apps, but I've
been having some setup problems. I think I need some
bone-head simple example to clear my understanding. :)
1) can I configure cherrypy to look at requests
fumanchu wrote:
No, you're not missing anything; my fault. I wasn't very awake when I
wrote that, I guess. Don't include the hostname, just write:
sn = '/~myusername/apps'
cherrypy.quickstart(Root(), sn, config)
yay! Thanks, that works perfectly.
bb
, and the two apps share it?
Are there any examples that show such a setup? I didn't see a CherryPy mailing
list,
so I'm posting here, but if there is somewhere else better I'd be glad to know!
thanks,
Brian Blais
two directories, and making a link to the
Part1
directory in the Part2 so I can import it. There must be a better way, yes?
thanks,
Brian Blais
--
-
[EMAIL PROTECTED]
http://web.bryant.edu
Carlos Hanson wrote:
It looks like you need __init__.py in MyPackage. Then you can import
starting with MyPackage. For example, you might use one of the
following:
import MyPackage
from MyPackage.Common import *
etc
that means that MyPackage must be in the sys path too? It
to a python function, so I can make the AdxList.OnUpdate call
python code.
Is there a tutorial somewhere about this stuff, or is there a proper place to
ask
such questions?
thanks,
Brian Blais
--
-
[EMAIL PROTECTED
people who have experience teaching programming
in
elementary/middle (or even high) school. Do graphical languages make a big
difference? Do text-based languages put up barriers to young learners? Is it
no big
deal either way?
thanks,
Brian Blais
,
Brian Blais
--
-
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
Jorge Vargas wrote:
On 2/20/07, Brian Blais [EMAIL PROTECTED] wrote:
I was wondering if there is a way to run CherryPy/Turbogears on a
server that I don't
have root access to.
I have never run ANY webapp as root. you should follow that advice. in
fact don't run any server as root.
Oh
to make changes...it took me a couple months
to get
them to upgrade to 2.4 from 2.3 last year, even when 2.5 was out.
thanks,
Brian Blais
--
-
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http
.
thanks,
Brian Blais
--
-
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais
--
http://mail.python.org/mailman/listinfo/python-list
, because then IDLE will not recognize it is
python
you are writing, and the right-click trick probably won't work either. You
should
never use Notepad, because it is just icky, and doesn't know about any
programming
languages. :)
Hope this helps,
Brian Blais
Dan Bishop wrote:
On Dec 14, 8:36 pm, Brian Blais [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
Then on your PC you can
run a script that loads each of such programs, and runs a good series
of tests, to test their quality...
What happens if someone-- perhaps
1 - 100 of 137 matches
Mail list logo