Re: why functions in modules need 'global foo' for integer foo but not dictionary foo?

2005-07-28 Thread Robert Kern
;s namespace and doesn't touch the module-level namespace. fun2(), on the other hand, only gets the dictionary from the module-level namespace with the name "bar". Then it modifies that dictionary (since it's mutable). It does not try to assign a new object to the name "

Re: Escaping certain characters

2005-07-30 Thread Robert Kern
e to reverse the process. > > I'm going to assume this has already been solved in Python.. But how? In [1]: s = 'Hello\x0aWorld!' In [2]: print s Hello World! In [3]: s.encode('string_escape') Out[3]: 'Hello\\nWorld!' In [4]: Out[3].decode('stri

Re: shelve: writing out updates?!

2005-07-30 Thread Robert Kern
store stuff in a long-running server, it could > be months before the shelve closes. > > Is shelve really missing this capability? No. Call the .sync() method. Unfortunately, the shelve module is not well-documented. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell wher

Re: shelve: writing out updates?!

2005-07-30 Thread Robert Kern
es this idea make some sense? Or are there hidden pitfalls? Yes! Someone actually has to do it! The same idea has come up time and time again. It's still not here because no one has been able to commit to the effort involved. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell wher

Re: How to convert a string like '777' to an octal integer like 0777?

