Dr. Dobb's Python-URL! - weekly Python news and links (Feb 9)

2005-02-09 Thread Craig Ringer
QOTW: "Such infrastructure building is in fact fun and instructive -- as long as you don't fall into the trap of *using* such complications in production code, where Python's simplicity rules;-)." -- Alex Martelli http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/41a6c

Dr. Dobb's Python-URL! - weekly Python news and links (Feb 9)

2005-02-09 Thread Craig Ringer
QOTW: "Such infrastructure building is in fact fun and instructive -- as long as you don't fall into the trap of *using* such complications in production code, where Python's simplicity rules;-)." -- Alex Martelli http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/41a6c

Re: Dynamic class methods misunderstanding

2005-01-28 Thread Craig Ringer
create another type. Well, a type is essentially a class (in the OOP sense, not the python- specific classobj sense). You can call a type or class to create an instance of that class or type. Here, you call the 'instancemethod' type to create an instance of type 'instancemethod'.

Re: example needed: sip + Qt

2005-01-28 Thread Craig Ringer
the PyQt/PyKDE list (and search its archives first). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Hello

2005-01-27 Thread Craig Ringer
newsreader to use that. Once your newsread is talking correctly to your ISP's news server, *then* you can subscribe to comp.lang.python. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: exclude binary files from os.walk

2005-01-26 Thread Craig Ringer
()? > > > > > > Sure, assuming you can provide a rigorous definition of 'binary > > files'. :) > > non-ascii That's not really safe when dealing with utf-8 files though, and IIRC with UCS2 or UCS4 as well. The Unicode BOM its self might (I'm not sure) qualify as ASCII. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: python without OO

2005-01-26 Thread Craig Ringer
so small and approachable. I also love the way I can chuck a bunch of objects into a functionally styled processing pipeline, say a series of functions that each just return the result of a listcomp/genexp. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: how to write a tutorial

2005-01-26 Thread Craig Ringer
quot; moron who appears to have nothing to do with either, or any knowledge of them. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: need help on need help on generator...

2005-01-22 Thread Craig Ringer
On Sat, 2005-01-22 at 12:20 +0100, Alex Martelli wrote: > Craig Ringer <[EMAIL PROTECTED]> wrote: > > > .>>> data = ''.join(x for x in infile) > > Maybe ''.join(infile) is a better way to express this functionality? > Avoids 2.4 dependen

Re: need help on need help on generator...

2005-01-22 Thread Craig Ringer
t the cost of making it less clear what's going on and having someone later go "duh, why isn't he using read() here instead" but can't seem to do much more than that. Might it be worth providing a way to have file objects seek back to the current position of the iterator when r

Re: need help on need help on generator...

2005-01-22 Thread Craig Ringer
his than: .>>> inpath = '/tmp/msg.eml' .>>> infile = open(inpath) .>>> initer = iter(infile) .>>> headers = [] .>>> for line in initer: if not line.strip(): break headers.append(tuple(line.split(':',1))) .&

Re: finding name of instances created

2005-01-21 Thread Craig Ringer
ct: > >> do_stuff(name) > > Any help, pointers, sketches or outline of solution would be greatly > appreciated. I'm not really able to grasp what you're trying to do (but others might). It wouldn't hurt if you could post a description of what you're actually trying to achieve - /why/ you want this - as that can often be very helpful both in understanding what you're thinking and in suggesting a suitable approach or alternative. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Tuple size and memory allocation for embedded Python

