Re: import urllib2 fails with Python 2.6.1 on Vista

2009-01-17 Thread Gabriel Genellina
En Sat, 17 Jan 2009 17:13:00 -0200, Scott MacDonald escribió: I googled a bit this morning search for an answer to this problem but have come up empty so far. Can anyone help? Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit ^ (Intel)] on win32 Type "help"

Re: A java hobbyist programmer learning python

2009-01-17 Thread elhombre
"Steven D'Aprano" wrote in message news:0182896d$0$8693$c3e8...@news.astraweb.com... On Sun, 18 Jan 2009 11:11:45 +1000, elhombre wrote: Hello, below is my first fragment of working python code. As you can see it is very java like as that is all I know. Is this the right approach to be taki

Re: A java hobbyist programmer learning python

2009-01-17 Thread elhombre
"John Machin" wrote in message news:5d2c588a-9b01-4a85-85b2-b132754e6...@o40g2000prn.googlegroups.com... On Jan 18, 12:11 pm, "elhombre" wrote: Hello, below is my first fragment of working python code. As you can see it is very java like as that is all I know. Is this the right approach to be

Re: A java hobbyist programmer learning python

2009-01-17 Thread elhombre
"Paul Rubin" wrote in message news:7xy6x9nzwd@ruckus.brouhaha.com... Chris Rebert writes: > class Calculator(): ... Delete the 3 Java-ish accessor methods; good Python style just uses the attributes directly (i.e. self.operator instead of self.getOperator

Re: A java hobbyist programmer learning python

2009-01-17 Thread elhombre
"Chris Rebert" wrote in message news:mailman.7468.1232242083.3487.python-l...@python.org... On Sat, Jan 17, 2009 at 5:11 PM, elhombre wrote: ... Rather than have a long if-elif-else chain like this, you can use a dictionary with functions as values. For example: def add(x, y): return x +

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-17 Thread Steven D'Aprano
On Sat, 17 Jan 2009 20:49:38 +0100, Bruno Desthuilliers wrote: > Russ P. a écrit : >> On Jan 15, 12:21 pm, Bruno Desthuilliers >> wrote: >> >>> Once again, the important point is that there's a *clear* distinction >>> between interface and implementation, and that you *shouldn't* mess >>> with i

Re: what's the point of rpython?

2009-01-17 Thread Paul Rubin
alex23 writes: > Here's an article by Guido talking about the last attempt to remove > the GIL and the performance issues that arose: > > "I'd welcome a set of patches into Py3k *only if* the performance for > a single-threaded program (and for a multi-threaded but I/O-bound > program) *does not

Re: changing URLs in webpages, python solutions?

2009-01-17 Thread Abandoned
On Jan 18, 4:07 am, Simon Forman wrote: > Hey folks, > > I'm having trouble finding this through google so I figured I'd ask > here. > > I want to take a webpage, find all URLs (links, img src, etc.) and > rewrite them in-place, and I'd like to do it in python (pure python > preferred.) > > I know

Dynamic Loading Modules

2009-01-17 Thread Riley Porter
Hello all, This is the first time I have posted to this group. That being said if I am in the wrong place for this kind of support please let me know. OK, So I am writing a log parsing program and wish to allow for the community to write "parsers". Basically, what I have in place now is a "mod

Re: Python 3: exec arg 1

2009-01-17 Thread Terry Reedy
Alan G Isaac wrote: Alan G Isaac wrote: Is it intentional that ``exec`` cannot handle a TextIOWrapper? Bottom line: has ``execfile(filename)`` really become ``exec(open(filename).read())``? Is this a good thing? On 1/17/2009 4:20 PM Terry Reedy apparently wrote: Yes. Yes. OK. Why? T

Re: reading file to list

2009-01-17 Thread Xah Lee
a idiot wrote: > Yes, Jillian also has nested maps: the issue here, is not about whether Ruby has nested map or not. It is about illustrating a lisp problem. In particular, nested syntax impedes the functional programing paradigm of function chaining. • A Ruby Illustration of Lisp Problems ht

Re: what's the point of rpython?

2009-01-17 Thread alex23
On Jan 18, 9:55 am, "Brendan Miller" wrote: > > The *actual* goal as outlined by their official docs is to > > implement Python in Python, at every level. > Ok fair enough. In some ways I see that as more of a purely > intellectual exercise than the practical endeavor that I assumed the > project

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-17 Thread Terry Reedy
John Machin wrote: On Jan 18, 9:10 am, Terry Reedy wrote: Martin v. Löwis wrote: Does he intend to maintain two separate codebases, one 2.x and the other 3.x? I think I have no other choice. Why? Is theoretically possible to maintain an unique code base for both 2.x and 3.x? That is certainl

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-17 Thread Terry Reedy
John Machin wrote: On Jan 18, 9:10 am, Terry Reedy wrote: Martin v. Löwis wrote: Does he intend to maintain two separate codebases, one 2.x and the other 3.x? I think I have no other choice. Why? Is theoretically possible to maintain an unique code base for both 2.x and 3.x? That is certainl

Re: tp_base, ob_type, and tp_bases

2009-01-17 Thread Mark Wooding
Jeff McNeil writes: > Thank you! It was tp_base that was confusing me. The tp_bases member > makes sense as Python supports multiple inheritance. It wasn't > immediately clear that tp_base is there for single inheritance > reasons. It's all quite clear now. > > Is that an optimization of sorts?

Re: A java hobbyist programmer learning python

2009-01-17 Thread Steven D'Aprano
On Sun, 18 Jan 2009 11:11:45 +1000, elhombre wrote: > Hello, below is my first fragment of working python code. As you can see > it is very java like as that is all I know. Is this the right approach > to be taking? You might find it very useful to read: http://dirtsimple.org/2004/12/python-is-n

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-17 Thread Simon Forman
On Jan 11, 1:22 pm, "Madhusudan.C.S" wrote: >   I am sorry all I am not here to just blame Python. This is just an > introspection of whether > what I believe is right. Being a devotee of Python from past 2 years I > have been writing only > small apps and singing praises about Python where ever I

changing URLs in webpages, python solutions?

2009-01-17 Thread Simon Forman
Hey folks, I'm having trouble finding this through google so I figured I'd ask here. I want to take a webpage, find all URLs (links, img src, etc.) and rewrite them in-place, and I'd like to do it in python (pure python preferred.) I know I could probably roll my own halfway decent solution in a

Re: A java hobbyist programmer learning python

2009-01-17 Thread John Machin
On Jan 18, 12:11 pm, "elhombre" wrote: > Hello, below is my first fragment of working python code. As you can see it > is very java like as that is all I know. Is this the right approach to be > taking? > Should I be taking a different approach? Thanks in advance. > > import sys > > class Calculat

Re: A java hobbyist programmer learning python

2009-01-17 Thread Chris Rebert
On Sat, Jan 17, 2009 at 5:53 PM, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > Chris Rebert writes: >> Rather than have a long if-elif-else chain like this, you can use a >> dictionary with functions as values. For example: >> >> def add(x, y): >> return x + y > > These functions are al

Re: reverse dict lookup & Relation class

2009-01-17 Thread Aaron Brady
On Jan 17, 10:45 am, Steven D'Aprano wrote: > On Sat, 17 Jan 2009 00:24:21 -0800, Aaron Brady wrote: > > Can you make it work for a 3-way lookup? > > What do you mean "3-way lookup"? > > I'm going to take a guess... > > A maps to B, B maps to C, and C maps to A. > > Is that what you mean? So long

Re: A java hobbyist programmer learning python

2009-01-17 Thread Paul Rubin
Chris Rebert writes: > > class Calculator(): ... > Delete the 3 Java-ish accessor methods; good Python style just uses > the attributes directly (i.e. self.operator instead of > self.getOperator()). I think I would get rid of the whole Calculator class unless there was a good reason to keep it (

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-17 Thread John Machin
On Jan 18, 9:10 am, Terry Reedy wrote: > Martin v. Löwis wrote: > >>> Does he intend to maintain two separate codebases, one 2.x and the > >>> other 3.x? > >> I think I have no other choice. > >> Why? Is theoretically possible to maintain an unique code base for > >> both 2.x and 3.x? > > > That i

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-17 Thread Russ P.
On Jan 17, 1:43 pm, Paul Rubin wrote: > Bruno Desthuilliers writes: > > Once again, there's quite a lot to learn from > > the story of Ariane 5. > > Do you know what actually happened with Ariane 5?  The failure was > because "smart" humans overrode the language enfo

Re: reading file to list

2009-01-17 Thread André Thieme
Xah Lee schrieb: Xah Lee wrote: • A Ruby Illustration of Lisp Problems http://xahlee.org/UnixResource_dir/writ/lisp_problems_by_ruby.html On Jan 17, 12:30 pm, André Thieme wrote: In the Lisp style Clojure for example one does exactly the same as Jillian James (JJ) did in Ruby: (map #(

Re: A java hobbyist programmer learning python

2009-01-17 Thread Chris Rebert
On Sat, Jan 17, 2009 at 5:11 PM, elhombre wrote: > Hello, below is my first fragment of working python code. As you can see it > is very java like as that is all I know. Is this the right approach to be > taking? > Should I be taking a different approach? Thanks in advance. > > import sys > > clas

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-17 Thread Russ P.
On Jan 17, 11:49 am, Bruno Desthuilliers wrote: > Please educate yourself and learn about why Ariane 5 crashed on it's > first flight, due to an error in a module written in ADA (which is such > a psychorigid language that C++ and Java are even looser than Javascript > in comparison). Perhaps wil

A java hobbyist programmer learning python

2009-01-17 Thread elhombre
Hello, below is my first fragment of working python code. As you can see it is very java like as that is all I know. Is this the right approach to be taking? Should I be taking a different approach? Thanks in advance. import sys class Calculator(): def __init__(self): self.operator

Re: Possible bug in Tkinter - Python 2.6

2009-01-17 Thread José Matos
On Friday 16 January 2009 09:47:36 Eric Brunel wrote: > What do you mean by 'works'...? The usual meaning, I think. :-) Click "Yes" and the program prints True, click "No" and the programs prints "False". > You don't have the problem? It doesn't   > change a thing for me... Notice that I am ru

Re: Incorrect title case?

2009-01-17 Thread John Machin
On Jan 18, 10:15 am, "Martin v. Löwis" wrote: > > A value of zero for ctype->title should be interpreted simply as the > > offset to add to the ordinal, as it is in the sibling _PyUnicode_To > > (Upper|Lower)case functions. > > Interestingly enough, according to the spec of UnicodeData.txt, > thes

Re: reading file to list

2009-01-17 Thread Xah Lee
Xah Lee wrote: > • A Ruby Illustration of Lisp Problems > http://xahlee.org/UnixResource_dir/writ/lisp_problems_by_ruby.html On Jan 17, 12:30 pm, André Thieme wrote: > In the Lisp style Clojure for example one does exactly the same as > Jillian James (JJ) did in Ruby: > (map #(map (fn [s] (I

Re: Windows Tablet RealTimeStylus in Python

2009-01-17 Thread M�ta-MCI (MVP)
Hi! I use Internet-Explorer like (as?) GUI. Then, I insert Active-X components (from Tablet-PC, native or SDK). Another solution: create a .HTA, and use PythonScript (version "ActiveScripting" of Python, who become with pyWin32). @-salutations -- Michel Claveau -- http://mail.python.org/ma

Re: what's the point of rpython?

2009-01-17 Thread Brendan Miller
>> The goals of the pypy project seems to be to create a fast python >> implementation. I may be wrong about this, as the goals seem a little >> amorphous if you look at their home page. > > The home page itself is ambiguous, and does oversell the performance > aspect. The *actual* goal as outlined

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-17 Thread Russ P.
No one ever claimed that a programming language, no matter how rigorous, can eliminate all bugs. All a language can do is to reduce their rate of occurrence. The Ariane fiasco was not a failure of Ada per se but rather a failure of people using Ada. They attempted to re-use software written for on

Re: s=ascii(hexlify(urandom(10)))

2009-01-17 Thread gert
On Jan 18, 12:20 am, "Martin v. Löwis" wrote: > >>> s = str(hexlify(urandom(8)))[2:18] > >> And your question is? > > > No question just solution to get rit of b'' :) > > Ah. hexlify(urandom(8)).decode('ascii') Ok that one looks better then mine :) -- http://mail.python.org/mailman/listinfo/pytho

