Re: Case study: debugging failed assertRaises bug

2011-04-27 Thread R David Murray
Ben Finney benfinney.id.au> writes: > > (1) assertRaises REALLY needs a better error message. If not a custom > > message, at least it should show the result it got instead of an > > exception. > > +1 > > Is this one of the many improvements in Python 3.2's ‘unittest’ that > Michael Foord presid

Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1

2011-01-17 Thread R. David Murray
On Mon, 17 Jan 2011 08:33:42 +, Mark Summerfield wrote: > from ..Graphics import Xpm > SVG = 1 > > I can do the relative import with Python 3.0 and 3.1 but not with > 3.2rc1: What about 3.1.3? I wonder if it is related to this issue: http://bugs.python.org/issue79

Re: zipfile doesn't compress very good, are there other solutions?

2009-06-12 Thread R. David Murray
Chris Rebert wrote: > On Thu, Jun 11, 2009 at 1:41 PM, Stef Mientki wrote: > > Peter Otten wrote: > >> Stef Mientki wrote: > >>> Peter Otten wrote: > Stef Mientki wrote: > > I packed all sources with zipfile, > > but the compression doesn't seem to be very good. > > > >

Am I doing this the python way? (list of lists + file io)

2009-06-08 Thread R. David Murray
your description, I don't see any reason to prefer any alternate data structure. 1000 small CSV files should fit in a modern computer's memory with no problem...and if it does become an issue, worry about it then. One thought, though: you might want to create a list subclass to hold y

Re: pylint naming conventions?

2009-06-08 Thread R. David Murray
; I'm going to go back and re-read PEP 8 and see if I perhaps don't > recall the right guidelines since no one else here seems to have had > the same observation. Well, I for one looked at that long pylint output when I first tried it, and switched to another tool :) (pyflake

problems while using pexpect: pexcept.TIMEOUT always

2009-06-08 Thread R. David Murray
a simple thing as ssh to my localhost.? I would suggest using the 'setlog' method of child to get more debugging information from pexpect. I've found that the best way to diagnose the source of a timeout. -- R. David Murray http://www.bitdance.com IT Consultin

Python preprosessor

2009-06-07 Thread R. David Murray
of Code project to create a 3to2 processor. That would let you maintain the code in 3.x, and have it automatically translated on demand so that it will run under 2.x (where x goes back to at least 5, I think, but I'm not sure). Of course, it isn't finished yet, so it won't do you any

Re: how to transfer my utf8 code saved in a file to gbk code

2009-06-07 Thread R. David Murray
John Machin wrote: > On Jun 8, 12:13 am, "R. David Murray" wrote: > > higer wrote: > > > My file contains such strings : > > > \xe6\x97\xa5\xe6\x9c\x9f\xef\xbc\x9a > > > > If those bytes are what is in the file (and it sounds like they ar

how to transfer my utf8 code saved in a file to gbk code

2009-06-07 Thread R. David Murray
ding to do. -- R. David Murray http://www.bitdance.com IT ConsultingSystem AdministrationPython Programming -- http://mail.python.org/mailman/listinfo/python-list

Re: 4 hundred quadrillonth?

2009-05-21 Thread R. David Murray
Gary Herron wrote: > MRAB wrote: > > Grant Edwards wrote: > >> On 2009-05-21, Christian Heimes wrote: > >>> seanm...@gmail.com schrieb: > The explaination in my introductory Python book is not very > satisfying, and I am hoping someone can explain the following to me: > > >>> 4

Re: Supply a plugin interface

2009-04-23 Thread R. David Murray
a variable with the module name (excluding the .py), you can't > use 'import' as it is. Instead, use the __import__ functio (I wonder if > there is anything more elegant) which returns the plugin. In 2.7 and 3.1 there will be: from importlib import import_module myna

how to know the importing file name from an imported file?

2009-04-17 Thread R. David Murray
pose module C imports module B as well? So, no, not in any useful way. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Getting Newsgroup Headers

2009-04-16 Thread R. David Murray
m not going to claim that this is the best code that could be written for this task :) Oh, and there's more involved in actually printing the headers if you need to deal with non-ASCII characters ("encoded words") in the headers. (That's in the docs for the email module, though it

Help with run command + variable.

2009-04-14 Thread R. David Murray
the $varname format you used above). Which you choose depends on how you want to work, but I'd recommend .format() for most things. Except for your os.system call, where I'd recommend using the subprocess module instead, in which case you'd do something like this: call(['sixa', 'action', 'profile', profile]) -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

iPython help, Docstring [source file open failed]

2009-04-14 Thread R. David Murray
at the shell > (as oppose lookup at Python Doc). Can I somehow link the actual Python > source code to iPython so that it can be accessed in that way? Notice that the filetype is '.so'. That means it is a compiled C module, so there is no python source to view. -- R. David Murray

xml.dom.minidom getElementsByTagName white space issue

2009-04-09 Thread R. David Murray
I've tried some escape chars but it doesnt seems to work. >   > Does anybody has the escape char sequence I should be using or a work around > for this? Thanks in advanced for your replies. As far as I can tell what you are getting is invalid XML. So I think the answer is &q

communication between objects - help

2009-04-09 Thread R. David Murray
Murali kumar wrote: > hi all.. > > > please see my attached document.. I think you'll get more help if you post in plain text. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: is there a way to collect twitts with python?

2009-04-08 Thread R. David Murray
's all e-mail to them. Granted the scourge of abbreviated words > and lol-speak is just as bad there. Sigh. lol-speak originated on IRC. (Or probably even earlier on the original bitnet relay chat.) -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Some test fail on my new Python 2.6

2009-04-08 Thread R. David Murray
. > > Everything is done as root. I got failures (different failures) when I tried running that test as root. You might try running it as a regular user, both before and after the install. > I'll move on with make install. > > Thanks for your help; I'm progressing :-)