2005-01-21 Thread Craig Ringer
). > Python is pretty stable, so it's usually best to suspect our own code > unless you're heavily into using the C API (which I'm not, so feel free > to ignore me). That's been my experience - stability issues in my Python/C code have almost always come down to refcounting bugs and/or failing to detect and handle or propagate an exception. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Tuple size and memory allocation for embedded Python

2005-01-21 Thread Craig Ringer
LL (meaning a failure, probably of memory allocation). I also don't see anything in there to resize the tuple. http://docs.python.org/api/tupleObjects.html -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Configuring Python for Tk on Mac

2005-01-21 Thread Craig Ringer
n't build Python with Tk support. > What do I do to set it up so I can use Tkinter? Try Google - this seems to be a moderately FAQ for MacOS/X. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: need help on generator...

2005-01-21 Thread Craig Ringer
ttp://www.python.org/peps/pep-0289.html http://docs.python.org/whatsnew/node4.html http://www.python.org/dev/doc/newstyle/ref/genexpr.html for details. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: need help on need help on generator...

2005-01-21 Thread Craig Ringer
er handy. I'm not sure how many Python built-in functions and library modules return generators for things. > I know this is now the case for reading lines in a file or with the > new "iterator" package. But what else ? Does Craig Ringer answer mean > that list comprehensi

Re: Dynamic properties

2005-01-21 Thread Craig Ringer
s though, personally. I'd want to look into using a class factory or metaclass to do the job if __getattr__ and __setattr__ are insufficient or unacceptable. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: need help on generator...

2005-01-21 Thread Craig Ringer
On Fri, 2005-01-21 at 22:38 +0800, Craig Ringer wrote: > consecutive_sets = ( x[offset:offset+subset_size] > for subset_size in xrange(2, len(x)) > for offset in xrange(0, len(x) + 1 - subset_size) ) Where 'x' is list to operate

Re: need help on generator...

2005-01-21 Thread Craig Ringer
in xrange(2, len(x)) for offset in xrange(0, len(x) + 1 - subset_size) ) -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT] Good C++ book for a Python programmer

2005-01-19 Thread Craig Ringer
can avoid the "sometimes works, sometimes doesn't" fun of referencing deleted memory by accident. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda

2005-01-17 Thread Craig Ringer
the Python/C API. That said, I do think "the rules" deserve consideration and respect - they're usually there because of many others' experience over time. It's interesting to learn those lessons first hand, but it's nice to be able to avoid repeating every single one

Re: [Fwd: Re: Embedding Multiplr Python interpreter in C++]

2005-01-15 Thread Craig Ringer
e thread per sub-interpreter, or if it can support multiple sub interpreters in a single thread. Any ideas? I'm pretty sure it's the former, but it'd be nice to be sure. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Free python server.

2005-01-13 Thread Craig Ringer
e in the cgi-bin, not public_html, (b) be flagged executable ("chmod a+x file.py"), and (c) begin with the line: '#!/usr/bin/env python' If the server doesn't provide you with CGI (or, strongly preferable, SCGI or mod_python), you're probably out of luck. -- Craig

Re: counting items

2005-01-13 Thread Craig Ringer
lice__(0, 0, > x[1:]))) > or (not x and rest and cur.append(rest.pop(0] > > ;-) If it means I _never_ have to see that list comprehension again, then seeing 'flatten' go into itertools would make me very, very happy :-P -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Craig Ringer
one obvious way than what we have now. And then we have iteration (generator expressions, list comprehensions, for loops, ...?) over (sequences, iterators, generators) I happen to be extremely fond of the flexibility this provides, but one obvious way to do it there is not. -- Craig Ringer

Re: Python.org, Website of Satan

2005-01-12 Thread Craig Ringer
> or, if you haven't upgraded to 2.4, yet: That'll work fine in Python 2.3. I think you meant: print sum(ord(x) for x in "PyPy") which is a different matter entirely (well, regarding compatibility anyway). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: here document

2005-01-11 Thread Craig Ringer
t;) > print >>f , """CategoryY = GRIB > etc. > """ You mean "os.popen" not "open" I assume? The former opens a pipe to a command, the latter overwrites the file. I'd use: os.popen("/bin/exe.x", "w").write("""\ CategorY = GRIB etc. """) myself, but that's just taste (well, and performance I suspect). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: C structure in the Python extension

