[issue23448] urllib2 needs to remove scope from IPv6 address when creating Host header

2017-01-26 Thread Jonathan Guthrie

Jonathan Guthrie added the comment:

Michael Sweet's draft RFC requiring that the scope should be included in the 
Host line expired in May 2014 and I can't find where it ever went anywhere.  
Does anyone have any updated information?

--
nosy: +JonathanGuthrie

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23448>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29375] httplib: wrong Host header when connecting to IPv6 link-local address

2017-01-26 Thread Jonathan Guthrie

Jonathan Guthrie added the comment:

Yes, it is more closely related to Issue 23448.  My search for related issues 
apparently wasn't exhaustive enough.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29375>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29375] httplib: wrong Host header when connecting to IPv6 link-local address

2017-01-25 Thread Jonathan Guthrie

New submission from Jonathan Guthrie:

This is related to issue 5111.

An IPv6 link-local address must include a scope specifier as part of the 
address passed to the HTTPConnection or HTTPSConnection constructor, that scope 
specifier is not being stripped from the address passed in the HTTP 1.1 Host: 
header line.

So, suppose I was attempting to connect to an HTTP server on 
fe80::8aae:1dff:fea4:29c8.  That's a link-local address, so I must give the 
scope specifier, which is the interface I can use to connect to that address.  
So, the address I would pass to the HTTPConnection constructor might look like 
"fe80::8aae:1dff:fea4:29c8%eth0".  The appropriate Host line in the HTTP 
request would be "Host: [fe80::8aae:1dff:fea4:29c8]" but it is actually "Host: 
[fe80::8aae:1dff:fea4:29c8%eth0]"

Compliant HTTP servers reject requests including this line as malformed.

--
messages: 286276
nosy: JonathanGuthrie
priority: normal
severity: normal
status: open
title: httplib: wrong Host header when connecting to IPv6 link-local address
type: behavior
versions: Python 2.7, Python 3.5

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29375>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Strong typing vs. strong testing

2010-10-03 Thread guthrie
An interesting archive article on the topic of correctness, and the
layers thereof:

   Program verification: the very idea;
   Communications of the ACM
   Volume 31 ,  Issue 9  (September 1988)
   Pages: 1048 - 1063
   Year of Publication: 1988
   ISSN:0001-0782
The notion of program verification appears to trade upon an
equivocation. Algorithms, as logical structures, are appropriate
subjects for deductive verification. Programs, as causal models of
those structures, are not. The success of program verification as a
generally applicable and completely reliable method for guaranteeing
program performance is not even a theoretical possibility.

And:
   The proof of correctness wars;
Communications of the ACM  archive
Volume 45 ,  Issue 8  (August 2002)
COLUMN: Practical programmer Pages: 19 - 21
Year of Publication: 2002
ISSN:0001-0782
Whether mild or raging, wars about topics ranging from programming
languages to methods of indentation are healthy for our field

One central point in the discussions is that the correctness of a
(running) program is different than just that of a piece of code - it
also depends on the compiler, OS, and underlying hardware layers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Dynamically compiling and reloading SWIG .pyd file

2010-05-11 Thread Dave Guthrie
I am creating an application which has it's code split between python
and C. The Python is used to provide a high level GUI interface and
the C is for low level functions. I use SWIG to create Python Bindings
for the C functions. I want to implement a feature where there is a
button in the toolbar of the GUI which will automatically compile the
C code into a .pyd file. The problem I have is when the GUI is
running, the .pyd is loaded as a DLL and thus is locked by the GUI, so
I can't get gcc to overwrite the .pyd file.

I have tried to force the GUI to close it's handle on the file

handle =
ctypes.windll.kernel32.GetModuleHandleA(_FirmwareSubSys.pyd)

if handle == 0:
print _FirmwareSubSys.pyd not loaded
else:
_ctypes.FreeLibrary(handle)

But by doing this the next time I load the DLL python crashes.

