Hello, list.
I have a list of sentence in text files that I use to filter-out some data.
I managed the list so badly that now it's become literally a mess.
Let's say the list has a sentence below
1. "Python has been an important part of Google since the beginning,
and remains so as the system
http://mail.python.org/pipermail/python-list/2004-May/221591.html
HTH
--
http://mail.python.org/mailman/listinfo/python-list
Thank you for the quick reply.
Here're the exact code I executed. (including your code)
#!/usr/bin/env python
from pprint import pprint as pp
data = [
'foo bar baz',
'foo bar',
'foo',
'food',
'food', # duplicate
'xyzzy',
'plugh',
'xyzzy and plugh are magic',
'',
By eliminating list cloning, my function got much faster than before.
I really appreciate you, John.
def prefixdel_recursively2(alist):
if len(alist) < 2:
return alist
first = alist.pop(0)
unneeded = [no for no, line in enumerate(alist) if line.startswith(first)]
adjust=0
recursive-function to fix up my big-messed-list.
It stops immediately because of 'RuntimeError: maximum recursion limit exceeded'
I hope this trial-and-errors getting me good place...
anyway, thank you.
On 10/13/06, Peter Otten <[EMAIL PROTECTED]> wrote:
> js wrote:
>
> > By
Hi,
I've learned basics of Python and want to go to the next step.
So I'm looking for good python examples
I steal good techniques from.
I found Python distribution itself contains some examples in Demo directory.
I spent some time to read them and
I think they're good but seemed not so practica
Hi list,
I have a list of URL and I want to sort that list by the domain name.
Here, domain name doesn't contain subdomain,
or should I say, domain's part of 'www', mail, news and en should be excluded.
For example, if the list was the following
--
Thanks for your quick reply.
yeah, it's a hard task and unfortunately even google doesn't help me much.
All I want to do is to sort out a list of url by companyname,
like oreilly, ask, skype, amazon, google and so on, to find out
how many company's url the list contain.
--
http://mail.python.org/
> Gentle reminder: is this homework? And you can expect better responses
> if you show youve bootstrapped yourself on the problem to some extent.
Sure thing.
First I tried to solve this by using a list of domain found at
http://www.neuhaus.com/domaincheck/domain_list.htm
I converted this to a li
On 2 Oct 2006 08:56:09 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> js:
> > All I want to do is to sort out a list of url by companyname,
> > like oreilly, ask, skype, amazon, google and so on, to find out
> > how many company's url the list contain.
&
> How about sorting the strings as they are reversed?
>
> urls = """\
> http://mail.google.com
> http://reader.google.com
> http://mail.yahoo.co.uk
> http://google.com
> http://mail.yahoo.com""".split("\n")
>
> sortedList = [ su[1] for su in sorted([ (u[::-1],u) for u in urls ]) ]
>
> for url in so
I'm a great fan of regexp because it has great power and flexibility.
if you don't like it I suggest you to read "Mastering Regular Expressions".
http://www.oreilly.com/catalog/regex3/
Yes, sometimes it might be hard to understand bites you but
if you use it correctly, it works great.
On 18 Dec 2
Just my curiosity.
Can python beats perl at speed of grep-like processing?
$ wget http://www.gutenberg.org/files/7999/7999-h.zip
$ unzip 7999-h.zip
$ cd 7999-h
$ cat *.htm > bigfile
$ du -h bigfile
du -h bigfile
8.2Mbigfile
-- grep.pl --
#!/usr/local/bin/perl
open(F, 'bigfile
Hi list.
If I'm not mistaken, in python, there's no standard library to convert
html entities, like & or > into their applicable characters.
htmlentitydefs provides maps that helps this conversion,
but it's not a function so you have to write your own function
make use of htmlentitydefs, probabl
Thanks you Matimus.
That's exactly what I'm looking for!
Easy, clean and customizable.
I love python :)
On 6/5/07, Matimus <[EMAIL PROTECTED]> wrote:
> On Jun 4, 6:31 am, "js " <[EMAIL PROTECTED]> wrote:
> > Hi list.
> >
> > If I'm not m
Hi list.
I'm writing a tail -f like program in python
and I found file.read() doesn't work as I think it should.
Here's the code illustrating my problem.
###
#!/usr/bin/env python
import os, sys
filename = "test.out"
f = open(filename, "w+")
f.write("Hello")
f.flush()
f.seek(0, 2)
statinfo =
e:
> On Apr 22, 6:51 pm, "js " <[EMAIL PROTECTED]> wrote:
> > Hi list.
> >
> > I'm writing a tail -f like program in python
> > and I found file.read() doesn't work as I think it should.
> >
> > Here's the code illustrating
Hi Jesse.
> cmd_set = ['wget', '-nv', '-O dir/cpan.txt', 'http://search.span.org']
[snip]
>proc = Popen(cmd_set, stdout=PIPE, stderr=PIPE)
wget will treat this as
$ wget -nv '-O dir/cpan.txt' "http://search.cpan.org";
And will emit the following error because there's no pathname ' dir/cpan.txt'.
Hello, Yang.
You're not supposed to use os.open there.
See the doc at http://docs.python.org/lib/os-fd-ops.html
Is there any reason you want to use os.close?
On 20 May 2007 04:26:12 GMT, Yang
<[EMAIL PROTECTED]> wrote:
> Hi, I'm experiencing a problem when trying to close the file descriptor
> f
Hi Yang.
> Hi, thanks for your answer. Should I just use that object's close()
> method? Is it safe to assume that objects that have fileno() also have
> close()? (Statically typed interfaces would come in handy now.)
> I'm writing a simple asynchronous I/O framework (for learning purposes -
> I'm
Why not just use try?
Trying to import a module is a python idiom.
http://www.diveintopython.org/file_handling/index.html
On 21 May 2007 06:17:16 -0700, dmitrey <[EMAIL PROTECTED]> wrote:
> howto check does module 'asdf' exist (is available for import) or no?
> (without try/cache of course)
> Thx
Can someone help me find the proper way to do AES encryption/decryption
using Python?
Thanks!
--
http://mail.python.org/mailman/listinfo/python-list
HI guys,
How do you write Perl's
print a ... z, A ... Z, "\n"' in Python
In Python?
A way I came up with is the following, but I'm sure this is ugly.
''.join(chr(c) for c in (range(ord('a'), ord('z')+1) +
range(ord('A'), ord('Z')+1)))
or
crange = lambda c1, c2: [ chr(c) for c in
> But note that you return the last item of the range too, and that goes
> against the semantic of the usual Python range/xrange, so you may want
> to call this function with another name.
That makes sense. 100% agree with you.
> Maybe there are better ways to solve this problem. Maybe a way to
>
I forgot to cc pythonlist...
#
Thanks for you quick reply.
I didn't know any string constants.
>From Python Library reference, 4.1.1 String constants:
letters
The concatenation of the strings lowercase and uppercase described below.
The specific value is locale-dependen
> > Maybe we don't want char range If string constants would be rich
> > enough.
>
> But as soon as we want a string that doesn't correspond to any
> pre-defined constants, we're hosed. For example, there isn't
> a constant that would correspond to this Perl-ism:
>
> print l ... w, e ... j, L ..
The only way you can do is rermove python2.4.4's files manually.
I suggest you to use MacPorts or Fink.
With MacPort, you can uninstall python2.4 by doing
$ port uninstall python24
And Installation is
$ port install python25
On 24 Mar 2007 10:30:28 -0700, Robert Hicks <[EMAIL PROTECTED]> wrot
print ''.join([str(i) for i in [1,2,3]])
On 9/15/07, Summercool <[EMAIL PROTECTED]> wrote:
> i think in Ruby, if you have an array (or list) of integers
>
> foo = [1, 2, 3]
>
> you can use foo.join(",") to join them into a string "1,2,3"
>
> in Python... is the method to use ",".join() ? but the
How about using httplib?
http://docs.python.org/lib/httplib-examples.html
HTTPResponse has getheaders() method, too.
On 9/15/07, Johny <[EMAIL PROTECTED]> wrote:
> Can anyone provide an example how to find out the return code and
> header from an urllib2 request?
> For example
> response = url
Hi list.
Is there any module that is compatible with RFC-3986 or 2396, which is like
Perl's URI module(http://search.cpan.org/~gaas/URI-1.35/URI.pm)?
I like to normalize lots of URIs I've got in my database to make them
all unique ones.
Thank you in advance.
--
http://mail.python.org/mailman/l
>>> print u"äöü"
äöü
>>> print [u"äöü"]
[u'\xe4\xf6\xfc']
Python seems to treat non-ASCII chars in a list differently from the
one in the outside of a list.
I think this behavior is so inconvenient and actually makes debugging
work harder.
Is this an intentional? Is there any doc discussing about
Thank you for your quick reply.
> It's intentional. __str__ of a list uses the __repr__ of its
> elements. This helps reduce confusion (e.g., between ['a', 'b, c']
> and ['a, b', 'c']).
That's make sence, but it's also true that
sometimes we want to see the contents of a list in pretty format.
S
http://wiki.python.org/moin/WebApplications?highlight=%28%28PythonWikiEngines%29%29
Hope this helps
On 9/18/07, Kevin Ar18 <[EMAIL PROTECTED]> wrote:
>
> Are any of the following pieces of web software available in Python (under a
> non-copyleft license like BSD or MIT or Python license)?
>
>
>
How about using lock?
Let writing process locks the files before writing, and unlock after
the job's done.
I think it'd work file in most environment.
On 1/19/07, Tom Wright <[EMAIL PROTECTED]> wrote:
> I'm writing a program which reads a series of data files as they are dumped
> into a director
AFAIK, nothing.
How abount letting a browser do it?
By using pamie [1] or selenium, you can drive a browser from python.
[1] http://pamie.sourceforge.net/
On Feb 2, 2008 11:07 AM, J. Peng <[EMAIL PROTECTED]> wrote:
> hello,
>
> Which useragent lib supports javascript?
> I know something about the
And why the HELL people prefer answering this kind of question to
normal ones? (Including me...)
On Jan 31, 2008 9:40 AM, Blubaugh, David A. <[EMAIL PROTECTED]> wrote:
> I do not understand why no one has answered the following question:
>
> Has anybody worked with Gene Expression Programming
Hi,
I'm looking for a job queue manager in Python, like TheSchwartz.[1].
I found there's TheSchawrtz server, RPC server powered by Gearman,
to which Python/Ruby can connect [2], but setting up two languages env
is a little cumbersome to me.
Is there any alternative to that in Python?
The requirem
Cool, but sched saves job in memory...
cron can't be an option. It's just a scheduler not a job queue.
On Feb 7, 2008 1:36 AM, Larry Bates <[EMAIL PROTECTED]> wrote:
>
> js wrote:
> > Hi,
> >
> > I'm looking for a job queue manager in Python, like The
Hi,
I'm looking for RSS/ATOM generator I can use in Python.
I searched on pypi and the other places but I couldn't find any
options on this. (I found many parsers, though)
Is there any de-fact standard RSS/ATOM generator? (especially, I'd
like to create Atom's)
Do I have to do it myself from scrat
Trivial?
More than XML::Atom::Feed?
http://search.cpan.org/~miyagawa/XML-Atom-0.28/lib/XML/Atom/Feed.pm
On 2/14/08, Torsten Bronger <[EMAIL PROTECTED]> wrote:
> Hallöchen!
>
>
> Terran Melconian writes:
>
> > On 2008-02-11, js <[EMAIL PROTECTED]> wrote:
> &
Great...
I guess I should have learned more about ElementTree.
In anyway, Thanks all. You all convinced me, really.
On 2/14/08, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> Torsten Bronger wrote:
> > js writes:
> >
> >> Trivial?
> >> More than XML::A
Howdy,
I was wondering if there's official IRC channel for Python.
I tried #python irc.freenode.net and irc.openproject.net with no luck.
Could you please give me some suggestions?
--
http://mail.python.org/mailman/listinfo/python-list
Really? maybe I'm been blocked from it...
thanks.
On 23 Feb 2008 20:37:42 -0800, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> js <[EMAIL PROTECTED]> writes:
> > I tried #python irc.freenode.net
>
> That has always worked for me.
>
> --
&
No. Actually, i'm very new to IRC.
On Sun, Feb 24, 2008 at 2:55 PM, Steve Holden <[EMAIL PROTECTED]> wrote:
> js wrote:
> > Really? maybe I'm been blocked from it...
> > thanks.
> >
> Currently 479 users. Have you been blocked from many channels?
>
> You can't join #python on freenode without identifying with nickserv
> first.
Why is that?
I can join #perl, #php, #ruby, #mysql, #postgres without registration.
What advantage does it have? and the advantage really worth?
If #python were the developer's room, I'd say it's reasonable,
but that
I saw bad guys on IRC a few days ago, but it was not a problem
because Ignore user function in IRC client makes his/her messages invisible.
BTW,who's the maintainer of the channel?
On 27 Feb 2008 11:34:54 -0800, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> "Guilherme Polo" <[EMAIL PROTECT
I wonder why nobody mension Python Cookbook yet.
http://www.oreilly.com/catalog/pythoncook2/
Web version: http://aspn.activestate.com/ASPN/Cookbook/Python/
and Python Standard Library
http://www.oreilly.com/catalog/pythonsl/
http://effbot.org/zone/librarybook-index.htm
On Sun, Mar 2, 2008 at 4:09
Hi,
Have you ever seen Beautiful Python code?
Zope? Django? Python standard lib? or else?
Please tell me what code you think it's stunning.
--
http://mail.python.org/mailman/listinfo/python-list
Hi list,
Can I make TextWrapper keep line breaks in the text?
For example,
>>> s = "spam\nham"
>>> print wrap(s)
spam
ham
As far as I can tell, there seems no way to do this,
but before writing my own solution, I want to know whether
the solution already exists or not.
Thanks.
--
http://mail.
Hi Arnaud,
Great. Thanks for your help!
On Tue, Mar 11, 2008 at 10:27 AM, Arnaud Delobelle
<[EMAIL PROTECTED]> wrote:
>
> On Mar 10, 11:31 pm, js <[EMAIL PROTECTED]> wrote:
> > Hi list,
> >
> > Can I make TextWrapper keep line breaks in the text?
> >
Hi list,
I'm trying to build a package for python modules.
When I just wanted to have a package for Python2.5, this is an easy task,
but in most cases, it's not enough.
Sometimes I need python2.4, 2.5, 2.6 or 3.0 etc.
The problem is coming from the fact that python installs its modules
into versi
By "package", I meant APT, Ports for BSD, MacPorts, etc.
On Mon, Jun 16, 2008 at 1:16 AM, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On Mon, 16 Jun 2008 01:01:47 +0900, js <[EMAIL PROTECTED]> wrote:
>>
>> Hi list,
>>
>> I'm trying to bui
Thanks everyone for details.
I'll try stealing some of the good bits of python-central of debian
for my purpose.
On Mon, Jun 16, 2008 at 10:43 AM, Ben Finney
<[EMAIL PROTECTED]> wrote:
> Jean-Paul Calderone <[EMAIL PROTECTED]> writes:
>
>> >What has changed is that the tools in common use for Debi
Hi,
I'm writing a wrapper module of C API.
To make a C struct data avaiable to Python, I need to map C struct
into a PyObject.
I'm thinking that I use a tuple or dict to represent the struct
but a problem is one of the members of the struct is char **, which is
not supported by
Py_BuildValue.
Is t
I read an interview with Guido at
http://www.techworld.com.au/article/255835/a-z_programming_languages_python
and
that's very interesting.
In that article, he said
"there are also a lot of modules that aren't particularly well
thought-out, or serve only a very small specialized audience, or don't
PyString_AsString returns a c string. Just feed it to std::string
http://docs.python.org/api/stringObjects.html#l2h-472
On Tue, Sep 23, 2008 at 11:32 AM, <[EMAIL PROTECTED]> wrote:
> I have a PyObject, say 'Hello World' , a string,
> How do I convert it to a string in C++?
> Thanks in advance!
>
Hi list,
Is it possible to change module search path (PYTHONPATH) built-in to
Python interpreter?
I thought I can change it with configure --libdir but it didn't work for me.
I also tried patching around python source tree replacing lib to lib64
but it didn't work either.
Adjusting sys.path direc
wrote:
> On Sep 25, 10:41 am, js <[EMAIL PROTECTED]> wrote:
>> Hi list,
>>
>> Is it possible to change module search path (PYTHONPATH) built-in to
>> Python interpreter?
>> I thought I can change it with configure --libdir but it didn't work for me.
>&
In addition to that, .pth cannot prepend search path.
All thing it can do is appending to it.
In my case, I have to put lib64 before lib/.
On 9/26/08, js <[EMAIL PROTECTED]> wrote:
> For 64bit python, there's no need to look at lib/lib-dynload because
> libraries for 64bit sho
cmd won't recognize python at all I've checked several times , and I don't
understand what's wrong
Sent from Mail for Windows 10
--
https://mail.python.org/mailman/listinfo/python-list
I'd recommend starting with http://learnpythonthehardway.org/book/ by "Zed
Shaw" or Beginning Python Using Python 2.6 and Python 3.1 by "James Payne"
I'd say learning Python 2.6 would be better than 2.4, since it's really old.
--
http://mail.python.org/mailman/listinfo/python-list
61 matches
Mail list logo