Overcoming herpetophobia (or what's up w/ Python scopes)?

2005-06-17 Thread kj
question is: is there any tutorial on Python scoping aimed at diehard Perlheads? Thanks! kj -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded. -- http://mail.python.org/mailman/listinfo/python-list

How to send a POST request?

2008-06-06 Thread kj
Hi. Sorry for this very clueless question, but how does one write in Python an HTTP client that can send a POST request? The modules I've found (e.g. urllib, urllib2), as far as I can tell, seem to be limited to GET requests. (I could be wrong though; please correct me if this is so.) TIA!

Re: How to send a POST request?

2008-06-06 Thread kj
In [EMAIL PROTECTED] kj [EMAIL PROTECTED] writes: Hi. Sorry for this very clueless question, but how does one write in Python an HTTP client that can send a POST request? The modules I've found (e.g. urllib, urllib2), as far as I can tell, seem to be limited to GET requests. (I could be wrong

Need help porting Perl function

2008-06-07 Thread kj
Hi. I'd like to port a Perl function that does something I don't know how to do in Python. (In fact, it may even be something that is distinctly un-Pythonic!) The original Perl function takes a reference to an array, removes from this array all the elements that satisfy a particular

Re: How to send a POST request?

2008-06-07 Thread kj
Thanks to Jeff and subeen for the helpful comments and suggestions. Kynn -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded. -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help porting Perl function

2008-06-07 Thread kj
This function will take a list of integers and modify it in place such that it removes even integers. The removed integers are returned as a new list snip Great! Thanks! kynn -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it,

Re: Need help porting Perl function

2008-06-08 Thread kj
In [EMAIL PROTECTED] John Machin [EMAIL PROTECTED] writes: It's nothing to do with list comprehensions, which are syntactical sugar for traditional loops. You could rewrite your list comprehension in the traditional manner... and it would still fail for the same reason: mutating the list over

Re: Need help porting Perl function

2008-06-08 Thread kj
In [EMAIL PROTECTED] kj [EMAIL PROTECTED] writes: In [EMAIL PROTECTED] John Machin [EMAIL PROTECTED] writes: It's nothing to do with list comprehensions, which are syntactical sugar for traditional loops. You could rewrite your list comprehension in the traditional manner... and it would still

How to get full path to script?

2008-06-08 Thread kj
How can a script know its absolute path? (__file__ only gives the path it was used to invoke the script.) Basically, I'm looking for the Python equivalent of Perl's FindBin. The point of all this is to make the scripts location the reference point for the location of other files, as part of

Re: How to get full path to script?

2008-06-08 Thread kj
In [EMAIL PROTECTED] Mark Tolonen [EMAIL PROTECTED] writes: import os print os.path.abspath(__file__) Great. Thanks! Kynn -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded. --

Q re documentation Python style

2008-06-08 Thread kj
I'm a Perlhead trying to learn the Way of Python. I like Python overall, but every once in a while I find myself trying to figure out why Python does some things the way it does. At the moment I'm scratching my head over Python's docstrings. As far as I understand this is the standard way to

Re: Q re documentation Python style

2008-06-09 Thread kj
Wow. That was a great bunch of advice. Thank you all very much! Kynn -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get full path to script?

2008-06-09 Thread kj
In [EMAIL PROTECTED] Mike Driscoll [EMAIL PROTECTED] writes: For my compiled scripts, I usually use this variation: path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]))) Thanks. But why the os.path.join()? (BTW, I did read the docs before posting, but they make no sense to me;

Strange bug doesn't occur in Pydb

2008-06-11 Thread kj
I'm running into a strange seg fault with the module cjson. The strange part is that it does not occur when I run the code under Emacs' Pydb. Here's an example: import sys, cjson d1 = {'a': 1, 'b': 2, 'c': 3} print sys.version j1 = cjson.encode(d1) print j1 # should print the string

Re: Strange bug doesn't occur in Pydb

2008-06-12 Thread kj
In [EMAIL PROTECTED] Diez B. Roggisch [EMAIL PROTECTED] writes: kj schrieb: I'm running into a strange seg fault with the module cjson. The strange part is that it does not occur when I run the code under Emacs' Pydb. Here's an example: import sys, cjson d1 = {'a': 1, 'b': 2, 'c

Re: Strange cjson bug doesn't occur in Pydb

2008-06-12 Thread kj
[Note: I changed the subject line to make it more informative.] In [EMAIL PROTECTED] Diez B. Roggisch [EMAIL PROTECTED] writes: kj wrote: In [EMAIL PROTECTED] Diez B. Roggisch [EMAIL PROTECTED] writes: kj schrieb: I'm running into a strange seg fault with the module cjson. The strange

Python noob's simple config problem

2008-06-12 Thread kj
I'm sure this is a simple, but recurrent, problem for which I can't hit on a totally satisfactory solution. As an example, suppose that I want write a module X that performs some database access. I expect that 99.999% of the time, during the foreseeable future, the database connection

Re: Python noob's simple config problem

2008-06-13 Thread kj
In [EMAIL PROTECTED] =?iso-8859-1?q?Robin_K=E5veland?= Hansen [EMAIL PROTECTED] writes: On Thu, 12 Jun 2008 21:32:34 +, kj wrote: I'm sure this is a simple, but recurrent, problem for which I can't hit on a totally satisfactory solution. As an example, suppose that I want write

How to sort very large arrays?

2008-06-13 Thread kj
I'm downloading some very large tables from a remote site. I want to sort these tables in a particular way before saving them to disk. In the past I found that the most efficient way to do this was to piggy-back on Unix's highly optimized sort command. So, from within a Perl script, I'd

Noob: finding my way around the docs...

2008-06-19 Thread kj
) to the fact that if the Perl module Foo::Bar::Baz is installed on our system, all I need to do to read its full-blown documentation in all its glory is to type perldoc Foo::Bar::Baz at the command line. Is there anything like this in Python? TIA! kj -- NOTE: In my address everything before the first