Re: s=ascii(hexlify(urandom(10)))

2009-01-17 Thread Martin v. Löwis
>>> s = str(hexlify(urandom(8)))[2:18] >> And your question is? > > No question just solution to get rit of b'' :) Ah. hexlify(urandom(8)).decode('ascii') Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Incorrect title case?

2009-01-17 Thread Martin v. Löwis
> A value of zero for ctype->title should be interpreted simply as the > offset to add to the ordinal, as it is in the sibling _PyUnicode_To > (Upper|Lower)case functions. Interestingly enough, according to the spec of UnicodeData.txt, these should *not* be siblings. Refer to http://www.unicode.

Re: s=ascii(hexlify(urandom(10)))

2009-01-17 Thread Pierre-Alain Dorange
"Martin v. Löwis" wrote: > > On Jan 17, 9:08 pm, "Martin v. Löwis" wrote: > >>> I expected that py3 did not converted the b'...' indication too ? > >>> b'afc76815e3fc429fa9d7' > >> You mean, just because you invoked the ascii() builtin, the b > >> prefix should disappear? Re-read the documentati

Re: s=ascii(hexlify(urandom(10)))

2009-01-17 Thread gert
On Jan 18, 12:05 am, "Martin v. Löwis" wrote: > gert wrote: > > On Jan 17, 9:08 pm, "Martin v. Löwis" wrote: > >>> I expected that py3 did not converted the b'...' indication too ? > >>> b'afc76815e3fc429fa9d7' > >> You mean, just because you invoked the ascii() builtin, the b > >> prefix should