Do anyone know how to dynamically compile and load SWIG Python
Bindings?
-- 
http://mail.python.org/mailman/listinfo/python-list


python interface to Yahoo groups?

2009-12-29 Thread guthrie
I'm looking for something to monitor  download yahoo group messages
using Python, similar to the Perl module WWW::Yahoo::Groups.

I've seen a few comments (speculations?) that Yahoo groups uses Python
code, but couldn't find any examples of samples of such access tools.

Any references or pointers appreciated.
-- 
http://mail.python.org/mailman/listinfo/python-list


py-rrdTool - install fails

2009-08-14 Thread guthrie
I want to do some rrd in a python cgi script, but am having trouble
getting an easy install module.

py-rrdTool looks good, but is distributed in c source, and is missing
a header file in the distribution. Thus the install fails when it
tries to reference rrd.h which is not there.

Are there better rrd modules to use, or a compiled version of this, or
other suggestions?
--
building 'rrdtool._rrdtool' extension
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /
Ox /MD /W3 /GS- /DNDEBUG -I/usr/local\include -IE:\PLang\Active Python
\include -IE:\PLang\Active Python\PC /Tcsrc/_rrdtoolmodule.c /
Fobuild\temp.win32-2.6\Release\src/_rrdtoolmodule.obj
_rrdtoolmodule.c
src/_rrdtoolmodule.c(34) : fatal error C1083: Cannot open include
file: 'rrd.h': No such file or directory
error: command 'C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN
\cl.exe' failed with exit status 2

C:\Documents and Settings\guthrie\Desktop\py-rrdtool-0.2.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: py-rrdTool - install fails

2009-08-14 Thread guthrie
On Aug 14, 3:39 pm, Christian Heimes li...@cheimes.de wrote:
 guthrie schrieb:



  I want to do some rrd in a python cgi script, but am having trouble
  getting an easy install module.

  py-rrdTool looks good, but is distributed in c source, and is missing
  a header file in the distribution. Thus the install fails when it
  tries to reference rrd.h which is not there.

  Are there better rrd modules to use, or a compiled version of this, or
  other suggestions?
  --
  building 'rrdtool._rrdtool' extension
  C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /
  Ox /MD /W3 /GS- /DNDEBUG -I/usr/local\include -IE:\PLang\Active Python
  \include -IE:\PLang\Active Python\PC /Tcsrc/_rrdtoolmodule.c /
  Fobuild\temp.win32-2.6\Release\src/_rrdtoolmodule.obj
  _rrdtoolmodule.c
  src/_rrdtoolmodule.c(34) : fatal error C1083: Cannot open include
  file: 'rrd.h': No such file or directory
  error: command 'C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN
  \cl.exe' failed with exit status 2

  C:\Documents and Settings\guthrie\Desktop\py-rrdtool-0.2.1

 rrd.h is part of the rrdtools. You need to install rrdtools plus all its
 dependencies. Have a lot of fun ;)

 Christian

Thanks;
I got py-rrttool-0.2.1 from sourceforge, but in its src directory it
has only 3 files,
  _rrdtoolmodule.c, rrd_extra.h, and rrd_format.h

   http://sourceforge.net/projects/py-rrdtool/files/py-rrdtool/0.2.1/

