Hmmm... interesting tie to another post...
x = timeit.Timer('random.random()','import random')
x.timeit(300)
1.0161026052194018
y = timeit.Timer('random()','from random import random')
y.timeit(460)
1.0004307810070827
Dictionary lookups do take HUGE amounts of time. Interesting.
At 05:13 AM 7/26/2007, Kent Johnson wrote:
For anyone who has wondered, how do I learn to write Python like an
expert? What do I read after I finish the tutorial? Check out David
Goodger's Code Like a Pythonista
http://python.net/~goodger/projects/pycon/2007/idiomatic/
Kent,
The handout is
Well, 'carpers' was my word but there is some truth to it. For example
this recent exchange:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/77285bd20fafbf2b/b0ffd482e925f0c0?hl=en#b0ffd482e925f0c0
which made it into QOTW in Python-URL, inspiring this rejoinder:
Sadly I can't think of a plan B, hence the frustration! Python, as far
as I know, is as good as it gets. And I don't have the courage or the
capability to improve it myself.
So all I can really do is clasp my hands together and helplessly plead:
Won't Somebody, Please, Think of the Children!
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Barton David wrote:
I mean no offense and lay no blame. It's simply that I feel like I've
been led up a nice gentle beach and suddenly I'm dodging boulders at the
bottom of a cliff.
I've learned to program with Python (and can hardly conceive
If it's any solace, there is a small minority of Python users who agree
with you. There *are* rough edges in the library modules and the library
docs. The great majority of Python users seem to find them good enough
and are pleased and amazed at what you can do with the batteries
included. A
Andreas Kostyrka wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Barton David wrote:
I mean no offense and lay no blame. It's simply that I feel like I've
been led up a nice gentle beach and suddenly I'm dodging boulders at the
bottom of a cliff.
I've learned to program with
Eric Brunson wrote:
It seems like new programmers today expect to be spoonfed their
information like they were in grammar school. They don't know what it
is to hack a Makefile to get a package to compile or break out an RFC to
understand a protocol. If you don't understand something and
*sigh* I'm really going off Python.
OK, thanks Andreas.
This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University
Hi,
I've hit a snag with Python's shelve module. By way of example...
_
from shelve import DbfilenameShelf as StoreFile
import os
sf=StoreFile(mytest.db,writeback=False) # but same problem if
writeback=True
for i in range(1):
sf[str(i)]=TESTOBJECT
sf.sync()
print len(sf)
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
That's in the nature of the underlying database library used for the
shelve. Most dbm implemention on Unix are using a sparse file that is
used as hashmap. E.g. compare ls -l versus du of the database file.
Now if this is the case, there is no way
Andreas Kostyrka wrote:
Additionally, the language core is very very thought out, with glacial
enhancements. Fixing the standard library OTOH would involve
renaming
and removing names, which would make huge collections of programs
break.
Not a good thing :(
Yes agreed. My comments there were
Barton David wrote:
*sigh* I'm really going off Python.
In what way is it Python's fault that the dbm database doesn't reclaim
disk space?
Kent
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
* Greg Lindstrom [EMAIL PROTECTED] [2007-07-26 13:44]:
Hello,
I am running python 2.4.2 on Gentoo Unix and am having problems running
programs. I have a script, hello.py as such:
#! /usr/bin/python
print 'hello, world'
that I save and add executable permission. Then at the prompt I
Just to follow up on what _my_ environment looks like (and the probable
cause in my case, anyway)
Security Options -
GRsecurity -
Executable Protections -
Trusted Path Execution (TPE)
CONFIG_GRKERNSEC_TPE:
If you say Y here, you will be able to choose a gid to add to the
supplementary groups of
...some credit. I taught myself to program, from scratch, without access
to (or time for) any courses whatsoever... 5 years now...core
language...certain standard modules pretty well... complaint...won't get
much further...without a computer science degree.
Wow. I'm so *shocked*.
Most
Barton David wrote:
*Eric Brunson* wrote:
It seems like new programmers today expect to be spoonfed their
information like they were in grammar school. They don't know what it
is to hack a Makefile to get a package to compile or break out an
RFC to
understand a protocol. If you
Hi,
I'm doing a little script with the help of the BeautifulSoup HTML parser
and uTidyLib (HTML Tidy warper for python).
Essentially what it does is fetch all the html files in a given
directory (and it's subdirectories) clean the code with Tidy (removes
deprecated tags, change the output to
Sebastien Noel wrote:
Hi,
I'm doing a little script with the help of the BeautifulSoup HTML parser
and uTidyLib (HTML Tidy warper for python).
Essentially what it does is fetch all the html files in a given
directory (and it's subdirectories) clean the code with Tidy (removes
deprecated
i've implemented a database as a shelve of record class instances. some of
the fields in each record are dictionaries.
i needed to parse info from 3 different reports into the dictionary fields
in each record instance. i wrote the code to do this and tinkered it to fit
the different reports (i.e.
Eric Brunson wrote:
Sebastien Noel wrote:
Hi,
I'm doing a little script with the help of the BeautifulSoup HTML parser
and uTidyLib (HTML Tidy warper for python).
Essentially what it does is fetch all the html files in a given
directory (and it's subdirectories) clean the code with
On Fri, 27 Jul 2007, Dick Moores wrote:
The handout is excellent! Thanks!
But the slideshow at
http://python.net/~goodger/projects/pycon/2007/idiomatic/presentation.html,
isn't.
You have to use the page-up and -down keys; or the spacebar (at least on
Windows under Firefox). Took me a
Barton David [EMAIL PROTECTED] wrote
I've learned to program with Python (and can hardly conceive of a
better
language to be honest)- and I still think the core language is
great:
elegant, easy to use and brilliantly documented.
Completely agree.
But the more I explore the standard
Eric Brunson [EMAIL PROTECTED] wrote
It seems like new programmers today expect to be spoonfed their
information like they were in grammar school.
I think its true they expect a lot of tutorial stuff, probably because
of the number of idiot guides to programming in languages like
VB/PHP etc.
On Fri, 27 Jul 2007, Kent Johnson wrote:
For navigation I use left and right arrows or mouse-over the
bottom-right of the screen to get a nav panel. But when I get to the
screen Whitespace 1 there is nothing but white space under the title.
Same here, but as I press the PgDn key (or the
One thing I don't think people realize, or at least don't talk about
often enough, is that good programming, like good art, takes talent.
I can draw a cat to make my 2yo happy or sketch my house well enough
that someone could pick it out driving down the street, but if I paint
every day for
Thanks a lot for this.
Someone on the comp.lang.python usenet channel also suggested using
BeautifulSoup with holding the content of a table for example,
extracting the table, than putting back the content. Also seems like a
good idea.
I will look at both possibilities.
Eric Brunson wrote:
Sebastien Noel [EMAIL PROTECTED] wrote
My question, since I'm quite new to python, is about what tool I
should
use to remove the table, tr and td tags, but not what's enclosed in
it.
I think BeautifulSoup isn't good for that because it removes what's
enclosed as well.
BS can do what you
Eric Brunson [EMAIL PROTECTED] wrote
newbie-friendly. My only complaint is that I'm starting to feel
like I
won't get much further than that without a computer science degree.
I'll disagree with you on that, if you can get a PhD in genetics
then
programming should be a snap...
I'm not
Terry Carroll wrote:
On Fri, 27 Jul 2007, Dick Moores wrote:
The handout is excellent! Thanks!
But the slideshow at
http://python.net/~goodger/projects/pycon/2007/idiomatic/presentation.html,
isn't.
You have to use the page-up and -down keys; or the spacebar (at least on
Windows
Man, the docs on the HTMLParser module are really sparse.
Attached is some code I just whipped out that will parse and HTML file,
supress the ouput of the tags you mention and spew the html back out.
It's just a rough thing, you'll still have to read the docs and make
sure to expand on some
Tiger12506 [EMAIL PROTECTED] wrote
Some people need degrees, most people don't. It all depends on what
they are
capable of understanding.
It also depends what they are doing.
Most programmers don't build complex state machines, nor do they
build safety critical systems. 90% or more of all
Luke Paireepinart wrote:
def place_robot():
global robot_x
global robot_y
global robot_shape
robot_y = random_between(0,47)-0.5
robot_x = random_between(0,63)-0.5
I'm not too clear why you're subtracting 0.5 here.
Doesn't this make the robot's center on the grid
Here is the code to deal with 1 given file (the code to iterate all the
files as working, and I will glue both together when the second one does
what I want.):
It's a little long, but I wanted to put it all so you maybe I can get
some tips to speed things up because it's pretty slow.
import
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Alan Gauld wrote:
Tiger12506 [EMAIL PROTECTED] wrote
Some people need degrees, most people don't. It all depends on what
they are
capable of understanding.
It also depends what they are doing.
Most programmers don't build complex state
Terry Carroll wrote:
On Fri, 27 Jul 2007, Kent Johnson wrote:
For navigation I use left and right arrows or mouse-over the
bottom-right of the screen to get a nav panel. But when I get to the
screen Whitespace 1 there is nothing but white space under the title.
Same here, but as I
Sebastien Noel [EMAIL PROTECTED] wrote
comments = soup.findAll(text=nbsp;)
[comment.extract() for comment in comments]
Umm, why comments here and not langcanada?
Just curious...
# Add some class attributes
for h1s in range(len(soup.findAll(h1))):
le_h1 = soup.findAll(h1)[h1s]
Andreas Kostyrka [EMAIL PROTECTED] wrote
was, that the only way to have more math courses would be to study
something with mathematics in the title *g*)
Thats true of most engineering courses.
Although I studied Electrical engineering the only compulsory subject
for each of the 5 years(if you
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Alan Gauld wrote:
Andreas Kostyrka [EMAIL PROTECTED] wrote
was, that the only way to have more math courses would be to study
something with mathematics in the title *g*)
Thats true of most engineering courses.
Although I studied Electrical
Hi,
now that I have a very basic understanding of Python I would like to
take a look at programming in a GUI. Which GUI is generally the easiest
to learn?
--
Your friend,
Scott
Sent to you from a Linux computer using Ubuntu Version 7.04 (Feisty Fawn)
scott wrote:
Hi,
now that I have a very basic understanding of Python I would like to
take a look at programming in a GUI. Which GUI is generally the easiest
to learn?
Easiest depends on your background. I was a Mac developer back in the
day, so WXPython was easy for me. If
cPickle/Pickle question is AFAIR documented,
But not in a manner totally clear to a newbie. An experienced
programmer will figure out that a C implementation is faster but
what does that meabn when your only reference is a few weeks
of Python? And why is there two modules if one is better?
Eric Brunson wrote:
Easiest depends on your background. I was a Mac developer back in the day,
so WXPython was easy for me. If you're a KDE programmer, then PyQT is
probably your cup of tee. Similarly, GTK programmers will probably like
PyGTK. I cannot make any statements about Tkinter,
At 12:02 PM 7/27/2007, Terry Carroll wrote:
On Fri, 27 Jul 2007, Dick Moores wrote:
The handout is excellent! Thanks!
But the slideshow at
http://python.net/~goodger/projects/pycon/2007/idiomatic/presentation.html,
isn't.
You have to use the page-up and -down keys; or the spacebar
As between Tkinter and wxPython, I started on Tkinter, but have been won
over to wxPython, although I've only played with it so far. The problem
with wxPython is that it's poorly documented, but there's a book out on it
now that you should beg, borrow or steal if you plan on using it.
Tiger12506 [EMAIL PROTECTED] wrote
As between Tkinter and wxPython, I started on Tkinter, but have
been won
over to wxPython, although I've only played with it so far.
I'm in transition. The problem I find with wxPython is the two-stage
create
widget/bind widget style and I find the layout
On Friday 27 July 2007 14:29, scott wrote:
Hi,
now that I have a very basic understanding of Python I would like to
take a look at programming in a GUI. Which GUI is generally the easiest
to learn?
You might want to check out Dabo (www.dabodev.com) which uses wxPython but
provides a
Eric Brunson wrote:
You seem like a smart guy that's having a bad day, so I'm cutting you
slack.
Thanks Eric. Yes I did indeed have a bad day (and it got much much worse),
and this is most definitely a case of a bad workman blaming his tools. I
apologise to all concerned for voicing my
os.path.exists(path) returns false when the path actually exists!
When I do this:
os.path.exists(c:\\winnt\\file_name)
I get this:
False
Actually the file exists in c:\winnt, and I can confirm it exists there, but
os.path.exists isn't returning True, when it should be..
Is this
Python is like democracy. It isn't perfect, but it's the best thing
come up with so far. ;-)
Barton David wrote:
Eric Brunson wrote:
You seem like a smart guy that's having a bad day, so I'm cutting you
slack.
Thanks Eric. Yes I did indeed have a bad day (and it got much much
Adam wrote:
From the library documentation:
Return True if path refers to an existing path. Returns False for
broken symbolic links. On some platforms, this function may return
False if permission is not granted to execute os.stat() on the
requested file, even if the path physically exists.
So
os.path.exists(path) returns false when the path actually exists!
When I do this:
os.path.exists(c:\\winnt\\file_name)
I get this:
False
Actually the file exists in c:\winnt, and I can confirm it exists
there, but os.path.exists isn't returning True, when it should be..
52 matches
Mail list logo