Re: s=ascii(hexlify(urandom(10)))

2009-01-17 Thread Martin v. Löwis
gert wrote: > On Jan 17, 9:08 pm, "Martin v. Löwis" wrote: >>> I expected that py3 did not converted the b'...' indication too ? >>> b'afc76815e3fc429fa9d7' >> You mean, just because you invoked the ascii() builtin, the b >> prefix should disappear? Re-read the documentation of the >> ascii() buil

Re: Incorrect title case?

2009-01-17 Thread MRAB
Terry Reedy wrote: John Machin wrote: On Jan 17, 9:07 am, MRAB wrote: Python 2.6.1 I've just found that the following 4 Unicode characters/codepoints don't behave as I'd expect: Dž (U+01C5), Lj (U+01C8), Nj (U+01CB), Dz (U+01F2). For example, u"\u01C5".istitle() returns True and unicodedata.cate

Re: Incorrect title case?

2009-01-17 Thread Terry Reedy
John Machin wrote: On Jan 17, 9:07 am, MRAB wrote: Python 2.6.1 I've just found that the following 4 Unicode characters/codepoints don't behave as I'd expect: Dž (U+01C5), Lj (U+01C8), Nj (U+01CB), Dz (U+01F2). For example, u"\u01C5".istitle() returns True and unicodedata.category(u"\u01C5") retu