Re: Some test fail on my new Python 2.6

2009-04-08 Thread R. David Murray
em (and that means that the test is a little fragile). If you rerun that test in verbose mode without the pipe into tee, does it pass? > The output for individual test_httpservers was posted here: > http://mail.python.org/pipermail/python-list/2009-April/708041.html Hmm. These puzzle me.

Re: genetic algorithms in Python??

2009-04-08 Thread R. David Murray
r of interesting hits. I also remember seeing at least one package announced on python-announce that referred to genetic algorithms, so you might check the archives of that mailing list as well. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Some test fail on my new Python 2.6

2009-04-08 Thread R. David Murray
pep277 test_py3kwarn test_scriptpackages > test_socketserver test_sqlite test_startfile test_sunaudiodev > test_tcl test_timeout test_unicode_file test_urllib2net > test_urllibnet test_winreg test_winsound test_zipfile64 These as it implies are all normal. > 3 skips unexpected on linux2: > test_tcl test_dbm test_multiprocessing And these we've covered. So your biggest barrier to getting your python working for your purposes is getting python to find the libtk8.5.so. Everything else you can ignore, unless you want to try to track them down. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Issue with subprocess Module

2009-04-07 Thread R. David Murray
pected. I know there have been quite > a few changes to the subprocess module between Python 2.5 & 2.6 so > maybe you need to upgrade. (Failing that, we'd have to work a bit > harder to pin down a specific bug in the 2.5 code since 2.5 is now > in bugfix-release mode only, I think). 2.5 is in security-fix-only mode. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: in place list modification necessary? What's a better idiom?

2009-04-07 Thread R. David Murray
On Tue, 7 Apr 2009 at 09:01, andrew cooke wrote: R. David Murray wrote: [...] try: dimensions.append(float(s)) except: dimensions.append(float(quantization[s])) No, no, no; never use a bare except! :) can you explain why? i can't think of any reason why the code wou

cgi file limit size?

2009-04-07 Thread R. David Murray
right? > maybe my connection to the server is timing out during the upload? > web server is IIS 6.0. > python is 2.5.2. > IIS webmapping does not use "-u" b/c nothing works when that option is > used. What are you using to do the upload? What error message do you g

Re: Some test fail on my new Python 2.6

2009-04-07 Thread R. David Murray
the Skip messages (and any real errors) from the make test run? I can run through them quickly for you then, and then we can focus on the ones that are the real errors. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: in place list modification necessary? What's a better idiom?

2009-04-07 Thread R. David Murray
-contiguous ranges of integers for a > particular column if a string occurs ("by accident" perhaps) in more than > one. > > 2 - don't bother with isNumeric. just return the cast value or catch the > exception: > > [...] > try: > dimensions.append(flo

Some test fail on my new Python 2.6

2009-04-06 Thread R. David Murray
Tk [...] > Anybody has a quick fix? Yep. Run 'make test' instead of running them one by one. make test will run them under regrtest, which has mechanisms for detecting tests that are expected to or may reasonably fail on a given platform. Then if you still have errors, report back