2005-07-31 Thread Robert Kern
ing. 0777 == 511. os.chmod('myfile', 0777) os.chmod('myfile', 511) os.chmod('myfile', int('777', 8)) They all do *exactly* the same thing. End of story. If you really need a string representation in octal (os.chmod() doesn't), then use oct() on the integ

Re: Thaughts from an (almost) Lurker.

2005-07-31 Thread Robert Kern
USENET suggests that there is always a steady stream of newbies, trolls, and otherwise clueless people. In the absence of real evidence (like traceable headers), I don't think there's a reason to suspect that there's someone performing psychological experiments on the denizens of

Re: Dabo in 30 seconds?

2005-07-31 Thread Robert Kern
Paul Rubin wrote: > E.g., on > Linux, to use wxPython, you need wxWidgets, which needs GTK 1.5, which > has been obsolete for years, Nope. It's on GTK2 now. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dr

Re: namespaces

2005-07-31 Thread Robert Kern
Paolino wrote: > While it's not so bad we can bind names in the module namespace, (ex > writing scripts ?) ,writing modules is someway bound to not polluting > that namespace (really IMO). I'm afraid that I can't parse that sentence. -- Robert Kern [EMAIL PROTECTED]

Re: Wheel-reinvention with Python

2005-07-31 Thread Robert Kern
to Gtk and Qt/KDE using this API. Like PyGUI, more or less? http://www.cosc.canterbury.ac.nz/~greg/python_gui/ -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: Escaping certain characters

2005-07-31 Thread Robert Kern
t;>Not *quite* what you asked for, but it ought to be close enough. >> >>That'll do just fine. Many thanks! > > Hmm... On second thought, I need to escape more characters. > > Is there no other way to escape characters in strings? Which characters? -- Robert

Re: Escaping certain characters

2005-07-31 Thread Robert Kern
Jan Danielsson wrote: > Robert Kern wrote: > [---] > >>>Hmm... On second thought, I need to escape more characters. >>> >>>Is there no other way to escape characters in strings? >> >>Which characters? > >I need to escape '

Re: subclassing list

2005-07-31 Thread Robert Kern
elements from the iterable until it is exhausted. Then repeat the sequence indefinitely. In [11]: class better_circular_list(circular_list): : def __iter__(self): : return itertools.cycle(list.__iter__(self)) : In [13]: bcl = better_circular_list(range(8)) In

Re: Dabo in 30 seconds?

2005-07-31 Thread Robert Kern
nsi/wx/stc.py", > > line 10, in ? > import _stc > ImportError: No module named _stc You can't blame Dabo for this one. Your wxPython install is broken. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to di

Re: Escaping certain characters

2005-07-31 Thread Robert Kern
Jan Danielsson wrote: > Robert Kern wrote: > [---] > >>> I need to escape '\n', '"', '[' and ']'. I finally went with a few of >>>these: >>>string.replace('\n', '\\n') >>>string.replac

Re: subclassing list

2005-07-31 Thread Robert Kern
: > > #! /usr/bin/env python > > def circular_list(list): ^^^ As John pointed out, this is part of the problem, but as I pointed out, that's not the last of the problems with the code. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass g

Re: Operator Overloading

2005-08-01 Thread Robert Kern
oad all of the available ones for new classes (not old ones like dicts). http://docs.python.org/ref/numeric-types.html With a beautiful hack, you can make your own general, pseudo-operators. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/384122 -- Robert Kern [EMAIL PROTECTED] "

Re: Changing interpreter's deafult output/error streams

2005-08-01 Thread Robert Kern
m very new to python so that might be nonsense but it appeals to my > programmer's common sense. Can anyone tell me how to do this? http://docs.python.org/api/fileObjects.html -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of

Re: python ETL

2005-08-01 Thread Robert Kern
hat kind of data are you dealing with? What kinds of munging do you want to do? What formats are the data going to? However, given that your current toolset is written as Korn shell scripts, I'm pretty confident that Python will be up to the task. -- Robert Kern [EMAIL PROTECTED] "I

Re: Changing interpreter's deafult output/error streams

2005-08-01 Thread Robert Kern
head and write the following in python... > > Ah, OK, I think you're mistaken, and PyErr_Print prints to the C level > FILE* stderr (I agree my first post was confusing on this point, sorry > about that...). No, it doesn't. It grabs the appropriate object from sys.stderr.

Re: bug in python/numarray

2005-08-02 Thread Robert Kern
post it to the numarray mailing list. Thanks! http://lists.sourceforge.net/lists/listinfo/numpy-discussion -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: HELP:sorting list of outline numbers

2005-08-02 Thread Robert Kern
the "key" keyword argument to list.sort(). In [1]: outline = ['1.12', '1.1', '1', '1.2'] In [2]: outline.sort(key=lambda x: map(int, x.split('.'))) In [3]: outline Out[3]: ['1', '1.1', '1.2', '1.12']

Re: distutils package_dir newbie

2005-08-03 Thread Robert Kern
gt; > Can anybody give the correct way to achieve a directory-renaming when > creating an installer? Works just fine for me. from distutils.core import * setup(name='somePackage', packages = ['project_user'], # <- Are you sure you have this? package

Re: distutils package_dir newbie

2005-08-03 Thread Robert Kern
do some kind of quoting of the message you are responding to.) -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: Mass importing of a template based system.. Trouble with name substitutions

2005-08-03 Thread Robert Kern
a = mod.mod() > a.run() > > But it doesn't work with the following.. > > Traceback (most recent call last): > File "./metriX.py", line 109, in main > a = mod.mod() > AttributeError: 'module' object has no attribute 'mod' > > So i

Re: quetion about "+=" and "runtime"

2005-08-03 Thread Robert Kern
now how to call out this As Terry said, look at the "time" module. Don't use the "time" program (a standard program on UNIX-like systems) unless you actually want to time the startup of the interpreter too rather than just the code itself. -- Robert Kern [EMA

Re: Wheel-reinvention with Python

2005-08-03 Thread Robert Kern
install wxPython on is Linux, where you pretty much need to build from >>>>source if you want the latest and greatest. >> >>FWIW, Tiger ships with wxPython pre-installed. > > Yes, but it's an older version... isn't it 2.4? 2.5.something.pretty.close.to.2.6.b

Re: Does pyparsing support UNICODE strings?

2005-08-04 Thread Robert Kern
port Word text = "Καλημέρα, κόσμε!".decode('utf-8') alphas = u''.join(unichr(x) for x in xrange(0x386, 0x3ce)) greet = Word(alphas) + u',' + Word(alphas) + u'!' greeting = greet.parseString(text) print greeting -- Robert Kern [EMAIL PROTECTED]

Re: Parallel arithmetic?

2005-08-04 Thread Robert Kern
In [21]: from Numeric import array In [22]: a = array(range(10)) In [23]: b = array(range(10, 20)) In [24]: c = a - b In [25]: c Out[25]: [-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,] -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the grave

Re: Parallel arithmetic?

2005-08-04 Thread Robert Kern
[4, 5, 6, 7] - [3, 4, 5, 6] == [1, 1, 1, 1]. I want to avoid > something like > if h[0] == h[1]-1 and h[1] == h[2]-1 ... In that case: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/415504 -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grow

Re: >time.strftime %T missing in 2.3

2005-08-04 Thread Robert Kern
on.""" So I suggest that it's a platform issue, not a Python version issue. FWIW: Python 2.4.1 (#2, Mar 31 2005, 00:05:10) [GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin Type "help", "copyright", "credits" or "license"

Re: Some question about setuptools module

2005-08-05 Thread Robert Kern
limodou wrote: > I'm sorry may be this letter is not suit for this maillist. You'll get better help on the Distutils-SIG list. http://mail.python.org/mailman/listinfo/distutils-sig/ Phillip Eby hangs out there for the care and feeding of setuptools adopters. -- Robert Kern [EM

Re: An editable buffer for the Python shell (similar to '\e' on sql prompts)

2005-08-05 Thread Robert Kern
itable buffer'. > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438813 > > Just thought some one else also would find this useful. See also ipython and pyrepl. http://ipython.scipy.org http://codespeak.net/pyrepl/ -- Robert Kern [EMAIL PROTECTED] "In the fiel

Re: Passing a variable number of arguments to a wrapped function.

2005-08-05 Thread Robert Kern
same as the defaults for the underlying function. matplotlib.pylab functions, however, have too much intelligence coded in them for this to be easy. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die.&qu

Re: Suggestions for optimizing my code

2005-08-05 Thread Robert Kern
= N.argmax(U.flat) i, j = divmod(k, n) return i, j, R[i,j] -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: why no arg, abs methods for comlex type?

2005-08-06 Thread Robert Kern
gt; the calculations where perfectly possible without them > using (re, im) tupels and many many sin/cos in the code > but imagine how ugly it would be .. I don't have to imagine. It's not all that ugly. > I would like see Python as a competitor to Matlab etc I think it is alre

Re: about coding

2005-08-06 Thread Robert Kern
-*- > > Is this wrong ? It depends. Are those characters encoded as UTF-8? Or, more likely, are they encoded as ISO-8859-1? > Where can I find a pratical explanation about these encodings ? http://www.amk.ca/python/howto/unicode http://en.wikipedia.org/wiki/Character_encoding http://www.

Re: Installing/Using SWIG for python again

2005-08-06 Thread Robert Kern
stutils setup.py script to do all of the compiling and linking. http://docs.python.org/dist/setup-script.html -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: SWIG again

2005-08-06 Thread Robert Kern
Please don't make a new thread every time you post. Jerry He wrote: > Robert Kern > >>Write a distutils setup.py script to do all of the >>compiling and linking. > > Ok, I wrote the following distutils setup.py script > from distutils.core import setup, Exten

Re: Does FTPLIB have a 'local change directory' ?

2005-08-06 Thread Robert Kern
just > > storbinary( picture.gif .. ). > > But the python doc doesn't show any LCD. os.chdir() -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: SWIG again

2005-08-06 Thread Robert Kern
Jerry He wrote: >>Robert Kern >>Please don't make a new thread every time you post. > > sorry, I chose the digest mode when I signed up, and I > have no idea how to reply, nor any idea how to change > to the normal mode where I get individual emails so I > can ac

Re: Proposed new collection methods

2005-08-06 Thread Robert Kern
efer that a find() operation return as soon as it locates an item that passes the test. This generator version tests every item. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://m

Re: Proposed new collection methods

2005-08-06 Thread Robert Kern
Robert Kern wrote: > Christopher Subich wrote: > > >>Dear Zeus no. Find can be defined as: >>def find(self, test=lambda x:1): >>try: >> item = (s for s in iter(self) if test(s)).next() >>except StopIteration: >> raise ValueEr

Re: Proposed new collection methods

2005-08-06 Thread Robert Kern
Jeff Schwab wrote: > Robert Kern wrote: > >>Robert Kern wrote: >> >>>Christopher Subich wrote: >>> >>>>Dear Zeus no. Find can be defined as: >>>>def find(self, test=lambda x:1): >>>> try: >>>> item = (s

Re: Decline and fall of scripting languages ?

2005-08-06 Thread Robert Kern
OP-ified Perl-resemblant >>>language, that's also implemented only as an interpreter. I can't see >>>punting Python for it. >> >>www.google.com > > Thanks but I wanted a more Pythonic point of view. google('"ruby on rails" python&#

Re: Python -- (just) a successful experiment?

2005-08-07 Thread Robert Kern
resting to the table, they don't build any consensus, and they certainly don't get any code written. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: Python -- (just) a successful experiment?

2005-08-07 Thread Robert Kern
Paul Rubin wrote: > Robert Kern <[EMAIL PROTECTED]> writes: > >>No it's not wrong to want these things. The problem is that we're not >>lacking in people posting this *same exact complaint* every month or >>so. We *are* lacking in people implementing thes

Re: Abstract methods in python - is this a good way ?)

2005-08-07 Thread Robert Kern
heriting from. It's the builtin type object. Metaclasses inherit from it. http://www.python.org/2.2/descrintro.html -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: Python -- (just) a successful experiment?

2005-08-07 Thread Robert Kern
ence begins to pall a bit. Fortunately, there's a better approach, and it's coming soon. The next iteration of MacEnthon, at least, is going to be based on Python eggs and easy_install.py. Python eggs are, more or less, Python's answer to Ruby's gems. http://peak.telecommunit

Re: Python -- (just) a successful experiment?

2005-08-07 Thread Robert Kern
Paul Rubin wrote: > Robert Kern <[EMAIL PROTECTED]> writes: > >>As a maintainers of a convenient unified distro, I have to say that >>it's a losing strategy. No matter how much you include, for every >>person that tells you, "Thank you, you've made my

Re: Optional assignments ?

2005-08-07 Thread Robert Kern
Madhusudan Singh wrote: > Hi > > Is it possible to have something like : > > a,b,c,d=fn(that returns 10 return values) ? a,b,c,d = fn()[:4] -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die.&q

Re: SWIG again

2005-08-07 Thread Robert Kern
Jerry He wrote: > > Can you tell me how to completely remove that > >>module? >> >>For cygwin, it should be in whatever corresponds to >>/usr/lib/python2.4/site-packages . >> >>-- >>Robert Kern >>[EMAIL PROTECTED] >> > > H

Re: Some newbie cgi form questions...

2005-08-07 Thread Robert Kern
(my web service provider is >>responsible for this - I'd use 2.4.1 if I could) > > That code above can't work - you want something like > > if not form.keys() in key: This thread has to rank somewhere in the top ten threads with respect to the density of obviously wron

RE: WSGI-server in the standard distro?

2005-08-07 Thread Robert Brewer
the reference server that comes with wsgiref (which is what they based their WSGI server on). If there are any licensing or other issues keeping django from using the CherryPy WSGI server, swing by irc://irc.oftc.net/cherrypy and we'll get them worked out in a hurry. Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Metaclasses and new-style classes

2005-08-07 Thread Robert Kern
es requires new-style classes. There is an older method which uses what is called the Don Beaudry hook; Zope used to use it extensively before Python 2.2. You should avoid using that older method and stick to new-style classes. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell

Re: Python -- (just) a successful experiment?

2005-08-08 Thread Robert Kern
EP wrote: > Robert Kern <[EMAIL PROTECTED]> wrote: > >>Which is exactly why I said at the beginning that people shouldn't >>bother with this thread and should instead just get to work. > > Robert, you are probably right, but I think how we get to work is impor

Re: Python -- (just) a successful experiment?

2005-08-08 Thread Robert Kern
Torsten Bronger wrote: > Hallöchen! > > Robert Kern <[EMAIL PROTECTED]> writes: > >>[...] >> >>What I'm trying to say is that posting to c.l.py is absolutely >>ineffective in achieving that goal. Code attracts people that like >>to code. T

Re: Python -- (just) a successful experiment?

2005-08-08 Thread Robert Kern
Peter Decker wrote: > On 8/8/05, Robert Kern <[EMAIL PROTECTED]> wrote: > >>What I'm trying to say is that posting to c.l.py is absolutely >>ineffective in achieving that goal. Code attracts people that like to >>code. Tedious, repetitive c.l.py threads attract

Re: How to connect to UNIX machine from windows box

2005-08-08 Thread Robert Kern
ttp://www.catb.org/~esr/faqs/smart-questions.html But since I'm fundamentally a nice guy (if incredibly crotchety for my young age): http://www.lag.net/paramiko/ -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed t

Re: Python -- (just) a successful experiment?

2005-08-10 Thread Robert Kern
Michael Hudson wrote: > Michael Hudson <[EMAIL PROTECTED]> writes: > >>Robert Kern <[EMAIL PROTECTED]> writes: >> >>>What I'm trying to say is that posting to c.l.py is absolutely >>>ineffective in achieving that goal. Code attracts people tha

What is Python?!

2005-08-10 Thread Robert Wierschke
hi I'm learning python since 3 days. I' ve some programming experience in BASIC, Pascal, C, C++ and Java. Actually I want to add a scripting language to this repertoire (I have virtually no experience with scripting). Having read that python is object orientated, I start wondering if python i

Re: What is Python?!

2005-08-10 Thread Robert Wierschke
Adriano Varoli Piazza schrieb: > Robert Wierschke ha scritto: > ... > Reading the FAQ at the python website too difficult? I don't think you > missed any of the most frequently asked... Good job. > sorry I 've forgetten the FAQ -- http://mail.python.org/mailman/listinfo/python-list

Re: set of sets

2005-08-11 Thread Robert Kern
an operation not described in the > frozenset docs, which makes subclassing frozenset a different operation. Don't subclass. In [1]: s = frozenset() In [2]: f = set() In [3]: f.add(s) In [4]: f Out[4]: set([frozenset([])]) In [5]: f.remove(s) In [6]: f Out[6]: set([]) -- Robert Ke

Re: Catching stderr output from graphical apps

2005-08-12 Thread Robert Kern
ut and let c.l.py and the py mailing list know if it works on Windows. [1] http://codespeak.net/py/current/doc/home.html -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: client server question

2005-08-15 Thread Robert Wierschke
John schrieb: > I have a simple script that runs a server where one client can connect. > I would like to make it so that many clients can connect to one server > on the same port. Where can I find how to do this? > > Thanks, > --j > use sockets. the socket accept mehtoh returns a new socket (

Re: random seed

2005-08-16 Thread Robert Kern
single seed yourself instead of getting it from system time. random.seed(1234567890) is traditional and works just fine. Other favorites: 3141592653589793 2718281828459045 -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of drea

Re: Testing for presence of arguments

2005-08-17 Thread Robert Kern
point) and a scripting language would > not cut it. http://cens.ioc.ee/projects/f2py2e/ -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: GUI tookit for science and education

2005-08-17 Thread Robert Kern
MATLAB will probably be somewhat more convenient. Once you move outside of that box and start doing real programming, Python (with Numeric, ipython, matplotlib, scipy, et al.) beats MATLAB handily. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the

Re: GUI tookit for science and education

2005-08-17 Thread Robert Kern
James Sungjin Kim wrote: > Robert Kern wrote: > >>... Once you move outside of that box and start doing real >>programming, Python (with Numeric, ipython, matplotlib, scipy, et al.) >>beats MATLAB handily. > > As one who is really newbie on Python, In MATLAB we

Re: GUI tookit for science and education

2005-08-17 Thread Robert Kern
John Hunter wrote: >>>>>>"Robert" == Robert Kern <[EMAIL PROTECTED]> writes: > > > Robert>H = U*D*V.T > > Robert> then I'm more than happy with that tradeoff. The small > Robert> syntactic conveniences MATLAB p

Re: Module Name Conflicts

2005-08-18 Thread Robert Kern
>>> import sys >>> sys.path.insert(0,'foo1') >>> import blah as blah1 >>> sys.path.insert(0,'foo2') >>> import blah as blah2 >>> sys.modules['blah'] >>> blah2.__file__ 'foo1/blah.py' >>> -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: Module Name Conflicts

2005-08-18 Thread Robert Kern
n't rename the java package to 'Cmd' or anything > like that. Any ideas? Why not copy cmd.py into your package under a different name? -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: Module Name Conflicts

2005-08-18 Thread Robert Kern
[EMAIL PROTECTED] wrote: > Robert Kern wrote: > >>Why not copy cmd.py into your package under a different name? > > It offends my sense of modularity. For the record, I'm trying to use > pdb, the debugger, which in turn uses cmd. So it would be a matter of > ta

Re: while c = f.read(1)

2005-08-18 Thread Robert Kern
() can take a function to call repeatedly until it # receives a given sentinel value, here ''. return iter(lambda: fileobj.read(blocksize), '') f = open('blah.txt', 'r') try: for c in reader(f): # ... finally:

Re: Database of non standard library modules...

2005-08-19 Thread Robert Kern
Jon Hewer wrote: > Is there an online database of non standard library modules for Python? http://cheeseshop.python.org/pypi -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Har

Re: while c = f.read(1)

2005-08-19 Thread Robert Kern
o the itertools.chain iterates through each > line and yields a character. As far as I can tell, that code is just going to read the whole file in when Python does the *arg expansion. What's the point? -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows hi

Re: Idempotent XML processing

2005-08-19 Thread Robert Kern
g function? Read up on XML canonicalization (abrreviated as c14n). lxml implements this, also xml.dom.ext.c14n in PyXML. You'll need to canonicalize on both ends before hashing. To paraphrase an Old Master, if you are running a cryptographic hash over a non-canonical XML string represent

Re: Well, another try Re: while c = f.read(1)

2005-08-19 Thread Robert Kern
nd short explanations would be enough since I'm really newbie > to Python. No sorry, that's not how the newsgroup works. You read the documentation first, then come back with specific questions about what you didn't understand or couldn't find. http://www.catb.org/~esr/faqs/sm

Re: Well, another try Re: while c = f.read(1)

2005-08-20 Thread Robert Kern
James Kim wrote: > Robert Kern wrote: > >>http://www.catb.org/~esr/faqs/smart-questions.html > > Is it a *smart* way or *necessary* way? It's the polite way. And probably the only way you're going to get your questions actually answered. Read the documentation. I

Re: Well, another try Re: while c = f.read(1)

2005-08-20 Thread Robert Kern
Paul Rubin wrote: > Robert Kern <[EMAIL PROTECTED]> writes: > >>>>http://www.catb.org/~esr/faqs/smart-questions.html >>> >>>Is it a *smart* way or *necessary* way? >> >>It's the polite way. And probably the only way you're going to

Re: subpackage import problem

2005-08-21 Thread Robert Kern
is executing the contents of foo/sub/B.py while it's trying to create the module object foo.sub. You can get around it, though. Try this in foo/sub/B.py : from foo.sub.A import A class B(A): pass That works for me (Python 2.4.1, OS X). -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading my own stdout

2005-08-21 Thread Robert Kern
> (The only option I see now is to do a "-Dprintf=my_log_function" > which I don't like.) Look at the py.io module. http://codespeak.net/py/current/doc/home.html http://codespeak.net/svn/py/dist/ -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass g

Re: while c = f.read(1)

2005-08-22 Thread Robert Kern
e message you are replying to. We have no idea what "the 2nd option" is. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: Well, another try Re: while c = f.read(1)

2005-08-22 Thread Robert Kern
Steve Holden wrote: > Robert Kern wrote: >>Coincidentally, those are exactly the reasons why I posted it in the >>first place. I care not a whit about decluttering the newgroup, an >>impossible task. > > It's clear that you care not a whit about it. Unfortuna

Re: while c = f.read(1)

2005-08-22 Thread Robert Kern
John Hunter wrote: >>>>>>"Robert" == Robert Kern <[EMAIL PROTECTED]> writes: > > Robert> Greg McIntyre wrote: > >> The 2nd option has real potential for me. Although the total > >> amount of code is greater, it factors o

Re: What's the difference between built-in func getattr() and normal call of a func of a class

2005-08-23 Thread Robert Kern
to specify the attribute at run-time rather than write-time. You can do things like iterate over a list of attributes. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: Library and real path name

2005-08-23 Thread Robert Kern
gt; library.class() > > I want that my library know where are its real path > (site-packages/library/), because it has to load a data file present > into a subpackage directory (like site-package/library/data/file.dat), http://peak.telecommunity.com/DevCenter/PkgResources -- Rober

RE: Multiple (threaded?) connections to BaseHTTPServer

2005-08-23 Thread Robert Brewer
P code)? Do you *really* want to reinvent that wheel? ;) I'd suggest you start with a threaded HTTP server from one of Python's many web frameworks. Since I hack on CherryPy, I'll link you to its liberally-licensed PooledThreadServer: http://www.cherrypy.org/file/trunk/cherrypy/_cpht

RE: Multiple (threaded?) connections to BaseHTTPServer

2005-08-23 Thread Robert Brewer
Adam Atlas wrote: > Never mind... I've found a workable solution: > http://mail.python.org/pipermail/python-list/2001-August/062214.html > > Robert, thanks, I'll still check that out for any future projects; but > for my current purpose, it seems overkill. But I don&#x

Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-24 Thread Robert Kern
ed '$' to stand for > the length of the sequence (not the address of the last > element). By "+1" he means, "I like it." He's not correcting you. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: use SciPy with Python 2.4.1?

2005-08-24 Thread Robert Kern
standard Python 2.4.1 interpreter, which is, I believe, the largest holdup for Windows binaries for 2.4.1. If you have success building Scipy for Python 2.4.1 on Windows, please let us know on the Scipy list. Thanks. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the gras

Re: use SciPy with Python 2.4.1?

2005-08-24 Thread Robert Kern
John Hunter wrote: >>>>>>"Robert" == Robert Kern <[EMAIL PROTECTED]> writes: > > > Robert> [EMAIL PROTECTED] wrote: > >> Is SciPy usable with Python 2.4.1? At > >> http://www.scipy.org/download/ it says that 2

Re: while c = f.read(1) [comment on news hosting]

2005-08-24 Thread Robert Kern
g Eight hierarchies. But I agree that it is quite nice and is what I use to access c.l.py/python-list so that I can use the same server both at home and at work. http://gmane.org -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dream

Re: How to start PEP process?

2005-08-25 Thread Robert Kern
the post-pre-PEP stage. By all means, please do post it here and get some feedback before formally submitting it. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question: convert a list to one string

2005-08-25 Thread Robert Kern
t; > I know I can make a loop like below but is that the fastest/best option > ? > > def unlist(test): > output='' > for v in test: > output = output+" "+v > return output ' '.join(test) -- Robert Kern [EMAIL PROTECTED] "In the fiel

Re: overload builtin operator

2005-08-25 Thread Robert Kern
o int.__div__(int1, int2) operator.__div__ does not get called. > Does anyone know if this is possible and if I'm going along the correct > path with my attempts above? > Is it possible to do this using a C extention? No, you can't replace the methods on builtin types. -- Robe

Re: RE Despair - help required

2005-08-25 Thread Robert Kern
x27;s > something obvious). I also tried this RE on KODOS and it works fine > there, so I am really puzzled. > > Any ideas? Look at the second string. It has "\r" in the middle of it where you really want "\\r" (or alternatively r"c:\ret_files"). --

Re: variable hell

2005-08-25 Thread Robert Kern
Nx wrote: > Hi > > I am unpacking a list into variables, for some reason they need to be > unpacked into variable names like a0,a1,a2upto aN whatever is > in the list. Really? Why? -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows hig

Re: RE Despair - help required

2005-08-25 Thread Robert Kern
Yoav wrote: > Don't think it will do much good. I need to get them from a file and > extract the last folder in the path. For example: > if I get "c:\dos\util" > I want to extract the string "\util" You mean like this: import os os.path.sep + os.path.split

Re: variable hell

2005-08-25 Thread Robert Kern
t code-time, but at the prompt I probably do. Bunch assists both usages. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: variable hell

2005-08-25 Thread Robert Kern
nal idea was, > that having them read into a list was the best way to massage them into the > form required to be used as input values for the insert statement. Again, why unpack them into separate variables when they are *already* in the form that you want to use them? -- Robert Kern [EMA

<    6   7   8   9   10   11   12   13   14   15   >