Re: tp_base, ob_type, and tp_bases

2009-01-17 Thread Ned Deily
In article , Terry Reedy wrote: > Martin v. Löwis wrote: > > (I don't understand the English "one in the same" - interpreting it > > as "as though they should be the same") > Martin, you are not alone! I do not really understand that either. It's a non-standard reshaping of the idiom "one and th

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-17 Thread Terry Reedy
Martin v. Löwis wrote: Does he intend to maintain two separate codebases, one 2.x and the other 3.x? I think I have no other choice. Why? Is theoretically possible to maintain an unique code base for both 2.x and 3.x? That is certainly possible! One might have to make tradeoffs wrt. readabilit

Windows Tablet RealTimeStylus in Python

2009-01-17 Thread Damon
I have a Windows Tablet machine, running XP Tablet Edition, and I want to access the stylus data from Python. If anyone has done this themselves, I'd be very grateful for a description of what worked. Otherwise, I'd be grateful for advice. I'm in way over my head, so what I describe below is prob

Re: Python 3: exec arg 1

2009-01-17 Thread Alan G Isaac
Alan G Isaac wrote: Is it intentional that ``exec`` cannot handle a TextIOWrapper? Bottom line: has ``execfile(filename)`` really become ``exec(open(filename).read())``? Is this a good thing? On 1/17/2009 4:20 PM Terry Reedy apparently wrote: Yes. Yes. OK. Why? Alan Isaac -- http://ma

Re: tp_base, ob_type, and tp_bases

2009-01-17 Thread Terry Reedy
Martin v. Löwis wrote: So, the documentation states that ob_type is a pointer to the type's Next, we have tp_base. That's defined as "an optional pointer to a base type from which type properties are inherited." The value of tp_base is then added to the tp_bases tuple. This is confusing me.

Re: Socket issues

2009-01-17 Thread twistedduck9
On 17 Jan, 21:32, Jeff McNeil wrote: > On Jan 17, 4:11 pm, twistedduck9 > wrote: > > > > > My hosting provider (Streamline) have said that there is no firewall > > (it's a dedicated server). Either way the code I'm using is: > > > Listening socket: > > import socket > > mysock = socket.socket(soc

Re: Jerry Pournelle gives award to Python and Guido for 2008

2009-01-17 Thread Terry Reedy
Richard Hanson wrote: [NB: Blatant Python advocacy (and OP self-promotion).] Jerry Pournelle commends Python and Guido in "The Annual Orchid and Onions Parade" portion of his Chaos Manor Reviews column: A reader [full-disclosure: t

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-17 Thread Paul Rubin
Bruno Desthuilliers writes: > Once again, there's quite a lot to learn from > the story of Ariane 5. Do you know what actually happened with Ariane 5? The failure was because "smart" humans overrode the language enforced protection by casting a floating point number down to a 16-bit integer, whi

Re: process command line parameter

2009-01-17 Thread Cameron Simpson
On 17Jan2009 13:28, asit wrote: | Recently I was coding a link extractor. It's a command line stuff and | takes parameter as argument. | I found that the in operator is not always helpful. | eg. if "--all" in sys.argv: |print "all links will be printed" Indeed. While I can't speak for

Re: python3.0 base64 error

2009-01-17 Thread Terry Reedy
yang michael wrote: I use base64 module on python3.0 like: import base64 b="hello world" a=base64.b64encode(b) print(a) but when i run it,it catch a error: Traceback (most recent call last): File "/home/jackie-yang/yd5m19/pythonstudy/test.py", line 4, in a=base64.b64encode(b) File "/us

Re: s=ascii(hexlify(urandom(10)))

2009-01-17 Thread gert
On Jan 17, 9:08 pm, "Martin v. Löwis" wrote: > > I expected that py3 did not converted the b'...' indication too ? > > > b'afc76815e3fc429fa9d7' > > You mean, just because you invoked the ascii() builtin, the b > prefix should disappear? Re-read the documentation of the > ascii() builtin - it prob

Re: Socket issues

2009-01-17 Thread Jeff McNeil
On Jan 17, 4:11 pm, twistedduck9 wrote: > My hosting provider (Streamline) have said that there is no firewall > (it's a dedicated server). Either way the code I'm using is: > > Listening socket: > import socket > mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > mysock.bind (('79.99.43

process command line parameter

2009-01-17 Thread asit
Recently I was coding a link extractor. It's a command line stuff and takes parameter as argument. I found that the in operator is not always helpful. eg. if "--all" in sys.argv: print "all links will be printed" its not helpful when some attribute value is sent in command line paramete

Re: Python 3: exec arg 1

2009-01-17 Thread Terry Reedy
Alan G Isaac wrote: In Python 3, you can no longer ``exec(open(filename))``. I guess the reason is that in 3.0 ``open`` returns a stream, instead of open file, and exec wants "a string, bytes, or code object" and not a "TextIOWrapper". So it returns an error. Is it intentional that ``exec`` can

Re: Socket issues

2009-01-17 Thread twistedduck9
My hosting provider (Streamline) have said that there is no firewall (it's a dedicated server). Either way the code I'm using is: Listening socket: import socket mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) mysock.bind (('79.99.43.58', 2727)) mysock.listen(1) while True: channel,

Re: Socket issues

2009-01-17 Thread Gary M. Josack
twistedduck9 wrote: Hi all I've been trying to set up sockets on my server (running Apache/2.2.3) using python and I'm confused as to why it doesn't work. I set up a simple listening script which runs without error, and works if a connecting script is run on the same server. However, if I try t

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-17 Thread Bruno Desthuilliers
Russ P. a écrit : On Jan 16, 5:22 am, Steve Holden wrote: Russ P. wrote: [...] I spent *way* too much time on that post. I really need to quit spending my time refuting the baloney that passes for wisdom here. He who cannot ignore baloney is doomed to refute it. Yeah, and I should reall

Re: tuple methods: documentation missing

2009-01-17 Thread Ned Deily
In article <8rncl.212$aw2@nwrddc02.gnilink.net>, Alan G Isaac wrote: > Is this another lacuna or am I overlooking it? > I cannot find the 3.0 documentation of string > formatting with the ``%`` operator. --

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-17 Thread Bruno Desthuilliers
Russ P. a écrit : On Jan 15, 12:21 pm, Bruno Desthuilliers wrote: Once again, the important point is that there's a *clear* distinction between interface and implementation, and that you *shouldn't* mess with implementation. If you "*shouldn't* mess with the implementation", then what is wro

Re: reading file to list

2009-01-17 Thread André Thieme
Xah Lee schrieb: comp.lang.lisp,comp.lang.scheme,comp.lang.functional,comp.lang.python,comp.lang.ruby Here's a interesting toy problem posted by Drew Krause to comp.lang.lisp: On Jan 16, 2:29 pm, Drew Krause wrote [paraphrased a bit]: OK, I want to create a nested list

Socket issues

2009-01-17 Thread twistedduck9
Hi all I've been trying to set up sockets on my server (running Apache/2.2.3) using python and I'm confused as to why it doesn't work. I set up a simple listening script which runs without error, and works if a connecting script is run on the same server. However, if I try to connect using Telnet

Re: s=ascii(hexlify(urandom(10)))

2009-01-17 Thread Martin v. Löwis
> I expected that py3 did not converted the b'...' indication too ? > > b'afc76815e3fc429fa9d7' You mean, just because you invoked the ascii() builtin, the b prefix should disappear? Re-read the documentation of the ascii() builtin - it probably does something completely different from what you e

Re: braces fixed '#{' and '#}'

2009-01-17 Thread Martin P. Hellwig
Roy Smith wrote: In article , Steve Holden wrote: Roy Smith wrote: In article <6264e675-ddd4-446a-822a-cc82e8f87...@w1g2000prk.googlegroups.com>, v4vijayakumar wrote: I saw some code where someone is really managed to import braces from __future__. ;) def test(): #{ print "hell

Re: braces fixed '#{' and '#}'

2009-01-17 Thread Roy Smith
In article , Steve Holden wrote: > Roy Smith wrote: > > In article > > <6264e675-ddd4-446a-822a-cc82e8f87...@w1g2000prk.googlegroups.com>, > > v4vijayakumar wrote: > > > >> I saw some code where someone is really managed to import braces from > >> __future__. ;) > >> > >> def test(): > >> #{

Re: English-like Python

2009-01-17 Thread Tim Rowe
2009/1/16 has : > http://www.alice.org/ Ooh, "JavaLikeSyntax.py" indeed! Why not "PythonLikeSyntax", since that's apparently what they used! -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Python 3: exec arg 1

2009-01-17 Thread Alan G Isaac
In Python 3, you can no longer ``exec(open(filename))``. I guess the reason is that in 3.0 ``open`` returns a stream, instead of open file, and exec wants "a string, bytes, or code object" and not a "TextIOWrapper". So it returns an error. Is it intentional that ``exec`` cannot handle a TextIOWr

import urllib2 fails with Python 2.6.1 on Vista

2009-01-17 Thread Scott MacDonald
I googled a bit this morning search for an answer to this problem but have come up empty so far. Can anyone help? Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import urllib2 Traceba

Re: python3.0 base64 error

2009-01-17 Thread MRAB
yang michael wrote: I use base64 module on python3.0 like: import base64 b="hello world" Try: b = b"hello world" instead. a=base64.b64encode(b) print(a) but when i run it,it catch a error: Traceback (most recent call last): File "/home/jackie-yang/yd5m19/pythonstudy/test.py", line 4

Re: psycopg2 weirdness

2009-01-17 Thread Philip Semanchuk
On Jan 17, 2009, at 12:48 PM, Neha Gupta wrote: Hey, I only have little experience with web.py and psycopg2 and am running into a weird problem, I'd appreciate any help I can get with debugging it. Hi Neha, There's a lot of pieces involved here and your subject implies you've isolated the

Re: psycopg2 weirdness

2009-01-17 Thread Tino Wildenhain
Neha Gupta wrote: Hey, ... crs_dep_hour, origin from flightdata where date = '" + date + "' group ^^^ never ever do that! Even more when input comes from user. The correct form is cur.exec("... date = %s group by ...",(date,)) ple

python3.0 base64 error

2009-01-17 Thread yang michael
I use base64 module on python3.0 like: import base64 b="hello world" a=base64.b64encode(b) print(a) but when i run it,it catch a error: Traceback (most recent call last): File "/home/jackie-yang/yd5m19/pythonstudy/test.py", line 4, in a=base64.b64encode(b) File "/usr/local/lib/python3.0/

Re: reading file to list

2009-01-17 Thread Tino Wildenhain
MRAB wrote: Tino Wildenhain wrote: Xah Lee wrote: comp.lang.lisp,comp.lang.scheme,comp.lang.functional,comp.lang.python,comp.lang.ruby ... OK, I want to create a nested list in Lisp (always of only integers) from a text file, such that each line in the text file would be represented as a s

Re: reading file to list

2009-01-17 Thread Xah Lee
On Jan 17, 9:34 am, Xah Lee wrote: > The code in my previous elisp code got a bump. It should be: > ... > • A Ruby Illustration of Lisp Problems > http://xahlee.org/UnixResource_dir/writ/lisp_problems_by_ruby.html Sorry again. More correction: (defun read-lines (file) "Return a list of lines

psycopg2 weirdness

2009-01-17 Thread Neha Gupta
Hey, I only have little experience with web.py and psycopg2 and am running into a weird problem, I'd appreciate any help I can get with debugging it. I wrote a simple program that works and I don't see any crash: import psycopg2 try: database_conn = psycopg2.connect("dbname='dbname'

Jerry Pournelle gives award to Python and Guido for 2008

2009-01-17 Thread Richard Hanson
[NB: Blatant Python advocacy (and OP self-promotion).] Jerry Pournelle commends Python and Guido in "The Annual Orchid and Onions Parade" portion of his Chaos Manor Reviews column: > A reader [full-disclosure: that reader was me] nomina

Re: reading file to list

2009-01-17 Thread MRAB
Tino Wildenhain wrote: Xah Lee wrote: comp.lang.lisp,comp.lang.scheme,comp.lang.functional,comp.lang.python,comp.lang.ruby ... OK, I want to create a nested list in Lisp (always of only integers) from a text file, such that each line in the text file would be represented as a sublist in the

Re: reading file to list

2009-01-17 Thread Xah Lee
On Jan 17, 9:16 am, Xah Lee wrote: > Here's a interesting toy problem posted by Drew Krause to > comp.lang.lisp: > ... The code in my previous elisp code got a bump. It should be: (defun read-lines (file) "Return a list of lines in FILE." (with-temp-buffer (insert-file-contents file)

Re: reading file to list

2009-01-17 Thread Tino Wildenhain
Xah Lee wrote: comp.lang.lisp,comp.lang.scheme,comp.lang.functional,comp.lang.python,comp.lang.ruby ... OK, I want to create a nested list in Lisp (always of only integers) from a text file, such that each line in the text file would be represented as a sublist in the 'imported' list. example

Re: figuring week of the day....

2009-01-17 Thread tekion
On Jan 9, 6:05 am, Tim Chase wrote: > Tim Chase wrote: > > tekion wrote: > >> Is there a module where you could figure week of the day, like where > >> it starts and end. I need to do this for a whole year. Thanks. > > > the monthcalendar() call returns the whole month's calendar which > > may be

Re: Noob question: Is all this typecasting normal?

2009-01-17 Thread Tim Rowe
2009/1/3 Russ P. : > So unless you think the standard library will someday include code for > air traffic management, I'll stick with camelCase, and I'll thank you > for not making an issue of it. Another late comment, sorry, but as an air traffic management safety consultant, I'm quite intereste

Re: reading file to list

2009-01-17 Thread Xah Lee
comp.lang.lisp,comp.lang.scheme,comp.lang.functional,comp.lang.python,comp.lang.ruby Here's a interesting toy problem posted by Drew Krause to comp.lang.lisp: On Jan 16, 2:29 pm, Drew Krause wrote [paraphrased a bit]: OK, I want to create a nested list in Lisp (always of

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-17 Thread mario ruggier
Just to add that a further potential subversion possibility could have been to build the expr in some way from within a template, and then dynamically setting that string as the source of a new template with from_string=True. This is precisely the reason why **from within a template** evoque has ne

Re: Noob question: Is all this typecasting normal?

2009-01-17 Thread Steven D'Aprano
On Sat, 17 Jan 2009 06:09:29 -0800, Aahz wrote: > You are missing the point: suppose you write a useful library in your > air traffic management application, maybe one that does a good job of > handling user input. If you have done a proper job of abstracting it > from your application as a whole

Re: reverse dict lookup & Relation class

2009-01-17 Thread Steven D'Aprano
On Sat, 17 Jan 2009 00:24:21 -0800, Aaron Brady wrote: > Can you make it work for a 3-way lookup? What do you mean "3-way lookup"? I'm going to take a guess... A maps to B, B maps to C, and C maps to A. Is that what you mean? -- Steven -- http://mail.python.org/mailman/listinfo/python-lis

Re: tuple methods: documentation missing

2009-01-17 Thread Alan G Isaac
On 1/16/2009 6:44 PM Terry Reedy apparently wrote: http://bugs.python.org/issue4966 Is this another lacuna or am I overlooking it? I cannot find the 3.0 documentation of string formatting with the ``%`` operator. Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: vb2py status?

2009-01-17 Thread Fuzzyman
On Jan 17, 3:52 pm, Vito De Tullio wrote: > Giampaolo Rodola' wrote: > >> > So is vb2py dead? If not, any idea when it'll support python 3? > >> I don't know this vb2py, but you can do a 2 pass conversion > >> [vb] -> (vb2py) -> [py2] -> (2to3) -> [py3] > > ...and presumibly get something which do

Re: tp_base, ob_type, and tp_bases

2009-01-17 Thread Jeff McNeil
On Jan 17, 11:09 am, Jeff McNeil wrote: > On Jan 17, 10:50 am, "Martin v. Löwis" wrote: > > > > > > So, the documentation states that ob_type is a pointer to the type's > > > type, or metatype. Rather, this is a pointer to the new type's > > > metaclass? > > > That's actually the same. *Every* ob

Re: tp_base, ob_type, and tp_bases

2009-01-17 Thread Jeff McNeil
On Jan 17, 10:50 am, "Martin v. Löwis" wrote: > > So, the documentation states that ob_type is a pointer to the type's > > type, or metatype. Rather, this is a pointer to the new type's > > metaclass? > > That's actually the same. *Every* ob_type field points to the object's > type, e.g. for strin

Re: tp_base, ob_type, and tp_bases

2009-01-17 Thread Martin v. Löwis
> So, the documentation states that ob_type is a pointer to the type's > type, or metatype. Rather, this is a pointer to the new type's > metaclass? That's actually the same. *Every* ob_type field points to the object's type, e.g. for strings, integers, tuples, etc. That includes type objects, whe

Re: vb2py status?

2009-01-17 Thread Vito De Tullio
Giampaolo Rodola' wrote: >> > So is vb2py dead? If not, any idea when it'll support python 3? >> I don't know this vb2py, but you can do a 2 pass conversion >> [vb] -> (vb2py) -> [py2] -> (2to3) -> [py3] > ...and presumibly get something which doesn't work at all. =) why? AFAIK there aren't probl

Pyro deadlock

2009-01-17 Thread MatthewS
I'd like to know if the following behavior is expected and can be avoided: I have a Pyro server object that maintains a queue of work, and multiple Pyro worker objects that take work off the queue by calling a method on the server (get_work) and then return the work to the server by calling another

tp_base, ob_type, and tp_bases

2009-01-17 Thread Jeff McNeil
Hi all, In an effort to get (much) better at writing Python code, I've been trying to follow and document what the interpreter does from main in Modules/python.c up through the execution of byte code. Mostly for my own consumption and benefit, but I may blog it if it turns out half way decent. An

Re: braces fixed '#{' and '#}'

2009-01-17 Thread Steve Holden
Roy Smith wrote: > In article > <6264e675-ddd4-446a-822a-cc82e8f87...@w1g2000prk.googlegroups.com>, > v4vijayakumar wrote: > >> I saw some code where someone is really managed to import braces from >> __future__. ;) >> >> def test(): >> #{ >> print "hello" >> #} > > That usage is obsolete

Re: braces fixed '#{' and '#}'

2009-01-17 Thread Roy Smith
In article <6264e675-ddd4-446a-822a-cc82e8f87...@w1g2000prk.googlegroups.com>, v4vijayakumar wrote: > I saw some code where someone is really managed to import braces from > __future__. ;) > > def test(): > #{ > print "hello" > #} That usage is obsolete. Current best practice is: def

Re: pep-8 vs. external interfaces?

2009-01-17 Thread Aahz
In article <27c6b149-3a5f-478d-a6fc-da87a66b9...@r36g2000prf.googlegroups.com>, Carl Banks wrote: >On Jan 4, 1:47=A0pm, Roy Smith wrote: >> >> Or, I could draw a line in the sand and say, "If it's a protocol >> primitive, it stays as written. =A0Otherwise, it's pep-8". =A0That's a >> little ugli

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-17 Thread Martin v. Löwis
>> Does he intend to maintain two separate codebases, one 2.x and the >> other 3.x? > > I think I have no other choice. > Why? Is theoretically possible to maintain an unique code base for > both 2.x and 3.x? That is certainly possible! One might have to make tradeoffs wrt. readability sometimes,

Re: LGPL license for Qt 4.5

2009-01-17 Thread eliben
On Jan 14, 2:57 pm, sturlamolden wrote: > According to a Norwegian publication, Nokia will release Qt under LGPL > as of version 4.5. > > If I had stocks in Riverbank Computing ltd., I would sell them now... > Unlikely... The switch of Qt to LGPL will almost certainly vastly increase the Qt user

Re: vb2py status?

2009-01-17 Thread Giampaolo Rodola'
On 17 Gen, 11:05, Vito De Tullio wrote: > axtens wrote: > > So is vb2py dead? If not, any idea when it'll support python 3? > > I don't know this vb2py, but you can do a 2 pass conversion > > [vb] -> (vb2py) -> [py2] -> (2to3) -> [py3] > > -- > By ZeD ...and presumibly get something which doesn't

  1   2   >