Re: print from a python script.

2009-04-06 Thread R. David Murray
e subprocess.Popen instead, that's better). By the way, when you get closer to getting the above to work, you're going to want to add a '\n' to the end of that string you are writing. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

set python default encoding

2009-04-06 Thread R. David Murray
7;invalid data' > start = 10 > > > Please tell me how to solve this problem. That doesn't look anything like a python traceback. I'm guessing you are using some sort of web framework? Perhaps you should try asking in the forum for the framework. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

object knows which object called it?

2009-04-06 Thread R. David Murray
does the right thing: def Bfoo_func(self): self.B.foo_func(self) Or maybe you could look at generic methods, which provide a way to do multiple dispatch. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: split string at commas respecting quotes when string not in csv format

2009-03-26 Thread R. David Murray
Paul McGuire wrote: > On Mar 26, 2:51 pm, "R. David Murray" wrote: > > OK, I've got a little problem that I'd like to ask the assembled minds > > for help with.  I can write code to parse this, but I'm thinking it may > > be possible to do it with

Re: split string at commas respecting quotes when string not in csv format

2009-03-26 Thread R. David Murray
John Machin wrote: > On Mar 27, 6:51 am, "R. David Murray" wrote: > > OK, I've got a little problem that I'd like to ask the assembled minds > > for help with.  I can write code to parse this, but I'm thinking it may > > be possible to do it with

Re: split string at commas respecting quotes when string not in csv format

2009-03-26 Thread R. David Murray
> for m in r.finditer(s) > ] > > Things like internal quoting ('b="123\"456", c="123""456"') would > require a slightly smarter parser. Thank you thank you. I owe you a dinner if we are ever in the same town (are you at Pycon

split string at commas respecting quotes when string not in csv format

2009-03-26 Thread R. David Murray
ggestion) I would be greatful. (This has to be stdlib only, by the way, I can't introduce any new modules into the application so pyparsing is not an option.) The challenge is to turn a string like this: a=1,b="0234,)#($)@", k="7" into this: [("a", &quo

Re: fft of a dat file?

2009-03-25 Thread R. David Murray
)]) Modify as appropriate to your actual needs. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

user site-packages, --prefix, --home and friends

2009-03-24 Thread R. David Murray
and handling of .pth files. As for best practice, I would say whichever one meets your needs. The PEP is addressing the needs of users who do not have root privs but who want to install packages via distutils in such a way that they will act as if they had been installed in the system site-packag

Re: Relative Imports, why the hell is it so hard?

2009-03-24 Thread R. David Murray
e, and you've told us that you have '50 modules' with a lot of shared code that 'could be used across other projects', perhaps you see why relative imports are generally discouraged. If you use only relative imports, the code _can't_ be shared across multiple p

Re: file.read() doesn't read the whole file

2009-03-24 Thread R. David Murray
' or hexdump instead of less to read the file? Run experiments until you gather enough clues to make a guess as to what is going on, then test your theory. Repeat until success :) -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

importing modules from alternate path

2009-03-24 Thread R. David Murray
> Any idea why alternate path is not working? Possibly because the package gets installed into ~/lib/python, but you haven't put that directory onto the PYTHONPATH. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: script files with python (instead of tcsh/bash)?

2009-03-23 Thread R. David Murray
e will be closed at program termination anyway, but is a good habit to get in to.) -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

udp package header

2009-03-23 Thread R. David Murray
mete wrote: > Hi all, > I got a problem. İ want to send udp package and get this package (server and > clinet ). it's easy to python but i want to look the udp header how can i > do ? The English word is 'packet'. If you are on Linux you can use raw sockets fo

Re: file.read() doesn't read the whole file

2009-03-23 Thread R. David Murray
the 'snap.read(length)' call is not returning the whole file is based on the fact that less is only showing him part of the file. There are several steps between that 'snap.read' and less displaying on the terminal whatever bytes it got back from its read call in whatever way it is less chooses to display them -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Generator

2009-03-23 Thread R. David Murray
impler statement works, too: > >g = iter(s[:]) Yes, but one presumes that in the real code that prompted the OP's question he wasn't just returning 'x'. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Lambda forms and scoping

2009-03-23 Thread R. David Murray
losure is a "read-only closure". But now with Python 3.x we can really have fun (thank you for that info): >>> def g(): ... def a(x): ... nonlocal z ... z = z + x ... def b(x): ... nonlocal z ... z = z - x ... def p()