(same for site: http://www.nongnu.org/py-rrdtool/ )

Where should I be looking for other dependencies?

I installed rrdtools.exe, and don't see any rrd.h file in that
hierarchy.
-- 
http://mail.python.org/mailman/listinfo/python-list


run all scripts in sub-directory as subroutines?

2009-08-11 Thread guthrie
I want to have a program which will form a list of all *.py scripts in
a sub-directory, and then call some standard messages on them. So I
can add a new data source modularly by just dropping a new file into
the sources directory with the appropriate methods in it.

For example:

path = sys.path[0]
print Starting Directory::  + path

getDir=path + \Sources# point to directory of data
sources
for name in os.listdir(getDir): # run collection from each source
src = imp.load_source(data,getDir,open(getDir+\\+name, 'rb'))
src.getData()
src.doGraph()

This works fine, but in the sub-modules the sys.path appropriately
returns the same as from the parent, I want them to know their own
file names. How?? I can pass it to them, but wondered if there is a
more self-sufficient way for a module to know from where it was
invoked.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: generator expression works in shell, NameError in script

2009-06-21 Thread guthrie
On Jun 18, 11:28 pm, greg g...@cosc.canterbury.ac.nz wrote:
 nn wrote:
  This is certainly an odd one. This code works fine under 2.6 but fails
  in Python 3.1.

 class x:

  ...     lst=[2]
  ...     gen=[lst.index(e) for e in lst]

 In 3.x it was decided that the loop variables in a list
 comprehension should be local, and not leak into the
 surrounding scope. This was implemented by making the
 list comprehension into a nested function.

 Unfortunately this leads to the same unintuitive
 behaviour as a genexp when used in a class scope.

-- I don't get this - the only local loop variable is e, not lst.
And lst is used twice in the generator expression, which is being
complained about?

It would generally be the case that a nested function would have
access to its enclosing scope.

In any case, even if/when the current behavior is explained or
rationalized, it certainly appears un-intuitive, and that is another
level of error! :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: generator expression works in shell, NameError in script

2009-06-18 Thread guthrie
On Jun 17, 6:38 pm, Steven Samuel Cole steven.samuel.c...@gmail.com
wrote:
 Still don't really understand why my initial code didn't work, though...

Your code certainly looks reasonable, and looks to me like it should
work. The comment of partial namespace is interesting, but
unconvincing (to me) - but I am not a Python expert! It would
certainly seem that within that code block it is in the local
namespace, not removed from that scope to be in another.

Seems that it should either be a bug, or else is a design error in the
language!

Just as in the above noted WTF - non-intuitive language constructs
that surprise users are poor design.


-- 
http://mail.python.org/mailman/listinfo/python-list


python list pattern matching?

2009-05-28 Thread guthrie
I want to do a functional like pattern match to get teh first two
elements, and then the rest of an array return value.

For example, assume that perms(x) returns a list of values, and I want
to do this:
seq=perms(x)

a = seq[0]
b = seq[1]
rest = seq[2:]
Of course I can shorten to:
[a,b] = seq[0:2]
rest  = seq[2:]

Can I find use some notation to do this?
[a,b,more] = perms(x)
or conceptually:
[a,b,more..] = perms(x)

PROLOG  functional languages do list decomposition so nicely like
this!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python list pattern matching?

2009-05-28 Thread guthrie
Many thanks to all; perfect solution!
-- 
http://mail.python.org/mailman/listinfo/python-list


list comprehension syntax..?

2006-08-01 Thread Gregory Guthrie
Sorry for a simple question- but I don't understand how to parse this use of 
a list comprehension.

The or clauses are odd to me.

It also seems like it is being overly clever (?) in using a lc expression as 
a for loop to drive the recursion.

Thanks for any insight!
Gregory
-

#  http://markbyers.com/moinmoin/moin.cgi/ShortestSudokuSolver

def solve(board):
 i=board.find('0')  # find next open cell
 if i0:# done if none...
 print board; exit(Done)
 [ m in [(i-j)%9*(i/9^j/9)*(i/27^j/27|i%9/3^j%9/3)
  or board[j] for j in range(81) ]
 or solve(board[:i]+m+board[i+1:]) for m in'%d'%5**18 ] 



== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list comprehension syntax..?

2006-08-01 Thread Gregory Guthrie
Very helpful, thanks!!

So I see that it parses as:


  m='1'
  a=asdf
  b=1234
  print [((m in a) or b) for m in '%d'%1234 ]


I get it.
Thanks,
Greg


Duncan Booth [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Gregory Guthrie wrote:

 Sorry for a simple question- but I don't understand how to parse this
 use of a list comprehension.

 The or clauses are odd to me.

 It also seems like it is being overly clever (?) in using a lc
 expression as a for loop to drive the recursion.

 You are spot on there. It is a list comprehension, but the resulting list
 is just thrown away, so using a list comprehension is a complete waste of
 time serving only to confuse the issue. Presumably it saved the author a
 character or two.

 [ exp for var in seq ]

 when the result isn't used can be rewritten as:

 for var in seq:
   exp

 and:

   exp1 or exp2

 when the result is thrown away is just:

   if not exp1:
   exp2


 So:

 [ m in [(i-j)%9*(i/9^j/9)*(i/27^j/27|i%9/3^j%9/3)
  or board[j] for j in range(81) ]
 or solve(board[:i]+m+board[i+1:]) for m in'%d'%5**18 ]

 is equivalent to:

 inner = [(i-j)%9*(i/9^j/9)*(i/27^j/27|i%9/3^j%9/3) or board[j] for j in
 range(81) ]
 for m in '3814697265625':
if m not in inner:
 solve(board[:i]+m+board[i+1:])

 (That inner list comprehension doesn't depend on m, so it doesn't need to
 be reevaluated each time round the loop except, again, to save a few
 characters.)

 The '%d'%5**18 looks to be a silly way to iterate through all possible
 digits for m even though it does some of them twice while saving one
 character over writing range(1,10).

 The strange expression I called 'inner' is a list containing the string
 value board[j] if j is in the same row, column or block as i, or an 
 integer
 for any other cells. So 'm not in inner' is true only if the value for m 
 is
 not already used in that row column or block and is therefore a possible
 candidate for that location in the board. 



== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Language Design: list_for scope?

2006-07-21 Thread guthrie
I'm pretty new to Python, and trying to parse the grammar.

Q: What is the scope of the testlist in a list_for?

For example;
Instead of;
  for x in [ x in dict if dict[x]==thing ]:
in this:
  for x in dict and dict[x]==thing:
x is undefined.

And why doesn't this work:
for x in dict if dict[x]==thing:

Any insights/hints on why it is broken?

Thanks,
Gregory

http://docs.python.org/ref/grammar.txt:
list_for ::=
  for expression_list in testlist
   [list_iter]
testlist ::=
  test ( , test )* [ , ]
list_iter ::=
  list_for | list_if
list_if ::=
  if test [list_iter]


== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Language Design: list_for scope?

2006-07-21 Thread guthrie


Larry Bates wrote:

 First things first:
 
 Don't name a variable dict because if you do it shadows
 the built in dict function (same goes for list, str, ...).
 This WILL bite you later, so start now by not naming
 variables by any built in names.
-- Thanks, got it!
 
 Now to your question:
 
 for x in something: requires something be an iterable
 (e.g. list, tuple, iterable class instance, etc) so there
 is something that it can loop over one object at at time.
 
 
for x in [ x in dict if dict[x]==thing ]:
 
 
 needs to be written (if I'm understanding what you are
 doing) as:
 
 for x in [x for x in d if d[x]==thing]:
-- Ywes, I understand the syntax, but think it is repetitive and cumbersome.

Just note the for x in x for x in ...
   no new semantics of the desired iteration set given, all redundant 
syntax.

I still wonder why one cannot qualify a for list iteration object with 
an list_if

Greg


For example;
Instead of;
 for x in [ x in dict if dict[x]==thing ]:
in this:
 for x in dict and dict[x]==thing:
x is undefined.

And why doesn't this work:
for x in dict if dict[x]==thing:

Any insights/hints on why it is broken?

Thanks,
Gregory

http://docs.python.org/ref/grammar.txt:
list_for ::=
 for expression_list in testlist
  [list_iter]
testlist ::=
 test ( , test )* [ , ]
list_iter ::=
 list_for | list_if
list_if ::=
 if test [list_iter]


== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =


== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


array alice of [:-0] ??

2006-07-18 Thread guthrie
Beginner question! :-)

x=[1,2,3,4]
for i in range(len(x)):
print x[:-i]

  []
  [1,2,3]
  [1,2]
  [1]

1) The x[:-0] result seems inconsistent to me;
 I get the idea that -0=0, so it is taken as x[:0] - []