Why no output from xml.dom.ext.PrettyPrint?

2008-06-19 Thread kj
OK, the following should work but doesn't, and I can't figure out why: from xml.marshal.generic import dumps dumps( ( 1, 2.0, 'foo', [3,4,5] ) ) '?xml version=1.0?marshaltupleint1/intfloat2.0/floatstringfoo/stringlist id=i2int3/intint4/intint5/int/list/tuple/marshal' from xml.dom.ext

Re: Noob: finding my way around the docs...

2008-06-20 Thread kj
In [EMAIL PROTECTED] Matimus [EMAIL PROTECTED] writes: If you are in the interpreter and you type: help(foo.bar.baz) you get the embeded documentation. I usually go straight to the `global module index` http://docs.python.org/m= odindex.html Thanks! kynn -- NOTE: In my address everything

Re: Why no output from xml.dom.ext.PrettyPrint?

2008-06-20 Thread kj
In [EMAIL PROTECTED] John Machin [EMAIL PROTECTED] writes: On Jun 20, 7:17 am, kj [EMAIL PROTECTED] wrote: OK, the following should work but doesn't, and I can't figure out why: from xml.marshal.generic import dumps dumps( ( 1, 2.0, 'foo', [3,4,5] ) ) '?xml version=1.0?marshaltupleint1

ISO dict = xml converter

2008-06-20 Thread kj
Hi. Does anyone know of a module that will take a suitable Python dictionary and return the corresponding XML structure? In Perl I use XML::Simple's handy XMLout function: use XML::Simple 'XMLout'; my %h = ( 'Foo' = +{ 'Bar' = +{

ISO books of official Python docs

2008-01-09 Thread kj
Is it possible to buy the official Python docs in book form? If so, I'd very much appreciate the name(s) and author(s) of the book(s). TIA! kynnjo -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded. --

Re: ISO books of official Python docs