Re: file.read() doesn't read the whole file

2009-03-23 Thread R. David Murray
' to read the 'file' exposed by fuse. Correct? So you still have not decoupled the python read from the fuse read in your debugging. You are focused on the fact that the python read "must be failing", yet you still (as far as you have told us) not _proven_ that by logging

Re: safely rename a method with a decorator

2009-03-22 Thread R. David Murray
is that I'm writing a turbogears application in which the > URLs are determined by the method names. People might want to change > these names if they want to change the URLs. One way would be to put > the method names into a turbogears configuration file and the @rename > decorator could fetch it from there. Use a WSGI routing engine instead. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Generator

2009-03-22 Thread R. David Murray
mattia wrote: > Il Sun, 22 Mar 2009 16:52:02 +0000, R. David Murray ha scritto: > > > mattia wrote: > >> Can you explain me this behaviour: > >> > >> >>> s = [1,2,3,4,5] > >> >>> g = (x for x in s) > >> >>> ne

loading program's global variables in ipython

2009-03-22 Thread R. David Murray
and myglobal2 are not imported into > python's interactive namespace. i'd like them too -- how can i do > this? > > (note my file does not contain a __name__ == '__main__' clause.) I'm not familiar with IPython, but perhaps 'from myfile import *

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread R. David Murray
"Gabriel Genellina" wrote: > En Sun, 22 Mar 2009 15:11:37 -0300, R. David Murray > escribió: > > "Gabriel Genellina" wrote: > >> En Sat, 21 Mar 2009 23:58:07 -0300, escribió: > >> > > >> > class file(io.TextIOWrapper): > &

Re: Lambda forms and scoping

2009-03-22 Thread R. David Murray
names point to in its local and global namespaces, but cannot modify what names point to in the closure namespace. Of course, we can produce the same _effect_ as a computer science closure in Python by using mutable objects...which is exactly parallel to the difference between passing mutable or immutable objects in a function call. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread R. David Murray
tion that would yield such an open function that otherwise is identical to the default open. What's the standard python idiom for when consumer code should be able to specialize the classes used to create objects returned from a called package? (I'm tempted to say monkey patching the module, but that can't be optimal :) -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Using python 3 for scripting?