2005-01-10 Thread Craig Ringer
x27;t too hard, though the Python/C API does make creating types a bit cumbersome. (Most of this seems to be because you're playing pretend-we-have-objects in C, rather than issues specific to the Python/C API). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: _tkinter problem

2005-01-07 Thread Craig Ringer
(Yes, I know yours isn't Python 2.4 - it doesn't matter). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Help uninstalling/installing Python 2.4

2005-01-07 Thread Craig Ringer
in ? > import readline > ImportError: No module named readline > > I think some paths are screwed up.. can someone take pity on me and give > me a hand. I'd say that'll be the same as with Tkinter - you probably didn't have the GNU readline development headers installed, so Python disabled readline support when it was compiled. That's just a guess, but seems pretty likely. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: how to extract columns like awk $1 $5

2005-01-07 Thread Craig Ringer
t;)[4:6] ['something', 'about'] so if 'x' is your string, the rough equivalent of that awk statement is: .>>> x_words = x.split() .>>> print x_words[4], x_words[5] or perhaps .>>> print "%s %s" % tuple(x.split()[4:6]) -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: sorting on keys in a list of dicts

2005-01-07 Thread Craig Ringer
e-sorting by a different key... but you didn't know what key was last used for sorting. A stable sort algorithm means you don't need to care, because the order will be maintained for you not randomized. Well, that's several hundred more words than were probably required, but I hope I made sense. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: missing sys.setappdefaultencoding

2005-01-07 Thread Craig Ringer
e...;-) Agreed. I prefer to use explicit str.encode(), str.decode() and unicode() calls where appropriate. On a side note, PEP 263 handles the text encoding interpretation of Python program source, and is well worth reading and following. http://python.org/peps/pep-0263.html -- Craig Ringer --

Re: curses is not imported under Linux (and Python 2.4)

2005-01-06 Thread Craig Ringer
ckages (providing the ncurses header files and static libs) installed. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedding a restricted python interpreter

2005-01-06 Thread Craig Ringer
Apache might well be able to respawn failed subprocesses, it's not > something that most hosting providers would like to have to do all the > time for many hosted sites. I wonder if SCGI or a similar "persistent CGI" solution might be more practical for running CGI scripts under spec

Re: File Handling Problems Python I/O

2005-01-06 Thread Craig Ringer
r not there are trailing path separators on the input strings. os.path.join can take more than two arguments, too. os.path has lots of other handy tools, so I strongly recommend checking it out. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Python C Object Comparison

2005-01-06 Thread Craig Ringer
a class and make the class own and manage the C++ object (and pointer to it) that it owns. Perhaps that's a better solution for you too? If you want any opinions from folks here about the best way to solve your problem, you'll probably need to explain a bit more of your problem - like

Re: Embedding a restricted python interpreter

2005-01-06 Thread Craig Ringer
On Thu, 2005-01-06 at 23:05, Peter Maas wrote: > Craig Ringer schrieb: > It would certainly be difficult to track all harmful code constructs. > But AFAIK the idea of a sandbox is not to look at the offending code > but to protect the offended objects: files, databases, URLs, socket

Re: Embedding a restricted python interpreter

2005-01-04 Thread Craig Ringer
> I do not know if it is possible to disable or override 'import'.. You can do a fair bit to it by wrapping/replacing __builtin__.__import__ . Preventing people from getting around what you've done, though... not sure. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Bad Interpreter

2005-01-03 Thread Craig Ringer
say something like : > > python sock.py > > but ./sock.py results in a :bad interpreter error > how do i troubleshoot something like this? You probably have Windows-style line endings in the file. The kernel sees the ^M at the end of the line and gets all confused. -- Craig Ringer -- http:/

RE: removing comments form a file

2005-01-03 Thread Craig Ringer
27;d be interested if you could clarify what you mean there. As far as I know, the whole file will only be read into memory if you use file.read () or file.readlines(). If you use an iterator it does internal readahead, but won't read the lot at once. If you use read() it reads only what

Re: Developing Commercial Applications in Python

2005-01-03 Thread Craig Ringer
plication. You'd simply need to keep an eye on the licenses of any extensions you used, like ReportLab, PIL, mx, database interfaces, twisted, etc. Many are licensed under the same license as Python or an MIT-like license, but of course some Python extensions are not and you would need to con