2008-01-10 Thread kj
In [EMAIL PROTECTED] gordyt [EMAIL PROTECTED] writes: Howdy kynnjo, Is it possible to buy the official Python docs in book form? If so, I'd very much appreciate the name(s) and author(s) of the book(s). I haven't seen them in print form, but you can download PDF's from here:

ISO Python example projects (like in Perl Cookbook)

2008-01-10 Thread kj
I'm looking for example implementations of small projects in Python, similar to the ones given at the end of most chapters of The Perl Cookbook (2nd edition, isbn: 0596003137). (Unfortunately, the otherwise excellent Python Cookbook (2nd edition, isbn: 0596007973), by the same publisher

Text-based data inspector for Python?

2008-01-24 Thread kj
I've only recently started programming in Python, trying to wean myself from Perl. One of the things I *really* miss from Perl is a 100% mouse-free data inspector, affectionally known as the Perl debugger, PerlDB, or just perl -d. With it I can examine the most elaborate data structures with

Re: Text-based data inspector for Python?

2008-01-25 Thread kj
In [EMAIL PROTECTED] Paddy [EMAIL PROTECTED] writes: python -h gives me: ... Other environment variables: PYTHONSTARTUP: file executed on interactive startup (no default) ... Sweet. Thanks! kynn -- NOTE: In my address everything before the first period is backwards; and the last

Re: Text-based data inspector for Python?

2008-01-25 Thread kj
In [EMAIL PROTECTED] Terry Jones [EMAIL PROTECTED] writes: kj == kj [EMAIL PROTECTED] writes: You actually liked the perl debugger... gasp! Still do, in fact!. OK, I used it too, but it left a few things to be desired... I'd love to read your thoughts on the matter. My biggest complain

Re: Text-based data inspector for Python?

2008-01-25 Thread kj
In [EMAIL PROTECTED] Paddy [EMAIL PROTECTED] writes: I tend to do the following at the python prompt: from pprint import pprint as pp Thanks, that's a good one to know, but isn't there a way to automate it??? I looked around, but I couldn't find the name of any *rc-type file that would hold

Python noob SOS (any [former?] Perlheads out there?)

2008-01-29 Thread kj
For many months now I've been trying to learn Python, but I guess I'm too old a dog trying to learn new tricks... For better or worse, I'm so used to Perl when it comes to scripting, that I'm just having a very hard time getting a hang of The Python Way. It's not the Python syntax that I'm

Re: Python noob SOS (any [former?] Perlheads out there?)

2008-01-30 Thread kj
In [EMAIL PROTECTED] Reedick, Andrew [EMAIL PROTECTED] writes: Be that as it may, the activation barrier to using Python for my scripting remains too high. =20 I'd written a Perl module to facilitate the writing of scripts. It contained all my boilerplate code for parsing and validating

Re: Python noob SOS (any [former?] Perlheads out there?)

2008-01-30 Thread kj
In [EMAIL PROTECTED] Wildemar Wildenburger [EMAIL PROTECTED] writes: kj wrote: Is there any good reading (to ease the transition) for Perl programmers trying to learn Python? www.diveintopython.org Thanks. Not for Perl programmers specifically, but it looks useful all the same. kynn

x, = y (???)

2008-07-17 Thread kj
I just came across an assignment of the form x, = y where y is a string (in case it matters). 1. What's the meaning of the comma in the LHS of the assignment? 2. How could I have found this out on my own? (Regarding (2) above, I consulted the index of several Python reference books but I

Re: x, = y (???)

2008-07-18 Thread kj
In [EMAIL PROTECTED] Matthew Woodcraft [EMAIL PROTECTED] writes: kj wrote: I still don't get it. If we write y = 'Y' x, = y what's the difference now between x and y? And if there's no difference, what's the point of performing such unpacking? If y really is is a string, I think

backspace problems

2008-07-29 Thread kj
If I'm in the python interactive interpreter, I get a beep when I hit the backspace key. I must confess, though, that my terminal is complicated, to put it mildly: I work on a Mac running Leopard; I open a Terminal session, and through it I ssh to an Ubuntu server; on this server I connect to a

Re: backspace problems