2) how then should one do this basic left-recursive subsetting (easily).

Thanks.


== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: array slice of [:-0] ??

2006-07-18 Thread guthrie
Thanks all!!
-

guthrie wrote:

 Beginner question! :-)
 
 x=[1,2,3,4]
 for i in range(len(x)):
print x[:-i]
 
   []
   [1,2,3]
   [1,2]
   [1]
 
 1) The x[:-0] result seems inconsistent to me;
 I get the idea that -0=0, so it is taken as x[:0] - []
 2) how then should one do this basic left-recursive subsetting (easily).
 
 Thanks.
 


== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


language design question

2006-07-09 Thread Gregory Guthrie
I am comparing Python to a few other scripting languages, and used a simple 
anagrams program as a sample.

I was surprised ast a few python features that did not work as I would 
expect/wish; which caused less compact/expressive program styles that I 
wanted - reverting to a FORTRAN like series of assignments.

For example,
   - why is len() not a member function of strings? Instead one says len(w).

  - Why doesn't sort() return a value?

This would allow things like:
key = '',join( list(word.lower().strip()).sort() )
instead:
key = ...
key.sort()
key = ...

   - Another feature I assumed but it failed, is a nice default for 
dictionaries, and more += like operations;
   For example: to acculumate words in a dictionary -