2009-03-22 Thread R. David Murray
cases I _do_ have to support a number of servers that are still running 2.5 :( -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Generator

2009-03-22 Thread R. David Murray
you want next(g) to yield 3, you'd have to do something like: g = (x for x in s[:]) where s[:] makes a copy of s that is then iterated over. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Using python 3 for scripting?

2009-03-22 Thread R. David Murray
lmost out the door and that fixes the I/O performance issue. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Script for a project inside own directory

2009-03-22 Thread R. David Murray
works in python (PYTHONPATH, sys.path) so that you can decide which of the many possible ways to make this work will serve you best. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Preparing teaching materials

2009-03-21 Thread R. David Murray
badly indeed if your handouts > and computers don't make the same assumptions! Print as function can be used in 2.6+ via 'from __future__ import print_function'. So it is probably best to teach print-as-function regardless. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: How complex is complex?

2009-03-20 Thread R. David Murray
k back further at the post which they were commenting on. Those two lines do not constitute consecutive lines of code, they are individual replacements for individual lines in two different previous examples, one of which updates the dict in place and the other of which creates a new dict. I thin

Re: file.read() doesn't read the whole file

2009-03-20 Thread R. David Murray
7;t read the whole file? You didn't log it. Both your statements might be true, but until you show the logging output proving it, you don't _know_ that your assumptions are true. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: file.read() doesn't read the whole file

2009-03-20 Thread R. David Murray
On Fri, 20 Mar 2009 at 07:09, Sreejith K wrote: On Mar 20, 4:43?pm, "R. David Murray" wrote: Sreejith K wrote: Hi, snapdir = './mango.txt_snaps' snap_cnt = 1 block = 0 import os os.chdir('/mnt/gfs_local') snap = open(snapdir + '/snap%s/%s' % (rep

Re: Lambda forms and scoping

2009-03-20 Thread R. David Murray
n they are called, __init__'s namespace is in whatever state it was left in when __init__ ended. In this case, that means that 'option' is pointing to the value it had at the _end_ of the for loop. Hope this helps. I find that thinking in terms of namespaces helps me understand how Python works better than any other mental model I've come across. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Can I rely on...

2009-03-20 Thread R. David Murray
n) > else: > print("The compiled pattern is stored.") FYI this is almost exactly the approach the re module takes to caching the expressions. (The difference is re adds a type token to the front of the key.) -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

file.read() doesn't read the whole file

2009-03-20 Thread R. David Murray
\n") > data = self.snap.read(length) > self.snap.close() > break > > the output data is supposed to read the whole fie but it only reads a > part of it. Why is it encountering an early EOF ? It's not. In the second case you told it to read only 4096 bytes. You might want to read the docs for the 'read' method, paying particular attention to the optional argument and its meaning. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Concrete Factory Pattern syntax?

2009-03-19 Thread R. David Murray
ook up the capitalized version of the string (eg: 'One') in the __init__.py module's global namespace, thus picking up the class, and then calls it to create an instance, which is then returned. Then your code that uses this can do: from parser import parserFactory myparser

Re: Can I rely on...

2009-03-19 Thread R. David Murray
iteration with equality if it doesn't). But the _intent_ of __contains__ is that comparison be by equality, not object identity, so if the two are not the same something weird is going on and there'd better be a good reason for it :) In summary, 'in' is the thing to use

Tuple passed to function recognised as string

2009-03-18 Thread R. David Murray
all the comma would normally be an argument separator, so in that context you do need the parenthesis as well: test_func(val=('val1',)) -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: alias method definitions / syntactic sugar suggestion

2009-03-18 Thread R. David Murray
zero__') > > def __bool__(self): > > > > and even better(?) if it could depend on python version! > > > > or maybe there's another solution to the __bool__ problem above? (there's > > also next methods, can't think of anything else

read web page that requires javascript on client

2009-03-18 Thread R. David Murray
nk it was GTK bindings, even though you were dealing with just network IO. But I don't remember clearly and did not record the reference. Perhaps the person who posted that info will answer you, or you will be able to figure out from these clues. Unfortunately I'm not 100% sure it was Webkit

Disable automatic interning

2009-03-18 Thread R. David Murray
ementation detail. What use case do you have for wanting to disable it? -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Mangle function name with decorator?

2009-03-18 Thread R. David Murray
any way that is really satisfying. Someone else suggested the property model, though that is probably not as elegant as you want either. Sohow about the below. Extending it to handle multiple classes is left as an exercise for the reader :) As is extending it to handle stacking the

Re: array next pointer

2009-03-18 Thread R. David Murray
except StopIteration: break but the version using SENTINEL avoids having the interpreter do the work of generating a traceback, and is IMO slightly prettier. I'm sure there are other use cases, too, but probably not a huge number of them. Certainly not as many as using the parameter as a default. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: 2to3 does not fix FileType from types Module; no replacement?

2009-03-18 Thread R. David Murray
. > > Nontheless, a warning would be helpful, possibly with some doc. Submitting an issue to the tracker with this request would probably be a good idea. Even better if you include a suggested patch. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Mangle function name with decorator?

2009-03-18 Thread R. David Murray
mmer type, eg: @GET def foo(self): pass @POST def foo(self): pass have them type: def GET_foo(self): pass def POST_foo(self): pass It's even one less character of typing (the :) -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: array next pointer

2009-03-17 Thread R. David Murray
I love the new sentinel argument for the next function in python3!) > > next() doesn't have a sentinel argument. It's iter() which does, and that's in > 2.x also. But it does have a 'default' argument, and you can pass that a sentinel, so it amounts to the same thing ;) -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: download x bytes at a time over network

2009-03-17 Thread R. David Murray
Jean-Paul Calderone wrote: > On Tue, 17 Mar 2009 15:17:56 + (UTC), "R. David Murray" > wrote: > >Jean-Paul Calderone wrote: > >> On Tue, 17 Mar 2009 12:15:23 +0530, Saurabh wrote: > >> >> This isn't exactly how things work.  The server *

Re: Keyword same in right hand side of assignments (rev)