2008-07-29 Thread kj
In [EMAIL PROTECTED] kj [EMAIL PROTECTED] writes: snip Please ignore my question. I found a general solution that works not only for the python interactive interpreter but also for all programs that have a readline-type interaction. This solution has nothing to do with Python, but if anyone's

DB access without object-relation mapping?

2008-07-29 Thread kj
Python noob here. I want to write a script that creates and populates a simple Postgres database. The word on the street is to use something like SQLAlchemy for database access in Python, but my experience in the past with packages that perform automated SQL generation has been awful, so I

Re: DB access without object-relation mapping?

2008-07-29 Thread kj
In [EMAIL PROTECTED] Tim Henderson [EMAIL PROTECTED] writes: I believe there are a couple of options but pyscopg, and PyGreSQL seem to be popular. Great. Thanks! kynn -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should

iterating by twos

2008-07-29 Thread kj
Is there a special pythonic idiom for iterating over a list (or tuple) two elements at a time? I mean, other than for i in range(0, len(a), 2): frobnicate(a[i], a[i+1]) ? I think I once saw something like for (x, y) in forgotten_expression_using(a): frobnicate(x, y) Or maybe I

Where is the documentation for psycopg2?

2008-07-29 Thread kj
Hi. I can't find any documentation for psycopg2. I'm a noob, so I'm sure I'm just not looking in the right place... Anybody know where it is? TIA! kynn -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be

Re: iterating by twos

2008-07-29 Thread kj
Thanks for all the replies. I learned a lot! kynn -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded. -- http://mail.python.org/mailman/listinfo/python-list

static variables in Python?

2008-07-29 Thread kj
Yet another noob question... Is there a way to mimic C's static variables in Python? Or something like it? The idea is to equip a given function with a set of constants that belong only to it, so as not to clutter the global namespace with variables that are not needed elsewhere. For

Re: Where is the documentation for psycopg2?

2008-07-29 Thread kj
In [EMAIL PROTECTED] Matthew Woodcraft [EMAIL PROTECTED] writes: kj [EMAIL PROTECTED] wrote: Hi. I can't find any documentation for psycopg2. I'm a noob, so I'm sure I'm just not looking in the right place... Anybody know where it is? For basic use, psycopg2 follows the dbapi, which

Re: static variables in Python?

2008-07-29 Thread kj
In [EMAIL PROTECTED] Larry Bates [EMAIL PROTECTED] writes: kj wrote: Yet another noob question... Is there a way to mimic C's static variables in Python? Or something like it? The idea is to equip a given function with a set of constants that belong only to it, so as not to clutter

Re: iterating by twos

2008-07-29 Thread kj
In [EMAIL PROTECTED] Terry Reedy [EMAIL PROTECTED] writes: kj wrote: Is there a special pythonic idiom for iterating over a list (or tuple) two elements at a time? I mean, other than for i in range(0, len(a), 2): frobnicate(a[i], a[i+1]) There have been requests to add a grouper

how to split text into lines?

2008-07-30 Thread kj
In Perl, one can break a chunk of text into an array of lines while preserving the trailing line-termination sequence in each line, if any, by splitting the text on the regular expression /^/: DB1 x split(/^/, foo\nbar\nbaz) 0 'foo ' 1 'bar ' 2 'baz' But nothing like this seems to work in

Re: how to split text into lines?

2008-07-30 Thread kj
In [EMAIL PROTECTED] kj [EMAIL PROTECTED] writes: In Perl, one can break a chunk of text into an array of lines while preserving the trailing line-termination sequence in each line, if any, by splitting the text on the regular expression /^/: DB1 x split(/^/, foo\nbar\nbaz) 0 'foo ' 1 'bar

overriding file.readline: an integer is required

2008-07-30 Thread kj
I'm trying to subclass file, overriding the readline method. The new method definition begins with def readline(self, size=None): line = self.file.readline(size) # etc., etc. ...where the self.file attribute is a regular file object. This works fine if I invoke the new

How to troubleshoot hanging script?