Re: emulating an and operator in regular expressions

2005-01-03 Thread Craig Ringer
7;not (not A or not B)' I thought I could try something along those lines, > but can't crack it. My first thought would be to express your 'A and B' regex as: (A.*B)|(B.*A) with whatever padding, etc, is necessary. You can even substitute in the sub-regex for A and B to avoid

Re: screen clear question

2005-01-01 Thread Craig Ringer
t clear' or '/usr/bin/clear' on many UNIX systems; no idea about Windows. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: exposing C array to python namespace: NumPy and array module.

2005-01-01 Thread Craig Ringer
le approach to me, but I'm hardly an expert. The code's license permits you to do so, and it's hardly worth repeating the work if you don't have to. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: exposing C array to python namespace: NumPy and array module.

2005-01-01 Thread Craig Ringer
s, etc. In my case, its easier to execute snippets as shown above than it is to worry about the module search path and wrapping things using a Python module. If you're doing substantial amounts of Python coding for your module, you'll almost certainly be better off writing a Python module that uses your C module internally (see PIL for a good example of this). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Speed ain't bad

2004-12-31 Thread Craig Ringer
oited. True; however, it's my understanding that compressing individual files also means that in the case of damage to the archive it is possible to recover the files after the damaged file. This cannot be guaranteed when the archive is compressed as a single stream. -- Craig Ringer -- http:

Re: Probleme mit der Installation der openSource Bittorrent.... python vs JAVA

2004-12-30 Thread Craig Ringer
et) than Python in this case anyway. This is probably not the right place. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Updating file objects automatically

2004-12-30 Thread Craig Ringer
's just a stab in the dark, but perhaps it might be. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: justifying text...and also...correct use of classes...

2004-12-30 Thread Craig Ringer
ize in advance if I > am, but I just can't figure it out. "%20s: %s" % (leftstring, rightstring) or "%20s: %-40s" % (leftstring, rightstring) That's Python's 'printf' style string formatting. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: what would you like to see in a 2nd edition Nutshell?

2004-12-29 Thread Craig Ringer
s sense once you already understand it. It wouldn't hurt to point C extension authors at things like the 'es' encoded string format for PyArg_ParseTuple to help them make their code better behaved with non-ascii text. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Reference behavior through C (was: Lambda going out of fashion)

2004-12-28 Thread Craig Ringer
On Wed, 2004-12-29 at 02:08, Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > Craig Ringer <[EMAIL PROTECTED]> wrote: > . > . > . > > IMO the reference behaviour of functions in the

Re: DB-API format string conventions

2004-12-28 Thread Craig Ringer
t still need to have a look for other API revision proposals. I thought it best to ask here to find out how much interest there would be in clarifying the API and adding a required format style before going ahead with actually writing a few patches and a draft PEP for comments. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: DB-API format string conventions

2004-12-28 Thread Craig Ringer
On Tue, 2004-12-28 at 18:29, Craig Ringer wrote: > Would there be any interest in releasing a DB-API 2.1 with one > parameter style made MANDATORY, and a tuple of other supported styles in > .paramstyles ? I think existing modules implemented in Python could be > retrofi

DB-API format string conventions

2004-12-28 Thread Craig Ringer
work, but still probably not a big deal. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Clearing the screen

2004-12-25 Thread Craig Ringer
r pythonrc ( ${HOME}/.pythonrc on UNIX , NFI on windows ). On a side note, it'd be easier to read your post if you'd use the shift key more often :-P -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiple Inheritance __slots__ problem

2004-12-25 Thread Craig Ringer
need to define slots in these classes and also need to inherit them in > Derived class. If I recall correctly, the standard advice in this situation is "don't use __slots__. If you think you need __slots__, still don't use __slots__." I've made use of __slots__ once my

Re: Lambda going out of fashion

