No, it turned out to be my mistake. Your code was correct and I
appreciate it very much.
Thank you again
On Sat, 27 Aug 2011 18:10:07 -0700, Emile van Sebille
wrote:
>On 8/27/2011 4:18 PM r...@rdo.python.org said...
>> Thank you so much. The code worked perfectly.
>>
>> This is what I tried us
Josh English wrote:
> OKB,
>
> The setup.py script created the egg, but not the .pth file. I
> created that myself.
>
> Thank you for clarifying about how .pth works. I know "redirect
> imports" was the wrong phrase, but it worked in my head at the
> time. It appears, at least on my system, tha
On Sun, 28 Aug 2011 00:19:07 -0400
Terry Reedy wrote:
> On 8/27/2011 11:45 PM, John O'Hagan wrote:
> > Somewhat apropos of the recent "function principle" thread, I was recently
> > surprised by this:
> >
> > funcs=[]
> > for n in range(3):
> > def f():
> > return n
> > funcs.
smith jack wrote:
i have heard that function invocation in python is expensive, but make
lots of functions are a good design habit in many other languages, so
is there any principle when writing python function?
for example, how many lines should form a function?
Once Abraham Lincoln was asked
On 8/27/2011 11:45 PM, John O'Hagan wrote:
Somewhat apropos of the recent "function principle" thread, I was recently
surprised by this:
funcs=[]
for n in range(3):
def f():
return n
funcs.append(f)
The last expression, IMO surprisingly, is [2,2,2], not [0,1,2]. Google tel
Somewhat apropos of the recent "function principle" thread, I was recently
surprised by this:
funcs=[]
for n in range(3):
def f():
return n
funcs.append(f)
[i() for i in funcs]
The last expression, IMO surprisingly, is [2,2,2], not [0,1,2]. Google tells me
I'm not the only one
On Aug 27, 2011, at 6:49 PM, Josh English wrote:
> When I run: os.listdir('c:\Python27\lib\site-packages') I get the contents in
> order, so the folders come before .pth files (as nothing comes before
> something.)
That's one definition of "in order". =)
> I would guess Python is using os.li
Julien wrote:
> What I'd like to achieve is:
>
d = {
> ... 'a': 1,
> ... 'b': 2,
> ... 'a': 3
> ... }
> Error: The key 'a' already exists.
>
> Is that possible, and if so, how?
Not if the requirements including using built-in dicts { }.
But if you are happy enough to use a custom cl
Hi,
With a simple dict, the following happens:
>>> d = {
... 'a': 1,
... 'b': 2,
... 'a': 3
... }
>>> d
{'a': 3, 'b': 2}
... i.e. the value for the 'a' key gets overridden.
What I'd like to achieve is:
>>> d = {
... 'a': 1,
... 'b': 2,
... 'a': 3
... }
Error: The key 'a' already ex
http://stromberg.dnsalias.org/svn/bufsock/trunk does it.
$ cat double-file
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
root:x:0:0:root:/roo
On 8/27/2011 4:18 PM r...@rdo.python.org said...
Thank you so much. The code worked perfectly.
This is what I tried using Emile code. The only time when it picked
wrong name from the list was when the file was named like this.
Data Mark Stone.doc
How can I fix this? Hope I am not asking too mu
On 8/27/2011 5:07 PM, Roy Smith wrote:
In article,
Terry Reedy wrote:
On 8/27/2011 1:45 PM, Roy Smith wrote:
In article<4e592852$0$29965$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano wrote:
open("file.txt") # opens the file
.read() # reads the contents of the fi
Hi
I created a python application which consists of multiple python files and a
configuration file. I am not sure, how can I distribute it.
I read distutils2 documentation and a few blogs on python packaging. But I
still have the following questions.
1. My package has a configuration file whic
On Sun, 28 Aug 2011 00:48:20 +0100, MRAB
wrote:
>On 28/08/2011 00:18, r...@rdo.python.org wrote:
>> Thank you so much. The code worked perfectly.
>>
>> This is what I tried using Emile code. The only time when it picked
>> wrong name from the list was when the file was named like this.
>>
>> Data
On 28/08/2011 00:18, r...@rdo.python.org wrote:
Thank you so much. The code worked perfectly.
This is what I tried using Emile code. The only time when it picked
wrong name from the list was when the file was named like this.
Data Mark Stone.doc
How can I fix this? Hope I am not asking too muc
On 8/27/11 3:41 PM, Josh English wrote:
> I have .egg files in my system path. The Egg file created by my setup script
> doesn't include anything but the introductory text. If I open other eggs I
> see the zipped data, but not for my own files.
Sounds like your setup.py isn't actually including
On 8/27/11 11:06 AM, Emile van Sebille wrote:
> from difflib import SequenceMatcher as SM
>
> def ignore(x):
> return x in ' ,.'
>
> for filename in filenames:
> ratios = [SM(ignore,filename,username).ratio() for username in
> usernames]
> best = max(ratios)
> owner = usernames[ra
On 8/27/11 3:21 PM, Emile van Sebille wrote:
> On 8/27/2011 2:57 PM Ben Finney said...
>> Emile van Sebille writes:
>>
>>> Code is first and foremost written to be executed.
>>
>
>
>> “Programs must be written for people to read, and only
>> incidentally for
>> machines to execute.”
>>
Thank you so much. The code worked perfectly.
This is what I tried using Emile code. The only time when it picked
wrong name from the list was when the file was named like this.
Data Mark Stone.doc
How can I fix this? Hope I am not asking too much?
import os
from difflib import SequenceMatche
In article ,
Emile van Sebille wrote:
> code that doesn't execute will need to be read to be understood, and
> to be fixed so that it does run.
That is certainly true, but it's not the whole story. Even code that
works perfectly today will need to be modified in the future. Business
requir
On Aug 27, 5:21 pm, Emile van Sebille wrote:
> On 8/27/2011 2:57 PM Ben Finney said...
>
> > Emile van Sebille writes:
>
> >> Code is first and foremost written to be executed.
>
> > “Programs must be written for people to read, and only incidentally for
> > machines to execute.”
> >
OKB,
The setup.py script created the egg, but not the .pth file. I created that
myself.
Thank you for clarifying about how .pth works. I know "redirect imports" was
the wrong phrase, but it worked in my head at the time. It appears, at least on
my system, that Python will find site-packages/fo
When I run: os.listdir('c:\Python27\lib\site-packages') I get the contents in
order, so the folders come before .pth files (as nothing comes before
something.) I would guess Python is using os.listdir. Why wouldn't it?
--
http://mail.python.org/mailman/listinfo/python-list
I have .egg files in my system path. The Egg file created by my setup script
doesn't include anything but the introductory text. If I open other eggs I see
the zipped data, but not for my own files.
Is having a zipped egg file any faster than a regular package? or does it just
prevent people fr
On 8/27/2011 2:57 PM Ben Finney said...
Emile van Sebille writes:
Code is first and foremost written to be executed.
“Programs must be written for people to read, and only incidentally for
machines to execute.”
—Abelson& Sussman, _Structure and Interpretation of Computer
Emile van Sebille writes:
> Code is first and foremost written to be executed.
−1 QotW. I disagree, and have a counter-aphorism:
“Programs must be written for people to read, and only incidentally for
machines to execute.”
—Abelson & Sussman, _Structure and Interpretation of Compute
Steven D'Aprano writes:
> >>> s = u'BIEBER FEVER \u2665'
> >>> print s # Printing Unicode is fine.
> BIEBER FEVER ♥
You're a cruel man. Why do you hate me?
--
\ “If nature has made any one thing less susceptible than all |
`\others of exclusive property, it is the action of the
On 27-Aug-11 11:53 AM, Hans Mulder wrote:
On 27/08/11 17:16:51, Colin J. Williams wrote:
What about:
cond= isinstance(left, PyCompare)
and isinstance(right, PyCompare)
and left.complist[-1] is right.complist[0]
py_and= PyCompare(left.complist + right.complist[1:])if cond
else: py_and = PyBoolea
In article <4e595334$0$3$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano wrote:
> and then there are languages with few, or no, design principles to speak of
Oh, like PHP?
--
http://mail.python.org/mailman/listinfo/python-list
In article ,
Terry Reedy wrote:
> On 8/27/2011 1:45 PM, Roy Smith wrote:
> > In article<4e592852$0$29965$c3e8da3$54964...@news.astraweb.com>,
> > Steven D'Aprano wrote:
> >
> >> open("file.txt") # opens the file
> >> .read() # reads the contents of the file
> >> .split("\n\n")
On 8/27/2011 1:15 PM r...@rdo.python.org said...
Hello Emile ,
Thank you for the code below as I have not encountered SequenceMatcher
before and would have to take a look at it closer.
My question would it work for a text file list of names about 25k
lines and a directory with say 100 files in
On Sun, Aug 28, 2011 at 6:27 AM, Steven D'Aprano
wrote:
> You've never noticed the masses of code written in text books, blogs, web
> pages, discussion forums like this one, etc.?
>
> Real world code for production is usually messy and complicated and filled
> with data validation and error checki
Chris Angelico wrote:
> On Sun, Aug 28, 2011 at 3:27 AM, Emile van Sebille wrote:
>> Code is first and foremost written to be executed.
>>
>
> +1 QOTW. Yes, it'll be read, and most likely read several times, by
> humans, but ultimately its purpose is to be executed.
You've never noticed the mas
On Aug 27, 2011, at 4:14 PM, Terry Reedy wrote:
> On 8/27/2011 2:07 PM, Philip Semanchuk wrote:
>>
>> On Aug 27, 2011, at 1:57 PM, Josh English wrote:
>>
>>> Philip,
>>>
>>> Yes, the proper path should be c:\dev\XmlDB, which has the
>>> setup.py, xmldb subfolder, the docs subfolder, and exampl
On 8/27/2011 2:07 PM, Philip Semanchuk wrote:
On Aug 27, 2011, at 1:57 PM, Josh English wrote:
Philip,
Yes, the proper path should be c:\dev\XmlDB, which has the
setup.py, xmldb subfolder, the docs subfolder, and example
subfolder, and the other text files proscribed by the package
developmen
Hello Emile ,
Thank you for the code below as I have not encountered SequenceMatcher
before and would have to take a look at it closer.
My question would it work for a text file list of names about 25k
lines and a directory with say 100 files inside?
Thank you once again.
On Sat, 27 Aug 2011
On 8/27/2011 9:42 AM, Jason Swails wrote:
P.S. I'll note that my "preferred" behavior is how python3.2 actually
operates
Python core developers agree. This is one of the reasons for breaking a
bit from 2.x to make Python 3.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/py
On Sun, Aug 28, 2011 at 6:03 AM, Terry Reedy wrote:
> yield para # or ''.join(para), as desired
>
Or possibly '\n'.join(para) if you want to keep the line breaks inside
paragraphs.
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
On 8/27/2011 1:45 PM, Roy Smith wrote:
In article<4e592852$0$29965$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano wrote:
open("file.txt") # opens the file
.read() # reads the contents of the file
.split("\n\n")# splits the text on double-newlines.
The biggest prob
Josh English wrote:
> Philip,
>
> Yes, the proper path should be c:\dev\XmlDB, which has the
> setup.py, xmldb subfolder, the docs subfolder, and example
> subfolder, and the other text files proscribed by the package
> development folder.
>
> I could only get it to work, though, by renaming th
HI,
Hi, I am trying to solve an equation containing both exp, log, erfc, and
they may be embedded into each otherBut sympy cannot handle this, as
shown below:
>>> from sympy import solve, exp, log, pi
>>>from sympy.mpmath import *
>>>from sympy import Symbol
>>>x=Symbol('x')
>>>sigma = 4
>>>m
On 8/25/11 1:54 PM, t...@thsu.org wrote:
> On Aug 25, 10:35 am, Arnaud Delobelle wrote:
>> You're close to the usual idiom:
>>
>> def doSomething(debug=None):
>> if debug is None:
>> debug = defaults['debug']
>> ...
>>
>> Note the use of 'is' rather than '=='
>> HTH
>
> Hmm, from
On Aug 27, 10:45 am, Roy Smith wrote:
> In article <4e592852$0$29965$c3e8da3$54964...@news.astraweb.com>,
> Steven D'Aprano wrote:
>
> > open("file.txt") # opens the file
> > .read() # reads the contents of the file
> > .split("\n\n") # splits the text on double-newlines.
>
> Th
On Aug 27, 2011, at 1:57 PM, Josh English wrote:
> Philip,
>
> Yes, the proper path should be c:\dev\XmlDB, which has the setup.py, xmldb
> subfolder, the docs subfolder, and example subfolder, and the other text
> files proscribed by the package development folder.
>
> I could only get it to
On 8/27/2011 10:03 AM r...@rdo.python.org said...
Hello,
What would be the best way to accomplish this task?
I'd do something like:
usernames = """Adler, Jack
Smith, John
Smith, Sally
Stone, Mark""".split('\n')
filenames = """Smith, John - 02-15-75 - business files.doc
Random Data - Adler J
Philip,
Yes, the proper path should be c:\dev\XmlDB, which has the setup.py, xmldb
subfolder, the docs subfolder, and example subfolder, and the other text files
proscribed by the package development folder.
I could only get it to work, though, by renaming the xmldb folder in the
site-packages
In article <4e592852$0$29965$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano wrote:
> open("file.txt") # opens the file
> .read() # reads the contents of the file
> .split("\n\n")# splits the text on double-newlines.
The biggest problem with this code is that read() slurp
On Sat, Aug 27, 2011 at 6:42 AM, Jason Swails wrote:
> Hello everyone,
>
> This is probably a basic question with an obvious answer, but I don't quite
> get why the type(foo).__name__ works differently for some class instances
> and not for others. If I have an "underived" class, any instance of
Josh English wrote:
> I have a development version of a library in c:\dev\XmlDB\xmldb
>
> After testing the setup script I also have
> c:\python27\lib\site-packages\xmldb
>
> Now I'm continuing to develop it and simultaneously building an
> application with it.
>
> I thought I could plug into m
On Sun, Aug 28, 2011 at 3:27 AM, Emile van Sebille wrote:
> Code is first and foremost written to be executed.
>
+1 QOTW. Yes, it'll be read, and most likely read several times, by
humans, but ultimately its purpose is to be executed.
And in the case of some code, the programmer needs the same t
greymaus wrote:
> On 2011-08-26, D'Arcy J.M. Cain wrote:
>> On 26 Aug 2011 18:39:07 GMT
>> greymaus wrote:
>>>
>>> Is there an equivelent for the AWK RS in Python?
>>>
>>>
>>> as in RS='\n\n'
>>> will seperate a file at two blank line intervals
>>
>> open("file.txt").read().split("\n\n")
>>
>
On 8/27/2011 9:41 AM Roy Smith said...
Chris Angelico wrote:
the important
considerations are not "will it take two extra nanoseconds to execute"
but "can my successor understand what the code's doing" and "will he,
if he edits my code, have a reasonable expectation that he's not
breaking stuf
On 27/08/2011 18:03, r...@rdo.python.org wrote:
Hello,
What would be the best way to accomplish this task?
I have many files in separate directories, each file name
contain a persons name but never in the same spot.
I need to find that name which is listed in a large
text file in the following f
On Aug 27, 2011, at 12:56 PM, Josh English wrote:
> (This may be a shortened double post)
>
> I have a development version of a library in c:\dev\XmlDB\xmldb
>
> After testing the setup script I also have c:\python27\lib\site-packages\xmldb
>
> Now I'm continuing to develop it and simultaneous
Hello,
What would be the best way to accomplish this task?
I have many files in separate directories, each file name
contain a persons name but never in the same spot.
I need to find that name which is listed in a large
text file in the following format. Last name, comma
and First name. The last n
(This may be a shortened double post)
I have a development version of a library in c:\dev\XmlDB\xmldb
After testing the setup script I also have c:\python27\lib\site-packages\xmldb
Now I'm continuing to develop it and simultaneously building an application
with it.
I thought I could plug into
On 2011-08-26, D'Arcy J.M. Cain wrote:
> On 26 Aug 2011 18:39:07 GMT
> greymaus wrote:
>>
>> Is there an equivelent for the AWK RS in Python?
>>
>>
>> as in RS='\n\n'
>> will seperate a file at two blank line intervals
>
> open("file.txt").read().split("\n\n")
>
Ta!.. bit awkard. :))
-
On Sun, Aug 28, 2011 at 2:41 AM, Roy Smith wrote:
> Forget about your successor. Will *you* be able to figure out what you
> did 6 months from now? I can't tell you how many times I've looked at
> some piece of code, muttered, "Who wrote this crap?" and called up the
> checkin history only to di
I am developing a library for Python 2.7. I'm on Windows XP. I am also learning
the "proper" way to do this (per PyPi) but not in a linear fashion: I've built
a prototype for the library, created my setup script, and run the install to
make sure I had that bit working properly.
Now I'm continu
Chris Angelico wrote:
> the important
> considerations are not "will it take two extra nanoseconds to execute"
> but "can my successor understand what the code's doing" and "will he,
> if he edits my code, have a reasonable expectation that he's not
> breaking stuff". These are always important.
In article ,
Arnaud Delobelle wrote:
> Hi all,
>
> I'm wondering what advice you have about formatting if statements with
> long conditions (I always format my code to <80 colums)
> [...]
> if (isinstance(left, PyCompare) and isinstance(right, PyCompare)
> and left.compl
On 27/08/11 17:16:51, Colin J. Williams wrote:
What about:
cond= isinstance(left, PyCompare)
and isinstance(right, PyCompare)
and left.complist[-1] is right.complist[0]
py_and= PyCompare(left.complist + right.complist[1:])if cond
else: py_and = PyBooleanAnd(left, right)
Colin W
On 27-Aug-11 03:50 AM, Hans Mulder wrote:
On 27/08/11 09:08:20, Arnaud Delobelle wrote:
I'm wondering what advice you have about formatting if statements with
long conditions (I always format my code to<80 colums)
Here's an example taken from something I'm writing at the moment and
how I've for
J wrote:
> Hi there,
>
> I'm attempting to print a dictionary entry of some twitter data to screen
> but every now and then I get the following error:
>
> (, UnicodeEncodeError('charmap',
> u'RT @ciaraluvsjb26: BIEBER FEVER \u2665', 32, 33, 'character maps to
> '), )
Showing the actual tracebac
Hi there,
I'm attempting to print a dictionary entry of some twitter data to screen but
every now and then I get the following error:
(, UnicodeEncodeError('charmap', u'RT
@ciaraluvsjb26: BIEBER FEVER \u2665', 32, 33, 'character maps to '),
)
I have googled this but haven't really found any w
On Sat, Aug 27, 2011 at 11:42 PM, Jason Swails wrote:
> I can't explain this behavior (since doesn't every class inherit from object
> by default? And if so, there should be no difference between any of my class
> definitions).
That is true in Python 3, but not in Python 2. That's why your exampl
Hello everyone,
This is probably a basic question with an obvious answer, but I don't quite
get why the type(foo).__name__ works differently for some class instances
and not for others. If I have an "underived" class, any instance of that
class is simply of type "instance". If I include an expli
Hi,
I released Oktest 0.9.0.
http://pypi.python.org/pypi/Oktest/
http://packages.python.org/Oktest/
Oktest is a new-style testing library for Python.
::
from oktest import ok, NG
ok (x) > 0 # same as assert_(x > 0)
ok (s) == 'foo'# same as assertEqual(s, '
Steven D'Aprano writes:
> I believe that PEP 8 now
Specifically the “Indentation” section contains::
When using a hanging indent the following considerations should be
applied; there should be no arguments on the first line and further
indentation should be used to clearly distingui
On Thursday, August 25, 2011 1:54:35 PM UTC-7, ti...@thsu.org wrote:
> On Aug 25, 10:35 am, Arnaud Delobelle wrote:
> > You're close to the usual idiom:
> >
> > def doSomething(debug=None):
> > if debug is None:
> > debug = defaults['debug']
> > ...
> >
> > Note the use of 'is' rat
On 27/08/11 11:05:25, Steven D'Aprano wrote:
Hans Mulder wrote:
[...]
It may look ugly, but it's very clear where the condition part ends
and the 'then' part begins.
Immediately after the colon, surely?
On the next line, actually :-)
The point is, that this layout makes it very clear that
On 27 August 2011 08:24, Steven D'Aprano
wrote:
> Arnaud Delobelle wrote:
>
>> Hi all,
>>
>> I'm wondering what advice you have about formatting if statements with
>> long conditions (I always format my code to <80 colums)
>>
>> Here's an example taken from something I'm writing at the moment and
On 27/08/11 05:45, Steven D'Aprano wrote:
> Thomas Jollans wrote:
>
>> On 26/08/11 21:56, Steven D'Aprano wrote:
>
>>> Is there any way to catch an exception and bind it to a name which will
>>> work across all Python versions from 2.5 onwards?
>>>
>>> I'm pretty sure there isn't, but I thought I
Hans Mulder wrote:
[...]
> It may look ugly, but it's very clear where the condition part ends
> and the 'then' part begins.
Immediately after the colon, surely?
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 26, 5:18 pm, Dave Boland wrote:
> I'm looking for a good IDE -- easy to setup, easy to use -- for Python.
> Any suggestions?
>
> I use Eclipse for other projects and have no problem with using it for
> Python, except that I can't get PyDev to install. It takes forever,
> then produces an
On 27/08/11 09:08:20, Arnaud Delobelle wrote:
I'm wondering what advice you have about formatting if statements with
long conditions (I always format my code to<80 colums)
Here's an example taken from something I'm writing at the moment and
how I've formatted it:
if (isinstance(left,
Arnaud Delobelle wrote:
> Hi all,
>
> I'm wondering what advice you have about formatting if statements with
> long conditions (I always format my code to <80 colums)
>
> Here's an example taken from something I'm writing at the moment and
> how I've formatted it:
>
>
> if (isinstance(
Hi all,
I'm wondering what advice you have about formatting if statements with
long conditions (I always format my code to <80 colums)
Here's an example taken from something I'm writing at the moment and
how I've formatted it:
if (isinstance(left, PyCompare) and isinstance(right, PyComp
On 27 August 2011 07:49, Peter Otten <__pete...@web.de> wrote:
> Arnaud Delobelle wrote:
>
>> Here is an extract from the dis module doc [1]
>>
>> """
>> RAISE_VARARGS(argc)
>> Raises an exception. argc indicates the number of parameters to the
>> raise statement, ranging from 0 to 3. The handler w
comp.lang.python · Discussions · + new post · About this group ·
Subscribe to this group. This is a Usenet group - learn more. View
this group in the new Google ...
http://123maza.com/65/purple505/
--
http://mail.python.org/mailman/listinfo/python-list
80 matches
Mail list logo