2008-08-05 Thread kj
Hi! I have a Pythonoob question. I have a script that hangs indefinitely at random times; the only thing to do at this point is to kill it. I'm looking for suggestions on how to troubleshoot and debug the problem. I'm not even sure of where exactly the script is hanging, though I suspect it

How to code dynamically created methods?

2007-06-20 Thread kj
of _auto). What's the right way to do this? Thanks! kj -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to code dynamically created methods?

2007-06-20 Thread kj
Nevermind, I found the problem... Thanks, kj In [EMAIL PROTECTED] kj [EMAIL PROTECTED] writes: I've tried a bazillion ways to code dynamically generated methods, to no avail. The following snippet is a very simplified (and artificial) demo of the problem I'm running into, featuring my

ISO programming projects

2007-04-01 Thread kj
) or not terribly useful to the average person (e.g. a function that efficiently computes the n-th Fibonacci number). Any pointers would be much appreciated. kj -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded. -- http

Aaaargh! global name 'eggz' is not defined

2009-10-29 Thread kj
How can one check that a Python script is lexically correct? As my Python apps grow in complexity and execution, I'm finding it more often the situation in which a program dies after a lengthy (i.e. expensive) run because the execution reaches, say, a typo. Of course, this typo needs to be

How can module determine its own path?

2009-10-30 Thread kj
How can a module determine the path of the file that defines it? (Note that this is, in the general case, different from sys.argv[0].) TIA! kynn -- http://mail.python.org/mailman/listinfo/python-list

Re: How can module determine its own path?

2009-10-30 Thread kj
In 7e456639-9dbb-41ba-ae36-042a034fa...@y32g2000prd.googlegroups.com AK Eric warp...@sbcglobal.net writes: How can a module determine the path of the file that defines it? (Note that this is, in the general case, different from sys.argv[0].) __file__ Also: import inspect print

import bug