2004-12-23 Thread Craig Ringer
Fredrik Lundh wrote: Craig Ringer wrote: It's hard to consistently support Unicode in extension modules without doing a lot of jumping through hoops. Unicode in docstrings is particularly painful. This may not be a big deal for normal extension modules, but when embedding Python it'

Re: Lambda going out of fashion

2004-12-22 Thread Craig Ringer
rivial) difference in syntax. I'd be interested in knowing if there is in fact more to it than this. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Lambda going out of fashion

2004-12-22 Thread Craig Ringer
em. Of course, all these are just my opinion in the end, but I'd still have to argue that using Python from C could be a lot nicer than it is. The API is still pretty good, but the solution of these issues would make it a fair bit nicer again, especially for people embedding Python in apps (a place were it can seriously excel as a scripting/extension/glue language). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: PHP vs. Python

2004-12-22 Thread Craig Ringer
#x27;ll be faster or slower than PHP, I just can't guess. I think it'd certainly be well worth a try, especially if you're writing any more complex applications. That said, for 90% of users development time matters more than execution speed, and that's another matter entirely. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Killing a python thread with a signal

2004-12-22 Thread Craig Ringer
the past - it might be a good idea to search the archives. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing

2004-12-21 Thread Craig Ringer
tdir) . I strongly recommend you read the Python tutorial if you haven't already, and have a browse over the documentation for some of the key modules like os and sys. Google and Google Groups are also often very helpful - you can use Google Groups to search comp.lang.python (this list/newsgroup). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing

2004-12-20 Thread Craig Ringer
M is an option. > Or to do a DOS directory and send it directly to a file to be accessed > as needed? I'm afraid I just don't understand that. "Do" a DOS directory? If you want to list the contents of a directory, see help(os.listdir) . -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: A completely silly question

2004-12-18 Thread Craig Ringer
it's probably worth just using curses, but if you have a fairly basic app that just needs to read raw characters sometimes this approach should be fine. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: regular expression for javadoc style comment

2004-12-18 Thread Craig Ringer
It would be good if you could post some of the things you've tried, and perhaps a little more detail about what you're trying to match. Are you trying to match the comment as a whole, eg "this is a javadoc comment", or are you trying to extract parts of it? -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Import trouble

2004-12-15 Thread Craig Ringer
On Wed, 2004-12-15 at 21:44, Craig Ringer wrote: > def import_xml: >try: >import libxml >except ImportError,err: ># handle the error >return libxml > > libxml = import_xml() Though my personal approach would actually be: try: import l

Re: Import trouble

2004-12-15 Thread Craig Ringer
e into the current namespace: > the function scope(instead of file scope as I want). Is there any solution to > my problem? Or should I solve it in another way? def import_xml: try: import libxml except ImportError,err: # handle the error return libxml libxml

Re: lies about OOP

2004-12-14 Thread Craig Ringer
doesn't extend as far as: instance = Constructor(*args) though if anybody knows how to do this in C++ I would be overjoyed to hear from them. Qt _does_ provide a pleasant (if somewhat limited) of the Python getattr() and setattr() calls. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: how do I "peek" into the next line?

2004-12-13 Thread Craig Ringer
Assuming there's a good reason, such as monster lines, not to just read the next line anyway, I'd suggest read()ing the next character then seek()ing back by one character to restore the file position. def peekChar(fileobj): ch = fileobj.read(1) fileobj.seek(-1,1) r

Re: How can i send 8-bit data or binary data with pyserial?

2004-12-13 Thread Craig Ringer
exstring2 = "\x5b\xbd" >>> hexstring2 '[\xbd' and you can convert them all to strings. Just remember that you can work with a string as a buffer of 8-bit blocks and you'll be fine. In your specific example: >>> byte = '00100' >>> byte_chr = chr(int(byte,2)) >>> byte_chr '@' -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Read a gzip file from inside a tar file

2004-12-13 Thread Craig Ringer
hat does require the entire thing to be loaded (or anything that means you have to seek around the file), I'd say you're SOL. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode docstrings in PyMethodDef?

