Jean-Paul Calderone wrote:
On Mon, 23 Mar 2009 05:30:04 -0500, Nick Craig-Wood
wrote:
Jean-Paul Calderone wrote:
[snip]
After bringing in all the heavy machinery of Twisted,
you're still polling at 10Hz. That's disappointing.
John Nag
Jean-Paul Calderone wrote:
On Tue, 24 Mar 2009 22:20:49 -0700, John Nagle wrote:
Jean-Paul Calderone wrote:
On Mon, 23 Mar 2009 05:30:04 -0500, Nick Craig-Wood
wrote:
Jean-Paul Calderone wrote:
[snip]
After bringing in all the heavy machinery of Twisted,
you're still polling at
ead. The basic
primitives are MsgSend, MsgReceive, and MsgReply, which do
about what you'd expect and do it very fast. Linux lacks
this.
If you're using CPython, don't worry about socket overhead.
CPython is so slow you'll never notice it.
John Nagl
7;m not going to put Python software out for public use again. I don't
have the time to deal with this crap.
John Nagle
Animats
--
http://mail.python.org/mailman/listinfo/python-list
mill NOW". Python doesn't do jobs
like that.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
am of mine is having a problem.)
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
That wasn't the problem. An incoherent bug report from a user
was the problem.
John Nagle
Carl Banks wrote:
On Apr 30, 11:48 am, John Nagle wrote:
def draininput(self) : # consume any queued input
try:
while True :
y thing that works reliably
is comparing the story text.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
".
CPython really is naive. That sort of thing should be a
compile-time optimization.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
acter u'\xae' in position 46:
ordinal not in range(128)
And we're downhill from there. Probably worth fixing, since it's one of the
few real-world HTML bugs that totally blows up BeautifulSoup.
John Nagle
SiteTruth
--
http://mail.python.org/mailman/listinfo/python-list
her item in our ongoing saga of "What happens when you parse real-world
HTML".
A try-block in handle_charref would be appropriate.
John Nagle
SiteTruth
--
http://mail.python.org/mailman/listinfo/python-list
e to compress the file down further.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
roblems of dealing with devices which may be
turned off and on or which may not send when wanted.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
"join".
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
;/tmp/result.txt') # do it
===
Note that this is ASCII-oriented; if you Unicode, you need
extra params to "connect". Also, the CSV module doesn't do
Unicode well as yet. Make sure the "outcsv" object
goes out of scope before you try to read the file, so the
file gets flushed and closed.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
ay, is per database handle, so if you have
multiple database handles, each needs to handle its own COMMIT needs.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
t behavior when faced with a site that wants authentication
is to to ask for a user name and password on standard input. This is
seldom what you want.
So subclass and overrride.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
) for func in func_strings]
What are you actually trying to do, anyway? What's the application?
You probably don't want to use "eval" that way. If you want function
objects out, use "compile".
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
I've actually hit it parsing big HTML
files with BeautifulSoup.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
r
"robots.txt" file set up that way.
There's no real "robots.txt" standard, unfortunately.
So it's not definitively a bug.
John Nagle
SiteTruth
--
http://mail.python.org/mailman/listinfo/python-list
rect time, every time. But that was in C++.
If you're trying to do hard real time in Python on Linux or Windows,
don't expect reliable timing. Remember, Python isn't really preemptive,
because of the global interpreter lock and the lack of thread priorities.
;t. It tends to do the wrong thing,
then leave things in a confused state. Too many things have to
be set up right before "easy install" works easily.
"python setup.py" is the de-facto standard.
Yes, there's no really good, standard solution for Python
install
tdict[mandict[manu]] = [] # make empty list
outdict[mandict[manu]].append(mandict) # append entry to list
You now have the desired result in a dictionary, which you can convert to a list
if you like.
If it's a production job, and the number of manufacturers is large,
you're probably better off using a database like MySQL, or some
mail merge program.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
like ordinary Python.
So there's no real need for an expression IF operator.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
ing instead.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
delay and try
again; don't let it get bigger than, say, 256 seconds. When a download
succeeds, halve the retry delay, but don't let it get smaller than 1 second.
That will make your downloader self-tune to the throttling imposed by
the server.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
; files, so you can
rename them, unpack them, and get at the good parts.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
round for
your distribution.
Note that if you use FCGI, don't put your FCGI scripts in a directory
enabled for CGI. Apache has a bias towards CGI, which is built in,
and will use CGI to run your FCGI scripts. Slowly.
John Nagle
--
http://mail.
)
While doing a simple grep:
grep '[^ "=]*/' input (input contains 156.000 a in
one row)
doesn't even take a second.
Is this a bug in python?
Thanks...
Henning Thornblad
You're recompiling the regular expression on each use.
Use "re.compile"
thon is usually troublesome. Python doesn't really have
quite enough isolation to run multiple unrelated instances reliably.
We use FCGI, which has the isolation of CGI but doesn't reload the
application for every transaction. Also, it's easier to debug if
CPython is crashing.
en extract the text content
of the "a" tag. The BeautifulSoup manual will tell you how.
If you want raw thesaurus data you can use freely, see
"http://wordnet.princeton.edu";.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
database
from multiple threads, until you have so many that the database
server starts to run out of resources.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
Martin v. Löwis, as
http://wiki.python.org/moin/CPythonVmInternals
That's interesting. It's dumber than I thought. All temporaries
on the stack are "boxed" as PyObjects. That's simple and portable,
but slow.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
d over and over again at run time by dictionary lookup.
This is simple, but there's a sizable speed penalty.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
ithin another def.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
nderstand the philosophy and design behind this.
Think about the implications of a language without real declarations
and it will come to you.
John Nagle
Animats
--
http://mail.python.org/mailman/listinfo/python-list
defn noob wrote:
How can I check how many cores my computer has?
Is it possible to do this in a Python-app?
Why do you care? Python can't use more than one of them at
a time anyway.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
27;ll have to see if PyPy 1.1 works.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
?
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
of Python objects)
then providing a "compile" operation which cranks out a .py file
with code to implement the state machine.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
(d,child) for child in d[node]])
else :
return([node])
getsubtree(d,min(d.keys())) # smallest node is assumed to be the root
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
e.split(",") # split into list at commas
fields = map(lambda(s) : s.strip(), fields) # strip whitespace
tcLst.append(TestCase(fields[0], fields[1:])) # pcap, then sids
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
d program to work around that.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
non-
> negative number n and returns a list of numbers from 0 to n. For
> example, upTo(3) should return the list [0, 1, 2, 3].
def howmany(n) :
return(range(n+1))
That should get you started.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
lp a multithreaded compute-bound process.
I'd recommend using Java or C# for new work in this area
if you're doing this in volume. Otherwise, you'll need to buy
many, many extra racks of servers. In practice, the big spiders
are in C or C++.
> http://www.immavista.com
t;eval", plus the ability to compile and include
new code at run time, so the useful facilities are already working.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
addition, you're not committing the database update.
You need to do
connection.commit()
after updating.
In general, server side programs should have a try-block
wrapped around most of the program, with some code to display or
log errors in some useful way.
d.join() # wait for thread to finish
totalcount += mythread.result # add to result
print "Total size of all tables is:", totalcount
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
programmers with about two years experience,
trying too hard to prove that they're cool.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
Gerardo Herzig wrote:
> John Nagle wrote:
>
>> Gerardo Herzig wrote:
> Thanks John, that certanly works. According to George's suggestion, i
> will take a look to the Queue module.
> One question about
>
> for mythread in mythreads:# for all
phical client, and play with
it a bit. Create a table, type in a few records, and
try various SELECT statements. That will give you a sense of how SQL works.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
is there a way to make the child
> processes terminate when the parent terminates?
>
> Thank you.
Put a thread in the child which reads stdin, and make stdin
connect to a pipe from the parent. When the parent terminates,
the child will get a SIGPIPE error and raise an exception.
>
Don't do that; Python doesn't have tail recursion and you'll hit the
stack limit.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
processline(line)
This works even in Python 2.4. I use this routinely for processing big
log files.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
into a single vendor solution, especially when they reserve the right
to start charging.
Their data store uses a subset of SQL, so it's probably possible
to write a conversion layer allowing use of MySQL.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
een working on a
revision of C++ since the 1990s, and that hasn't happened either.
The general consensus is that Python 3.x isn't much of an
improvement over the existing language. There's just not much
demand for it.
John Nagle
--
http://mail.p
error message. That may be
your first problem.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
mix them. Which
to use is ideological; mixing them is a bug.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
Python, so please bear with me.
>> Is there a way of guarenteeing that all created threads in a
>> program are finished before the main program exits?
>> I guess I'm doing something wrong with join().
Didn't we answer this question just a few days ag
effectively takes O(N*N) time.
Do your data structures need garbage collection? CPython is
a reference counted system with garbage collection as a backup
to catch cycles. Try using weak back-pointers in your data
structures to avoid creating cycles.
John Na
ng.
Which does not support Python.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
w one, as an atomic operation:
http://blogs.msdn.com/adioltean/archive/2005/12/28/507866.aspx
If you really want to update files in place, use a database, like
SQLite. If you find yourself rewriting big files for minor changes,
switch to a database. For small files, just r
latin1" if you want. This
might make sense if, for example, all your data is in French or German,
which maps well to "latin1". Unless that's your situation, go with
either all-ASCII or all-Unicode. It's less confusing.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
general, default values should be immutable constants only.
There's been talk of fixing this (it's really a design bug in Python),
but for now, it's still broken.
(I just had horrible thoughts about the implications of binding
a closure to a default argument. You don't wan
error from BeautifulSoup installation
> attempt:
easy_install usually seems to make things harder.
BeautifulSoup is one single .py file. That's all you need.
Everything else is excess baggage.
John Nagle
ent
> of python users don't have 2.5?
Desktop or server?
If server, check what the major Linux distros, like Fedora
Core, are shipping with.
Check major shared hosting providers to see what they're offering
to their customers as standard.
e" set to True. If you're going to run
the MySQL connection in Unicode, you should use "utf8" talking to the
database, and Unicode strings in Python. Otherwise, you have to
understand very clearly exactly how both Python and MySQL handle
character sets, and how this changes in Python 2.4, 2.5, and 3.x.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
BeautifulSoup.py
And yes, the site is up.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
Tim Golden wrote:
John Nagle wrote:
Mike Driscoll wrote:
Ken,
On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald
<[EMAIL PROTECTED]> wrote:
Sadly.
Thanks,
Ken
--
http://mail.python.org/mailman/listinfo/python-list
I've attached the 2.4 version. I also have some Windows b
fighting to get out from under
a mountain of mediocre libraries.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
a list of links to packages
elsewhere. There's no uniformity, no standard installation, no
standard uninstallation, and no standard version control.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
f ambiguity, refuse the temptation to guess.
Greg
Good point.
The problem is the typical one; Python did not originally
have a Boolean type, and the retrofit resulted in weird semantics.
C has the same issue.
John Nagle
--
http://mail.python.org/
modify BeautifulSoup to use weak pointers.
All the pointers towards the root and towards previous parts of the
document are "weak". As a result, reference counting alone is sufficient
to manage the tree. We still keep GC enabled, but it doesn't find much
to collect.
ould break.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
of a path name without checking with the underlying OS
to see if the file exists.
If, say, you're writing a GUI tool for setting up some configuration,
you'd want to do input validation on fields without actually
accessing the files.
John Nagle
--
http:
emember, any assignment to them in a global context makes them a global.
You should never get "None" from the queue unless you put a "None"
on the queue. "get()" blocks until there's work to do.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
s.
It doesn't validate the certificate chain. And those strings of
attributes you can get are ambiguious; data fields may contain unescaped
"/", which is the field separator. I went through this last year and
had to use M2Crypto, which is something of a headache but more or less works.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
ad a shell, which in turn will load Python.
Or, in Python, you can use "socket.gethostname()", which will
get you the host name used for networking purposes.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
ting a huge number of records, look into
LOAD DATA. It's much faster.
4. Your code will make 1 entries, then exit. Is that
what you want?
5. Creating a database of computed values is a useful exercise,
but not all that useful.
printed to stdout will be automatically converted from the
interpreter's internal Unicode representation to this legacy character set.
Python 5 is even stricter. Only ASCII (chars 0..127) can be sent
to standard output by default.
John Nagle
--
Find the font tags with findAll,
make a list, then go in and use "extract" and "replaceWith" appropriately.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
some restrictions on threading.
Only one thread at a time can use each connection to the database. But you
can create multiple connections to the same database at the same time from
a single program, and run them concurrently.
John Nagle
--
http://mail.python.
, take a look at it again.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
r.execute(sql, values) ## let SQL do the substitution
db.commit() ## commit transaction
1. The table names look different.
2. Did you commit the changes?
That, too.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
see I have done).
...
This guy wants people to spam for him to promote his $300 conference.
Don't support spammers. Boycott PyCon.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
installed the failed install, and reinstalled. On a new install,
the installer prompts for the destination dir, and that works.
Upgrade installs, though, are botched.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
quot;cgi" and tell Apache to use that for
FCGI.
FCGI is a good system; it's just that the documentation isn't
very good.This code has been running a live
web site for two years now.
John Nagle
#!/usr/local/bi
enough traffic that you need a multi-threaded web server,
it's probably time to move up.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
input,
I'd look at the USB to serial device. I've used devices with
the Silicon Laboratories CP2102 part, and they work fine.
("http://www.aetherltd.com/connectingusb.html";)
Do you have something plugged into the serial port? If
so, what?
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
It's just somebody pirating movies. Ineptly. Ignore.
John Nagle
yamamoto wrote:
Hi,
I am new to Python. I'd like to extract "a" tag from a website by
using "beautifulsoup" module.
but it doesnt work!
//sample.py
from Beautif
d that.
The language is fine, but the CPython implementation is obsolete.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
Nobody wrote:
On Fri, 15 Jan 2010 12:34:17 -0800, John Nagle wrote:
Actually, no. It's quite possible to make a Python implementation that
runs fast. It's just that CPython, a naive interpreter, is too primitive
to do it. I was really hoping that Google would put somebo
David Cournapeau wrote:
On Sun, Jan 17, 2010 at 4:17 AM, John Nagle wrote:
Nobody wrote:
On Fri, 15 Jan 2010 12:34:17 -0800, John Nagle wrote:
Actually, no. It's quite possible to make a Python implementation
that
runs fast. It's just that CPython, a naive interpreter, is too
pproach to collision response probably won't handle multiple
simultaneous collisions.
3. You're expecting others to debug your code.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
t's an automatically
updated static page.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
;s my classic "Obvious password detector":
http://www.animats.com/source/obvious/obvious.c
This prevents dictionary attacks using an English dictionary, but
needs only a small bit table and does no I/O.
John Nagle
--
http://mail.python.org/mailman/
pported by MySQLdb, OpenSSL, feedparser, etc.
Arguably, Python 3 has been rejected by the market. Instead, there's
now Python 2.6, Python 2.7, and Python 2.8. Python 3 has turned into
a debacle like Perl 6, now 10 years old.
That's the reality, Python 3 fanboys.
e search: "Results 1 - 10 of about 29,400 for psycopg2 crash".
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
ython.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
n warnings associated with
the feedparser module, but not that one. How do I get rid of that
one?
And no,
warnings.filterwarnings(action='ignore',
category=DeprecationWarning, module='sgmllib')
doesn't do it.
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
701 - 800 of 1270 matches
Mail list logo