2009-10-31 Thread kj
I'm running into an ugly bug, which, IMHO, is really a bug in the design of Python's module import scheme. Consider the following directory structure: ham |-- __init__.py |-- re.py `-- spam.py ...with the following very simple files: % head ham/*.py == ham/__init__.py == == ham/re.py ==

Re: import bug

2009-10-31 Thread kj
In 4aec591e$0$7629$9b4e6...@newsspool1.arcor-online.net Stefan Behnel stefan...@behnel.de writes: kj, 31.10.2009 16:12: My sin appears to be having the (empty) file ham/re.py. So Python is confusing it with the re module of the standard library, and using it when the inspect module tries

How to test urllib|urllib2-using code?

2009-11-04 Thread kj
I want to write some tests for code that uses both urllib and urllib2. I would like to be able to run these tests locally. Are there modules to facilitate the writing of such tests (e.g. for setting up a mock web server locally, etc.)? BTW, in the Perl world, one very easy way to learn how

How to specify Python version in script?

2009-11-11 Thread kj
I have a script that must be run with Python 2.6.x. If one tries to run it with, say, 2.5.x, *eventually* it runs into problems and crashes. (The failure is quicker if one attempts to run it with Python 3.x.) Is there some way to specify at the very beginning of the script the acceptable

Re: How to specify Python version in script?

2009-11-11 Thread kj
In mailman.261.1257963528.2873.python-l...@python.org Benjamin Kaplan benjamin.kap...@case.edu writes: On Wed, Nov 11, 2009 at 12:16 PM, kj no.em...@please.post wrote: I have a script that must be run with Python 2.6.x. =A0If one tries to run it with, say, 2.5.x, *eventually* it runs

Re: How can a module know the module that imported it?

2009-11-11 Thread kj
In hdf9bq$59...@panix3.panix.com a...@pythoncraft.com (Aahz) writes: In article hdf63i$cm...@reader1.panix.com, kj no.em...@please.post wrote: The subject line says it all. You are probably trying to remove a screw with a hammer Worse: I'm trying to write Perl using Python! -- why don't you

Python Go

2009-11-11 Thread kj
I'm just learning about Google's latest: the GO (Go?) language. (e.g. http://golang.org or http://www.youtube.com/watch?v=rKnDgT73v8s). There are some distinctly Pythonoid features to the syntax, such as import this_or_that, the absence of parentheses at the top of flow control constructs, and

How can a module know the module that imported it?

2009-11-12 Thread kj
The subject line says it all. Thanks! kynn -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Go

2009-11-12 Thread kj
. When reading such code, to follow any method call one must check in at least two places: the base class and the subclass. The deeper the inheritance chain, the more places one must check. For every method call. Yeecch. Good riddance. kj -- http://mail.python.org/mailman/listinfo/python-list

A terminators' club for clp

2009-11-13 Thread kj
This is meta-question about comp.lang.python. I apologize in advance if it has been already discussed. Also, I don't know enough about the underlying mechanics of comp.lang.python, so this may be *totally unfeasible*, but how about giving a few bona fide *and frequent* clp posters the ability

Re: Python Go

2009-11-14 Thread kj
In 7xpr7lixnn@ruckus.brouhaha.com Paul Rubin http://phr...@nospam.invalid writes: It seems a little weird to me that they (Google) are concerned with the speed of the compiler, indicating that they plan to write enormous programs in the language. Fast compilation also means that Go can

Re: Python Go

2009-11-14 Thread kj
In 129a67e4-328c-42b9-9bf3-152f1b76f...@k19g2000yqc.googlegroups.com Michele Simionato michele.simion...@gmail.com writes: It does not look so primitive to me, compared to commonly used languages. I am pretty sure that they are missing a lot of the latest ideas on purpose. If they want to

Re: How to specify Python version in script?

2009-11-14 Thread kj
In 77b812a9-d82c-4aaa-8037-ec30366fc...@h34g2000yqm.googlegroups.com Yinon Ehrlich yinon...@gmail.com writes: Is there some way to specify at the very beginning of the script the acceptable range of Python versions? sys.hexversion, see

The ol' [[]] * 500 bug...

2009-11-16 Thread kj
...just bit me in the fuzzy posterior. The best I can come up with is the hideous lol = [[] for _ in xrange(500)] Is there something better? What did one do before comprehensions were available? I suppose in that case one would have to go all the way with lol = [None] * 500 for i in

Re: The ol' [[]] * 500 bug...

2009-11-16 Thread kj
In 6e20a31b-2218-49c5-a32c-5f0147db3...@k19g2000yqc.googlegroups.com Jon Clements jon...@googlemail.com writes: lol =3D map(lambda L: [], xrange(5)) [id(i) for i in lol] [167614956, 167605004, 167738060, 167737996, 167613036] Oh yeah, map! I'd forgotten all about it. Thanks! kynn --

Re: A terminators' club for clp

2009-11-16 Thread kj
In 7x3a4i56u7@ruckus.brouhaha.com Paul Rubin http://phr...@nospam.invalid writes: kj no.em...@please.post writes: frequent* clp posters the ability to *easily* delete spam from the comp.lang.python server? Um, this is usenet; there is no comp.lang.python server. Are you saying you want

ISO all functions+methods+classes without docstring

2009-12-23 Thread kj
I'm looking for a good way to get a listing of all the undocumented (i.e. docstring-less) functions, classes, and methods as defined in a (largish) library of files. What's a good way to get this information? TIA! -Kynn -- http://mail.python.org/mailman/listinfo/python-list

ISO module for binomial coefficients, etc.

2010-01-23 Thread kj
Before I go off to re-invent a thoroughly invented wheel, I thought I'd ask around for some existing module for computing binomial coefficient, hypergeometric coefficients, and other factorial-based combinatorial indices. I'm looking for something that can handle fairly large factorials (on the

How to set default encoding for print?

2010-01-31 Thread kj
It gets tedious to have to append .encode('utf-8') to all my unicode strings when I print them, as in: print foobar.encode('utf-8') I want to tell python to apply this encoding automatically to anything argument passed to print. How can I do this? TIA! K PS: BTW, sys.setdefaultencoding

How to pass Chinese characters as command-line arguments?

2010-01-31 Thread kj
I want to pass Chinese characters as command-line arguments to a Python script. My terminal has no problem displaying these characters, and passing them to the script, but I can't get Python to understand them properly. E.g. if I pass one such character to the simple script import sys print

Re: How to set default encoding for print?

2010-01-31 Thread kj
In 7slndhfno...@mid.uni-berlin.de Diez B. Roggisch de...@nospam.web.de writes: Am 31.01.10 16:38, schrieb kj: It gets tedious to have to append .encode('utf-8') to all my unicode strings when I print them, as in: print foobar.encode('utf-8') I want to tell python to apply

Re: How to pass Chinese characters as command-line arguments?

2010-01-31 Thread kj
In 7slr5ife6...@mid.uni-berlin.de Diez B. Roggisch de...@nospam.web.de writes: Am 31.01.10 16:52, schrieb kj: I want to pass Chinese characters as command-line arguments to a Python script. My terminal has no problem displaying these characters, and passing them to the script, but I can't

How to guard against bugs like this one?

2010-02-01 Thread kj
I just spent about 1-1/2 hours tracking down a bug. An innocuous little script, let's call it buggy.py, only 10 lines long, and whose output should have been, at most two lines, was quickly dumping tens of megabytes of non-printable characters to my screen (aka gobbledygook), and in the process

Re: How to guard against bugs like this one?

2010-02-02 Thread kj
Let me preface everything by thanking you and all those who replied for their comments. I have only one follow-up question (or rather, set of related questions) that I'm very keen about, plus a bit of a vent at the end. In pan.2010.02.02.03.28...@remove.this.cybersource.com.au Steven D'Aprano

Re: How to guard against bugs like this one?

2010-02-02 Thread kj
In mailman.1795.1265135424.28905.python-l...@python.org Terry Reedy tjre...@udel.edu writes: On 2/2/2010 9:13 AM, kj wrote: As for fixing it, unfortunately it's not quite so simple to fix without breaking backwards-compatibility. The opportunity to do so for Python 3.0 was missed

Re: How to guard against bugs like this one?

2010-02-02 Thread kj
(For reasons I don't understand Stephen Hansen's posts don't show in my news server. I became aware of his reply from a passing reference in one of Terry Reedy's post. Then I found Hansen's post online, and then an earlier one, and pasted the relevant portion below.) First, I don't shadow

Re: How to guard against bugs like this one?

2010-02-02 Thread kj
In mailman.1804.1265150872.28905.python-l...@python.org Terry Reedy tjre...@udel.edu writes: On 2/2/2010 2:43 PM, kj wrote: Inmailman.1795.1265135424.28905.python-l...@python.org Terry Reedytjre...@udel.edu writes: On 2/2/2010 9:13 AM, kj wrote: As for fixing it, unfortunately it's

test -- please ignore

2010-02-03 Thread kj
(my replies in a different comp.lang.python thread are getting rejected by the server; i have no problem posting to alt.test; and i'm trying to toubleshoot the problem further.) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to guard against bugs like this one?

2010-02-03 Thread kj
carried away by my annoyance with the Python import scheme. I'm sorry about it. Even though I don't think I can put to practice all of your advice, I can still learn a good deal from it. Cheers, ~kj Steve Holden st...@holdenweb.com writes: kj wrote: First, I don't shadow built in modules. Its

Re: How to guard against bugs like this one?

2010-02-03 Thread kj
In hkbv23$c0...@reader2.panix.com kj no.em...@please.post writes: Steve, I apologize for the snarkiness of my previous reply to you. After all, I started the thread by asking the forum for advice on how to avoid a certain kind of bugs, you were among those who gave me advice. So nothing other

Re: test -- please ignore

2010-02-04 Thread kj
In 87wryumvff@benfinney.id.au Ben Finney ben+pyt...@benfinney.id.au writes: kj no.em...@please.post writes: (my replies in a different comp.lang.python thread are getting rejected by the server; i have no problem posting to alt.test; and i'm trying to toubleshoot the problem further

Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread kj
Some people have mathphobia. I'm developing a wicked case of Unicodephobia. I have read a *ton* of stuff on Unicode. It doesn't even seem all that hard. Or so I think. Then I start writing code, and WHAM: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread kj
In 402ac982-0750-4977-adb2-602b19149...@m24g2000prn.googlegroups.com Jonathan Gardner jgard...@jonathangardner.net writes: On Feb 10, 11:09=A0am, kj no.em...@please.post wrote: FWIW, I'm using Python 2.6. =A0The example above happens to come from a script that extracts data from HTML files

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread kj
In xns9d1bcad3b50e1duncanbo...@127.0.0.1 Duncan Booth duncan.bo...@invalid.invalid writes: kj no.em...@please.post wrote: But to ground the problem a bit I'll say that the exception above happens during the execution of a statement of the form: x = '%s %s' % (y, z) Also, I found

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-11 Thread kj
In mailman.2379.1265906673.28905.python-l...@python.org mk mrk...@gmail.com writes: To make matters more complicated, str.encode() internally DECODES from string into unicode: nu '\xc4\x84' type(nu) type 'str' nu.encode() Traceback (most recent call last): File stdin, line 1, in

What's the word on using to comment-out?

2010-02-24 Thread kj
I think I remember, early in my learning of Python, coming across the commandment THOU SHALT NOT USE TRIPLE-QUOTES TO COMMENT-OUT LINES OF CODE, or something to that effect. But now I can't find it! Is my memory playing me a trick? After all, from what I've seen since then, the practice of

How to monitor memory usage within Python? (Linux)

2010-02-24 Thread kj
Is there some standard module for getting info about the process's memory usage, in a Linux/Unix system? (I want to avoid hacks that involve, e.g., scraping ps's output.) Thanks! ~K -- http://mail.python.org/mailman/listinfo/python-list

Anything like Effective Java for Python?

2010-03-10 Thread kj
Subject line pretty much says it all: is there a book like Effective Java for Python. I.e. a book that assumes that readers are experienced programmers that already know the basics of the language, and want to focus on more advanced programming issues? ~K --

Need help with Python scoping rules

2009-08-25 Thread kj
I have many years of programming experience, and a few languages, under my belt, but still Python scoping rules remain mysterious to me. (In fact, Python's scoping behavior is the main reason I gave up several earlier attempts to learn Python.) Here's a toy example illustrating what I mean.

Re: Need help with Python scoping rules

2009-08-26 Thread kj
In mailman.407.1251237485.2854.python-l...@python.org John Posner jjpos...@optimum.net writes: Stephen Hansen said: This sounds like a fundamental confusion -- a namespace is not equivalent to a scope, really, I think. ... snip Hmm. I can't find Stephen Hansen's original post anywhere.

Re: Need help with Python scoping rules

2009-08-26 Thread kj
In 7figv3f2m3p0...@mid.uni-berlin.de Diez B. Roggisch de...@nospam.web.de writes: Classes are not scopes. This looks to me like a major wart, on two counts. First, one of the goals of OO is encapsulation, not only at the level of instances, but also at the level of classes. Your comment

Re: Need help with Python scoping rules

2009-08-26 Thread kj
In jeqdncamuyvtrwjxnz2dnuvz8ludn...@bt.com Martin P. Hellwig martin.hell...@dcuktec.org writes: kj wrote: cut First, one of the goals of OO is encapsulation, not only at the level of instances, but also at the level of classes. Who says? Python itself: it already offers a limited form

Re: Need help with Python scoping rules

2009-08-26 Thread kj
In 16b72319-8023-471c-ba40-8025aa6d4...@a26g2000yqn.googlegroups.com Carl Banks pavlovevide...@gmail.com writes: First, one of the goals of OO is encapsulation, not only at the level of instances, but also at the level of classes. =A0Your comment suggests that Python does not fully support

  1   2   3   4   >