2004-12-10 Thread Craig Ringer
On Wed, 2004-12-08 at 13:43, Craig Ringer wrote: > Hi folks > > I'm currently working on a fairly well internationalised app that embeds > a Python intepreter. I'd like to make the docstrings translatable, but > am running into the issue that the translation function ret

Re: converting html escape sequences to unicode characters

2004-12-10 Thread Craig Ringer
On Fri, 2004-12-10 at 16:09, Craig Ringer wrote: > On Fri, 2004-12-10 at 08:36, harrelson wrote: > > I have a list of about 2500 html escape sequences (decimal) that I need > > to convert to utf-8. Stuff like: > > I'm pretty sure this somewhat horrifying code doe

Re: converting html escape sequences to unicode characters

2004-12-10 Thread Craig Ringer
, '에', '요', '내', '면', '금', '이', '얼', '마', '지', '잠'] >>> def unescape(escapeseq): ... return ("\\u%x" % int(escapeseq[2:-1])).decode("unicode_escape") ... >>> print ' '.join([ unescape(x) for x in entities ]) 비 행 기 로 보 낼 거 에 요 내 면 금 이 얼 마 지 잠 -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible to insert variables into regular expressions?

2004-12-09 Thread Craig Ringer
You could also end up inserting ?s , *s etc, resulting in some rather frustrating bugs. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Class Variable Inheritance

2004-12-08 Thread Craig Ringer
variable is still there, and unmodified, but the name search finds the copy each instance has in its dict before the class one. >>> a.__class__.name 'fred' >>> a.__class__.name = "Albert" >>> a.__class__.name 'fred' >>> a.name &#x

Unicode docstrings in PyMethodDef?

2004-12-07 Thread Craig Ringer
e rest of the app is translated with. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I do this? (eval() on the left hand side)

2004-12-07 Thread Craig Ringer
dict__[varname] = 'unwise' >>> obj.fred 'unwise' This, however, won't do you much good if you don't know what you'll be modifying. I know the locals() and globals() functions exist, but have always been leery of the idea of modifying their contents, an

Re: Writing class factories with the Python/C API?

2004-12-05 Thread Craig Ringer
wouldn't have guessed what I was looking for would be in the exception code. Much appreciated. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Writing class factories with the Python/C API?

2004-12-05 Thread Craig Ringer
bunch of methods on the generated subclasses, so I'm hoping so... -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Help] (fwd)

2004-12-05 Thread Craig Ringer
t;>> x [1] >>> x.append(5) >>> x [1,5] >>> sum(x) 6 >>> sum(x) / len(x) 3 As you can see, it's much easier to work with data in lists. Some of the other methods, like list.sort() and list "slices" will also be useful to you, but I'll let

Re: Run an python method from C++

2004-11-30 Thread Craig Ringer
PyMapping_GetItemString(globals, "errorMsg") QString errorMsg = PyString_AsString(errorMsgPyStr); (I'd love to be told there's a nicer way to do this). This could easily be the wrong way to go about things, buggy, or just stupid, so be warned. It does work well here, however. I would be interested in knowing how to tell Python what encoding is used for program text passed using PyRun_String() if anybody knows. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Class methods in Python/C?

2004-11-30 Thread Craig Ringer
d to worry about older code. Thanks. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Class methods in Python/C? [ANSWER]

2004-11-30 Thread Craig Ringer
on. New in version 2.3. Sorry for the noise everybody, I could've sworn I looked over that already. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Class methods in Python/C?

2004-11-30 Thread Craig Ringer
hanks to Qt the bindings are going to be both simple and quite powerful. However, I need a way to do class methods... If anybody has any tips on this, It'd be much appreciated. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Protecting Python source

2004-11-29 Thread Craig Ringer
bit more practical IMO, and may be a good place to look at digital signing. > - Your customer demands closed source because the code contains trade >secrets. My understanding is that that's never guaranteed safe, no? Or are restrictions against reverse engineering now commonly enforcable? -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list