2009-03-17 Thread R. David Murray
Arg, my apologies, I posted my replies to the wrong group :( -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Keyword same in right hand side of assignments (rev)

2009-03-17 Thread R. David Murray
still think that the cost of a new keyword is probably too high a > price to pay, but I like the idea. Yeah, you have to make a really, _really_ compelling case to get a new keyword added. Something you can't do any other way, or at least not without an awful lot of hassle. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Keyword same in right hand side of assignments (rev)

2009-03-17 Thread R. David Murray
inmutable+1; inmutable*=unused; del unused" > > There seems to be no really simple expression for the above extensions, > and I take that as an indication > that the proposed feature could be quite useful. For the first one, we have: lst[:0] = [5, 6] And unless I'm misun

Re: urllib2 (py2.6) vs urllib.request (py3)

2009-03-17 Thread R. David Murray
mattia wrote: > Il Tue, 17 Mar 2009 10:55:21 +0000, R. David Murray ha scritto: > > > mattia wrote: > >> Hi all, can you tell me why the module urllib.request (py3) add extra > >> characters (b'fef\r\n and \r\n0\r\n\r\n') in a simple example like the >

Re: download x bytes at a time over network

2009-03-17 Thread R. David Murray
with 46229 bytes ? Or is it something else ? > > That's just a bug in urllib in Python 3.0. What makes you say that's a bug? Did I miss something? (Which is entirely possible!) -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: download x bytes at a time over network

2009-03-17 Thread R. David Murray
Saurabh wrote: > > This isn't exactly how things work.  The server *sends* you bytes.  It can > > send you a lot at once.  To some extent you can control how much it sends > > before it waits for you to catch up, but you don't have anywhere near > > byte-level control (you might have something lik

urllib2 (py2.6) vs urllib.request (py3)

2009-03-17 Thread R. David Murray
open("temp3.html", "wb") as fd: ... fd.write(f) The "b''" is the stringified representation of a bytes object, which is what urllib.request returns in python3. Note the 'wb', which is a critical difference from the python2.6 case. If y

Re: error writing str to binary stream - fails in Python 3.0.1, works in 2.x

2009-03-16 Thread R. David Murray
str converted over to binary bytes to > write to bmp file. (I reformatted your message slightly to make the code block stand out more.) A byte array is an array of bytes, and it understands integers as input. Check out the PEP (the official docs leave some things out): http://www.p

error writing str to binary stream - fails in Python 3.0.1, works in 2.x

2009-03-16 Thread R. David Murray
to work with binary byte streams, you want to use the 'bytes' type. Bytes contstants are written with a leading 'b', so the code snipped above would become self.out.write(b'BM') -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

setattr() on "object" instance

2009-03-16 Thread R. David Murray
o.x > 1000 > > I notice that the first example's instance doesn't have a __dict__. > Is the second way the idiom? The lack of a __dict__ is why you can't set the attribute. I've occasionally wanted to use instances of object as holders of arbitrar

Re: print - bug or feature - concatenated format strings in a print statement

2009-03-16 Thread R. David Murray
n the other hand, it is one of the, well, bugs, that is avoided by the 'format' method in 3.x. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Style question - defining immutable class data members

2009-03-15 Thread R. David Murray
laid out in full, with all the consequences it would entail examined. > I think this situation should be handled in documentation. (I'm a tech writer > in my day job ... oh wait, I forgot ... I got laid off from my day job in > December.) I'll look into what the standard Python doc set says on this > matter. Doc patches are always welcome, and from what I hear easier to get accepted than code patches ;) -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Style question - defining immutable class data members

2009-03-15 Thread R. David Murray
same object that was just mutated. Unlike the '+' case where 'a' is bound to a newly created list object. Personally I think += and kin were a bad idea and should have been removed in Python 3.0 :) Even though I occasionally use them. (Maybe I'll stop.) > A

Is this type of forward referencing possible?

2009-03-15 Thread R. David Murray
d information. I found this one, which is a nice summary but doesn't give examples: http://www.network-theory.co.uk/docs/pytut/PythonScopesandNameSpaces.html -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Set & Frozenset?

2009-03-10 Thread R. David Murray
.timeit('for res in myset: break', 'myset=range(100)') > 0.3293300797699 > > I'd never expect that for-loop assignment is even faster than a > precreated iter object (the second test)... but I don't think this > for-looping variable leaking behavior is guaranteed, isn't it? My guess would be that what's controlling the timing here is name lookup. Three in the first example, two in the second, and one in the third. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Packaging Survey

2009-03-09 Thread R. David Murray
sort of mechanism for a site to say "I'm not claiming anything about my identity, I'm just providing you an https channel over which to talk to me securely". I fault the designers of https for this oversight. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Re: should i move on to python3

2009-03-07 Thread R. David Murray
roblems of the new io package), I think the only reason not to move to python3 will be any dependency one might have on 3rd party packages that haven't themselves made the switch yet. Of course, that will be a big issue for some time to come for many people. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list