dict[key] += [word]

 Instead of:
mark[key] = mark.get(key,[]) + [word]

The former seems very intuitive, and clearer.
I am a bit used to the compactness and convenient defaults of Perl, which 
would do this:
   my $key = join '', sort(split(//, lc($word)));
push @{$anagrams{$key}}, $word

I am curious why these obvious conveniences are not present.  :-)
Thansk for any context or insight.

Best,
Gregory

Perl is great, and 



== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: language design question

2006-07-09 Thread guthrie
Steven Bethard wrote:
 Gregory Guthrie wrote:
 
 For example,
- why is len() not a member function of strings? Instead one says 
 len(w).
  
 Why would ``x.len()`` be any more convenient than ``len(x)``? Your 
 preference here seems pretty arbitrary.
-- Perhaps;
but having all standard operations as a method seems more regular (to 
me), and allows a simple chained operation format of a series of method 
calls, instead of alternating prefix function calls, and post-fix method 
invocations; e.g.
   x.lower().strip().toList().sort().join()
seems cleaner and simpler than the usage below, where the pre/post 
alternation is visually more complex.

I think the mix of OO like methods, and global functions, is not ideal.
 
   - Why doesn't sort() return a value?

 This would allow things like:
 key = '',join( list(word.lower().strip()).sort() )
 
 
 Use sorted():
 
 key = ','.join(sorted(word.lower().strip()))
-- Thanks!
(Is the comma in ',' just a typo?)
 
 
- Another feature I assumed but it failed, is a nice default for 
 dictionaries, and more += like operations;
For example: to acculumate words in a dictionary -
 dict[key] += [word]
 
 
 Get Python 2.5 and use collections.defaultdict:
-- Great, thanks.
 
 Python 2.5a2 (trunk:46491M, May 27 2006, 14:43:55) [MSC v.1310 32 bit 
 (Intel)] on win32
 Type help, copyright, credits or license for more information.
   import collections
   d = collections.defaultdict(int)
   d['a'] += 5
   d['b'] += 2
   d
 defaultdict(type 'int', {'a': 5, 'b': 2})
 
 STeVe


== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: language design question

2006-07-09 Thread guthrie
Many thanks; great information.

Best,
Gregory



Steven Bethard wrote:

 guthrie wrote:
 
 Steven Bethard wrote:

 Why would ``x.len()`` be any more convenient than ``len(x)``? Your 
 preference here seems pretty arbitrary.

 -- Perhaps;
 but having all standard operations as a method seems more regular (to 
 me), and allows a simple chained operation format of a series of 
 method calls, instead of alternating prefix function calls, and 
 post-fix method invocations; e.g.
   x.lower().strip().toList().sort().join()
 seems cleaner and simpler than the usage below, where the pre/post 
 alternation is visually more complex.
 I think the mix of OO like methods, and global functions, is not ideal.
 
 
 The advantage of a functional form over a method shows up when you write 
 a function that works on a variety of different types. Below are 
 implementations of list(), sorted() and join() that work on any 
 iterable and only need to be defined once::
 
 def list(iterable):
 result = []
 for item in iterable:
 result.append(item)
 return result
 
 def sorted(iterable):
 result = list(iterable)
 result.sort()
 return result
 
 def join(iterable):
 # this is more efficient in C, where the string's buffer can be
 # pre-allocated before iterating through the loop.
 result = ''
 for item in iterable:
 result += item
 return result
 
 Now, by providing these as functions, I only have to write them once, 
 and they work on *any* iterable, including some container object that 
 you invent tomorrow.
 
 If everything were methods, when you invented your container object 
 tomorrow, you'd have to reimplement these methods on your class. (Or 
 we'd have to introduce a Container class to provide them, and everyone 
 would have to inherit from that if they wanted to define a container.)
 
   - Why doesn't sort() return a value?

 This would allow things like:
 key = '',join( list(word.lower().strip()).sort() )


 Use sorted():

 key = ','.join(sorted(word.lower().strip()))

 -- Thanks!
 (Is the comma in ',' just a typo?)
 
 
 No, the comma puts a comma between each item.  I wasn't sure whether the 
 comma in your original was a typo for ''. or for ','.  Of course if you 
 don't want the comma between each item, you should just use ''
 
 STeVe


== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: language design question

2006-07-09 Thread guthrie
Good point, thanks.

But if (as I proposed..!) the user interface is better if presented as a 
method. one could porovide convenience methods which would then 
interface to these underlying library functions; yes?

So the main datatype classes could support such a method style, and just 
layer on top of the library.

Anyway, I get your point, thanks.

Greg

Steven Bethard wrote:

 guthrie wrote:
 
 Steven Bethard wrote:

 Why would ``x.len()`` be any more convenient than ``len(x)``? Your 
 preference here seems pretty arbitrary.

 -- Perhaps;
 but having all standard operations as a method seems more regular (to 
 me), and allows a simple chained operation format of a series of 
 method calls, instead of alternating prefix function calls, and 
 post-fix method invocations; e.g.
   x.lower().strip().toList().sort().join()
 seems cleaner and simpler than the usage below, where the pre/post 
 alternation is visually more complex.
 I think the mix of OO like methods, and global functions, is not ideal.
 
 
 The advantage of a functional form over a method shows up when you write 
 a function that works on a variety of different types. Below are 
 implementations of list(), sorted() and join() that work on any 
 iterable and only need to be defined once::
 
 def list(iterable):
 result = []
 for item in iterable:
 result.append(item)
 return result
 
 def sorted(iterable):
 result = list(iterable)
 result.sort()
 return result
 
 def join(iterable):
 # this is more efficient in C, where the string's buffer can be
 # pre-allocated before iterating through the loop.
 result = ''
 for item in iterable:
 result += item
 return result
 
 Now, by providing these as functions, I only have to write them once, 
 and they work on *any* iterable, including some container object that 
 you invent tomorrow.
 
 If everything were methods, when you invented your container object 
 tomorrow, you'd have to reimplement these methods on your class. (Or 
 we'd have to introduce a Container class to provide them, and everyone 
 would have to inherit from that if they wanted to define a container.)
 
 
 STeVe


== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list