Re: Pickling over a socket

2011-04-20 Thread Chris Angelico
t I used with DB2 was called "dblapos" because it simply doubled every apostrophe - nothing else needed. On the other hand, mysql_real_escape_string will escape quite a few characters, for convenience in reading dumps. > Am Wed, 20 Apr 2011 18:43:01 +1000 > schrieb Chris Angelico :

Re: List comprehension vs filter()

2011-04-20 Thread Chris Angelico
) I described the embed environment above, in the hopes that someone would spot an "obvious error", and if your instant suspicion is an IDE, then that's probably it. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: List comprehension vs filter()

2011-04-20 Thread Chris Angelico
_input the problem? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

TestFixtures 1.9.2 Released!

2011-04-20 Thread Chris Withers
links to docs, issue trackers and the like can be found here: http://www.simplistix.co.uk/software/python/testfixtures cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listin

Re: Questions about GIL and web services from a n00b

2011-04-20 Thread Chris H
hitectures for avoiding the issue. Now to find the right framework for a simple web service. So far I've heard pyramid the most, but others we are looking into include rest.ish.io, web2py, and flask. Anyone with experience across these as to what is best for someone starting fr

Re: Teaching Python

2011-04-20 Thread Chris Angelico
On Wed, Apr 20, 2011 at 8:17 PM, Steven D'Aprano wrote: > It's hardly just the press. "Hack" is a fine old English word: > "Can you teach me how to hack?" "Sure. Go to the tobacconists and buy him out, then smoke the lot. You'll be hacking li

Re: learnpython.org - an online interactive Python tutorial

2011-04-20 Thread Chris Angelico
On Thu, Apr 21, 2011 at 3:15 AM, Ron wrote: > Hey everyone. > > I've written an online interactive Python tutorial atop Google App Engine: > http://www.learnpython.org. That looks very handy! And I notice you've protected yourself by running it in a sandbox: import time time.sleep(3) Tracebac

Re: learnpython.org - an online interactive Python tutorial

2011-04-21 Thread Chris Angelico
tabase, and probably even a web browser if it feels like it. Is that strong typing or not? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: is there a difference between one line and many lines

2011-04-21 Thread Chris Angelico
t your test would work if you used 6 instead of -6; but there's no guarantee of anything with the negatives. However, it doesn't matter whether the variables are pointing to the same object or not, if you use ==, because two different objects holding the number -6 will compare equal. Hope that clarifies it! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: is there a difference between one line and many lines

2011-04-21 Thread Chris Angelico
going to be an oddity of the IDLE system, because it's compiling each line separately. When you put it on a single line, it's saving some trouble by sharing the constant; when you do them separately, it doesn't optimize like that. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Argument count mismatch

2011-04-21 Thread Chris Angelico
hod call? As a side point, if it takes a piece of the URL and looks it up, unchecked, as a member name, this is a rather dodgy practice. I hope you have a whitelist of legal method names. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Input() in Python3

2011-04-21 Thread Chris Angelico
should do something simple and straightforward - not eval() the expression. > to:        a = eval(input("enter a number > ")) U NO. NO NO NO. What if someone enters "os.exit()" as their number? You shouldn't eval() unchecked user input! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Input() in Python3

2011-04-21 Thread Chris Angelico
On Fri, Apr 22, 2011 at 4:49 PM, Chris Angelico wrote: > U NO. NO NO NO. What if someone enters "os.exit()" as their > number? You shouldn't eval() unchecked user input! Whoops, I meant sys.exit() - but you probably knew that already. ChrisA -- http://mail.python

Re: learnpython.org - an online interactive Python tutorial

2011-04-22 Thread Chris Angelico
dollars of credit with us." Okay, that one is probably better done with the % operator, but it definitely makes logical sense to concatenate numbers and strings as strings, not to add them as numbers. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Input() in Python3

2011-04-22 Thread Chris Rebert
ly and is quite trivially replaced. raw_input() was used much more frequently, but was a bit awkwardly named. Python 3 made use of its backwards-incompatible status to rectify both of these problems at once. Writing correct code will be now easier for newbies. If you're porting stuff to Python 3, using 2to3 and reading the summary of changes from 2.x are absolute necessities. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: PyLZMA lastwritetime file to python datetime

2011-04-22 Thread Chris Rebert
amp() or datetime.datetime.fromtimestamp() ? http://docs.python.org/library/datetime.html#datetime.datetime.utcfromtimestamp http://docs.python.org/library/datetime.html#datetime.datetime.fromtimestamp Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: suggestions, comments on an "is_subdict" test

2011-04-22 Thread Chris Rebert
dict view tricks can be exploited): def is_subdict(sub, larger): return set(sub.items()).issubset(set(larger.items())) Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Input() in Python3

2011-04-22 Thread Chris Angelico
On Sat, Apr 23, 2011 at 12:08 AM, Mel wrote: > But sys.exit() doesn't return a string.  My fave is It doesn't return _at all_. Boom, process terminated. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Input() in Python3

2011-04-22 Thread Chris Angelico
On Sat, Apr 23, 2011 at 9:55 AM, Steven D'Aprano wrote: > On Sat, 23 Apr 2011 06:25:51 +1000, Chris Angelico wrote: > >> On Sat, Apr 23, 2011 at 12:08 AM, Mel wrote: >>> But sys.exit() doesn't return a string.  My fave is >> >> It doesn&

Re: detecting newline character

2011-04-23 Thread Chris Rebert
lling built-in open() with a nonsense `mode` of "rUb" or similar, resulting in strange behavior. If this explanation is correct, then there are 2 bugs: 1. Built-in open() should treat "b" and "U" as mutually exclusive and reject mode strings which involve both. 2. code

Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread Chris Angelico
Re harrismh's code: For that sort of work, I used and still use the REXXTry program that comes with OS/2 (written, I believe, by Mike Cowlishaw), with a modified input routine that gives readline-style capabilities. Dragging this vaguely back on topic, the end result is rather similar in feel

Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread Chris Angelico
with the base 10 string than to convert it to base 256 or base 2**32 or something, just because you skip the conversions. Obviously this makes REXX a poor choice for heavy HEAVY computation, but it's potentially faster for things that involve a little computation and a lot of string manipulation

Re: Include me in the list

2011-04-24 Thread Chris Angelico
On Mon, Apr 25, 2011 at 6:34 AM, nusrath ahmed wrote: > urlLogin = > 'file:///C:/Documents%20and%20Settings/Fat/Desktop/New%20Folder/Login.html' > This is a file on your hard disk. You'll need to change the URL to point to the actual login page on the actual web site.

Re: Pls chk my login script

2011-04-24 Thread Chris Rebert
"action" URL specified by the form, not the URL the form itself is on (unless they happen to be the same). Also, please don't make a whole new thread just to post a follow-up reply. Regards, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Argument of the bool function

2011-04-25 Thread Chris Angelico
On Tue, Apr 26, 2011 at 12:29 AM, Thomas Rachel wrote: > for function in actions: >     results.append(function()) Can this become: results = [function() for function in actions] Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: sockets: bind to external interface

2011-04-25 Thread Chris Angelico
way. At very worst, parse ifconfig's output. The way you talk of "the" external interface, I'm assuming this computer has only one. Is there a reason for not simply binding to INADDR_ANY aka 0.0.0.0? Do you specifically need to *not* bind to 127.0.0.1? Chris Angelico -- http://

Re: sockets: bind to external interface

2011-04-25 Thread Chris Angelico
t has just connect; bind/connect is a lot less common. Incidentally, interfaces don't have to correspond 1:1 to network cards. At work, we have a system of four IP addresses for each server, even though it has only one NIC - it's used for traffic management and routing. Binding to a specific

Re: sockets: bind to external interface

2011-04-25 Thread Chris Angelico
ologies - I've done most of my sockets programming in C, where the integer constant is applicable. 0.0.0.0 means the exact same thing. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Python login script

2011-04-25 Thread Chris Angelico
l text? It gets very difficult to follow the changes, other than by pulling up your previous email and doing a visual diff. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: sockets: bind to external interface

2011-04-25 Thread Chris Angelico
On Tue, Apr 26, 2011 at 7:18 AM, Thomas Rachel wrote: > Am 25.04.2011 22:30, schrieb Chris Angelico: > >> If you don't care what port you use, you don't need to bind at all. >> That may be why it's not mentioned - the classic TCP socket server >> involves

Re: strange use of %s

2011-04-25 Thread Chris Angelico
in that you can't use this to search for a percent character anywhere in the string (come to think of it, how _would_ you do that? I think you'd have to backslash-escape it, prior to escaping it for the string, but I'd have to check), so it doesn't make a lot of difference wher

Re: How to concatenate unicode strings ???

2011-04-26 Thread Chris Rebert
roper Unicode string literals: u'this an example language ' + u'español' You'll probably also need to add the appropriate source file encoding declaration; see http://www.python.org/dev/peps/pep-0263/ Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Terrible FPU performance

2011-04-26 Thread Chris Colbert
On Tue, Apr 26, 2011 at 8:40 AM, Mihai Badoiu wrote: > Hi, > > I have terrible performance for multiplication when one number gets very > close to zero. I'm using cython by writing the following code: > > You should ask this question on the Cython users mailing list. -- http://mail.python.org/m

Re: Restarting a daemon

2011-04-26 Thread Chris Angelico
ith the 'initctl' command, for instance. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: De-tupleizing a list

2011-04-26 Thread Chris Angelico
work with a tuple of length 1, where most of the others are flexible enough to take the first element from any length tuple; but the time saving is quite significant. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Development tools and practices for Pythonistas

2011-04-26 Thread Chris Angelico
ect is to you. At work, I have a lot of disciplines; we have a wiki where stuff gets documented, we have source control, we have daily backups (as well), etc, etc, etc. For little home projects, it's not usually worth the effort. Take your pick, where do you want to go? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: client-server parallellised number crunching

2011-04-26 Thread Chris Angelico
an do the whole job without bothering the unreliable boxen at all. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: client-server parallellised number crunching

2011-04-26 Thread Chris Angelico
On Wed, Apr 27, 2011 at 6:33 AM, Dan Stromberg wrote: > On Tue, Apr 26, 2011 at 1:20 PM, Chris Angelico wrote: > >> But question: Why are you doing major number crunching in Python? On >> your quad-core machine, recode in C and see if you can do the whole >> job without

Re: client-server parallellised number crunching

2011-04-26 Thread Chris Angelico
On Wed, Apr 27, 2011 at 6:47 AM, Hans Georg Schaathun wrote: > Does that answer your question, Chris? Yup! It does. :) Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Terrible FPU performance

2011-04-26 Thread Chris Angelico
, but used to be a separate purchase) gets all the really hard work farmed off to it. Gross oversimplification, but hopefully helpful. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Development tools and practices for Pythonistas

2011-04-27 Thread Chris Angelico
ning curve. I have a few places where I should probably migrate things to git. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: client-server parallellised number crunching

2011-04-27 Thread Chris Angelico
On Wed, Apr 27, 2011 at 10:21 PM, Hans Georg Schaathun wrote: > On Wed, 27 Apr 2011 11:35:16 +0200, Thomas Rachel >   wrote: > :  As far as I understand, you acquire a job, send it to a remote host via > :  a socket and then wait for the answer. Is that correct? > > That's correct.  And the clien

Re: client-server parallellised number crunching

2011-04-27 Thread Chris Angelico
much advantage of multiple CPUs/cores (because the threads will all be waiting for socket read, or the single thread will mostly be waiting in select()), so it's mainly a resource usage issue. Probably worth testing with your actual code. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: use of index (beginner's question)

2011-04-27 Thread Chris Angelico
7;] ] Then you could use: n = 2 a = lists[n][list1.index('horse')] If it helps, you can think of this as a two-dimensional array; technically it's not, though, it's a list that contains other lists. (Note that you probably don't want to use the word 'list' as a variable name; it's the name of the type, and is actually a token in its own right. But 'lists' or something is fine.) Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: use of index (beginner's question)

2011-04-27 Thread Chris Rebert
On Wed, Apr 27, 2011 at 6:23 PM, Thomas 'PointedEars' Lahn wrote: > Chris Angelico wrote: >> Rusty Scalf wrote: >>> list1 = ['pig', 'horse', 'moose'] >>> list2 =  ['62327', '49123', '79115'] >&g

Re: use of index (beginner's question)

2011-04-27 Thread Chris Angelico
115'], ] Often makes for easier maintenance, especially when you append array/list elements. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Access violation reading 0x00000010

2011-04-27 Thread Chris Angelico
On Thu, Apr 28, 2011 at 1:00 PM, yuan zheng wrote: > Hi, >     everyone. I have a question when I invoke an api which is included a > library > open by CDLL. And then it will prompt the follow error: How are you invoking it? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Access violation reading 0x00000010

2011-04-27 Thread Chris Angelico
-0.dll", RTLD_GLOBAL) I don't know if that's your problem, but it could be! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Need your help

2011-04-28 Thread Chris Rebert
le a and b? > I want to output all the printed information into a text file. > > Need your help, thanks a lot! import a, b, sys def c(): orig_stdout = sys.stdout sys.stdout = open('my_log_file.log', 'w') a.a() b.b() sys.stdout.close() sy

Re: NaN

2011-04-28 Thread Chris Rebert
inue to limp along (albeit with a NaN result) after an error rather than forcing the probably slower explicit handling of the error at the time of its occurrence. And it's used to represent missing numeric data values, sort of like a numerical None/Null: "How much does the truck weigh? NaN (i.

Aborting Python from C code

2011-04-28 Thread Chris Angelico
x27;d rather not use setjmp/longjmp if I can help it, as they seem a tad brutal, but I'm thinking in terms of a call that, in effect, doesn't return. Any ideas would be appreciated! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Fibonacci series recursion error

2011-04-29 Thread Chris Angelico
it's wrong ;) Fortunately, most Python interpreters will not implement double-tail-recursion as forking. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Aborting Python from C code

2011-04-30 Thread Chris Angelico
s; what I want is to force the PyRun_StringFlags to return. Normally PyErr_SetInterrupt will do exactly this (within a few instructions is fine), but the Python script is able to prevent that from happening, which I don't like. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: What other languages use the same data model as Python?

2011-05-01 Thread Chris Rebert
luenced by CLU. > > What other languages use the same, or mostly similar, data model as > Python? According to http://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing , besides those you already listed: Scheme, OCaml, AppleScript, and possibly VB, among "many other languages

Re: Fibonacci series recursion error

2011-05-01 Thread Chris Angelico
s to deep.  Consequently, because recursion > is usually a clearer form of expression than iterative loops, recursion > may actually be /less/ dangerous. I'm not sure that recursion is clearer. Recursion is a way of expressing the two rules: 1! = 1 n! = n * (n-1)! But iteration is

Re: skipping one unittest assertion?

2011-05-01 Thread Chris Angelico
nd add a line of output manually? Make everything as simple as possible (but no simpler). Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: PIL Question

2011-05-01 Thread Chris Rebert
tcwd()) Also, I would suggest using absolute file paths in the future, rather than relative ones; e.g. "C:/Documents and Settings/Your username/Desktop/screen_capture.jpg" rather than just "screen_capture.jpg". Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Compile 32bit C-lib on 64 bit

2011-05-01 Thread Chris Angelico
your 64-bit app). Let the operating system do my work for me? Don't mind if I do... Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Fibonacci series recursion error

2011-05-01 Thread Chris Angelico
On Mon, May 2, 2011 at 3:36 PM, Hans Georg Schaathun wrote: > On Mon, 2 May 2011 06:49:41 +1000, Chris Angelico >   wrote: > :  Sure. Serialize this Python object in a way that can be given to, say, PHP: > :  foo={"asdf":"qwer","zxcv":"1234

Re: Fibonacci series recursion error

2011-05-01 Thread Chris Angelico
On Mon, May 2, 2011 at 4:28 PM, Chris Angelico wrote: > reduce(`*,range(1,n+1)) > reduce(`*,xrange(1,n+1)) Whoops, forgot which language I was using. Back-tick functions not being available, these need to be: reduce(operator.mul,range(1,n+1)) reduce(operator.mul,xrange(1,n+1)) Chris An

Re: build the "sql where cause" dynamic

2011-05-02 Thread Chris Angelico
ing: for el in input.split('#'): (obviously your variable won't want to be called 'input' but you knew that already) Then split on the = sign and add to a list or dictionary. Be wary of elements that don't have an equals sign in them. That looks like the querystring

Re: codec for UTF-8 with BOM

2011-05-02 Thread Chris Rebert
cate that thing there either. What's going on here? Works for me™: Python 2.6.6 (r266:84292, Jan 12 2011, 13:35:00) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from encodings import utf_8_sig >>> Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Fibonacci series recursion error

2011-05-02 Thread Chris Angelico
be eyeball the compiler's source code, maybe do some disassembly. If you have a few years of career ahead of you, you'll benefit many times over from those few hours, and without spending extra time, you'll produce better code. THAT is what distinguishes the master from the novice

Re: Fibonacci series recursion error

2011-05-02 Thread Chris Angelico
conditional return will solve this. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: (beginner question) ConfigParser nuances

2011-05-02 Thread Chris Rebert
e might instead use several numbered options to similar effect: # config file [Example] fruit1: apple fruit2: orange fruit3: pear # Python from itertools import count fruits = [] names = ("fruit" + str(i) for i in count(1)) for name in names: if not config.has_option("Example", name): break fruits.append(config.get("Example", name)) Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Fibonacci series recursion error

2011-05-02 Thread Chris Angelico
o so. (And of course, it works for fib() because it needs/uses no global state, which makes the recursions completely independent. Not all functions are so courteous, and the compiler can't necessarily know the difference.) Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Development software

2011-05-02 Thread Chris Angelico
ts of times and only then commit the change in git). Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Py / VNC Automation

2011-05-02 Thread Chris Angelico
up as a test, I recommend playing around with authentication disabled - it's a lot easier to master the protocol in its simplest form. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursion or iteration (was Fibonacci series recursion error)

2011-05-02 Thread Chris Angelico
ursive functions around after compiling them - for instance, powR2=powR; def powR(x,n): os.exit() - but if you do that, then you should expect to see nice bullet-holes in your foot). However, I do not believe that Python would overall benefit from any such thing. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Development software

2011-05-02 Thread Chris Angelico
On Tue, May 3, 2011 at 12:04 PM, rusi wrote: > Chris talked of a good make tool. Yes this is necessary for more 'in- > the-large' programming. > But for a beginner its very important to have tight development cycle > -- viz. > a. Write a function > b. Check the functio

Re: complex data structures in python

2011-05-02 Thread Chris Rebert
doesn't work since it violates the aforementioned immutability rule. One should also be aware of the datatypes in the `collections` module, particularly `defaultdict`: http://docs.python.org/library/collections.html Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursion or iteration (was Fibonacci series recursion error)

2011-05-02 Thread Chris Angelico
you sure? It will produce n function calls and n multiplications, how is that O(log n)? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursion or iteration (was Fibonacci series recursion error)

2011-05-03 Thread Chris Angelico
mediates) is more important than performance, but in this case they go > hand in hand. And that, Your Honour, is why I prefer bignums (especially for integers) to floating point. Precision rather than performance. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursion or iteration (was Fibonacci series recursion error)

2011-05-03 Thread Chris Angelico
On Tue, May 3, 2011 at 10:49 PM, Steven D'Aprano wrote: > On Tue, 03 May 2011 21:04:07 +1000, Chris Angelico wrote: > >> And that, Your Honour, is why I prefer bignums (especially for integers) >> to floating point. Precision rather than performance. > > I'm int

Re: Why do directly imported variables behave differently than those attached to imported module?

2011-05-03 Thread Chris Rebert
t;>> def mutate_then_rebind(b): ... b.append(99) # mutates passed-in value ... b = [42] # rebinds local name; has no outside effect ... >>> mutate_then_rebind(c) >>> c # name still references same obj, but that obj has been mutated [7, 99] Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Fibonacci series recursion error

2011-05-03 Thread Chris Angelico
y, probably not quite as there'll be a few used for other things, but fib(900) would be safe). Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Why do directly imported variables behave differently than those attached to imported module?

2011-05-03 Thread Chris Angelico
On Wed, May 4, 2011 at 2:57 AM, Chris Rebert wrote: > from foo import * > > can be thought of as essentially doing: > > import foo > set = foo.set > var = foo.var > del foo Here's a side point. What types will hold a reference to the enclosing module (or at least

Re: Coolest Python recipe of all time

2011-05-03 Thread Chris Angelico
t had to be complicated... Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: What other languages use the same data model as Python?

2011-05-03 Thread Chris Angelico
led function a shallow copy of the list, which it can modify to its heart's content, but the original list isn't changed. Callee can do the same, with an assignment command at the top of the function (a_list=a_list[:]). Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Why do directly imported variables behave differently than those attached to imported module?

2011-05-03 Thread Chris Rebert
On Tue, May 3, 2011 at 2:47 PM, Chris Angelico wrote: > On Wed, May 4, 2011 at 2:57 AM, Chris Rebert wrote: >> from foo import * >> >> can be thought of as essentially doing: >> >> import foo >> set = foo.set >> var = foo.var >> del foo > &

Re: vertical ordering of functions

2011-05-03 Thread Chris Angelico
t understand a term, you know to scan upwards for its definition. It's just a stylistic thing, you can do it whichever way you think best! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Fibonacci series recursion error

2011-05-03 Thread Chris Angelico
ipt. This will be essential to the finding of answers to these vital questions. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Fibonacci series recursion error

2011-05-04 Thread Chris Angelico
y. The word "programming" has been secretly attracting related words to its corner of the alphabet... and the government's *covering it up* and pretending there's nothing happening! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Aborting Python from C code

2011-05-04 Thread Chris Angelico
I'm assuming that Python will flush out all its state on process termination (that is, it doesn't hang onto any system-global resources). Thanks for the advice! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: What other languages use the same data model as Python?

2011-05-04 Thread Chris Angelico
r I should say, they occasionally have confidential briefings with the press. Abstracting everything perfectly is neither possible nor desirable. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Today's fun and educational Python recipe

2011-05-04 Thread Chris Angelico
ources is a major restriction (for an extreme example of RAM shortage, look at how much code you can fit into a boot sector without loading anything more from the disk). Take away all the restrictions, and people will tend to code sloppily. Chris Angelico -- http://mail.python.org/mailman/li

Re: What other languages use the same data model as Python?

2011-05-04 Thread Chris Angelico
can point nowhere. (Pike goes for a slightly different approach; any variable, regardless of its stated types, may legally hold the integer 0. It acts somewhat as a null pointer, but it isn't really.) Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: What other languages use the same data model as Python?

2011-05-05 Thread Chris Angelico
On Thu, May 5, 2011 at 7:08 PM, Gregory Ewing wrote: > harrismh777 wrote: >> >> 'C'  is still the best high-level language on that processor. > > Some would argue that C is actually better than assembler these > days, because modern architectures are so freaking complicated > that it takes a compu

Re: What other languages use the same data model as Python?

2011-05-05 Thread Chris Angelico
ted as "==" on >> immutable objects. > > I foresee trouble testing among float(5), int(5), Decimal(5) ... Define 'x is y' as 'type(x)==type(y) and isinstance(x,(int,float,tuple,etc,etc,etc)) and x==y' then. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: What other languages use the same data model as Python?

2011-05-05 Thread Chris Angelico
ics > of high-level Python code... http://xkcd.com/505/ Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Need to solve the "Stateless HTTP" problem

2011-05-05 Thread Chris Angelico
ing NameVirtualHost), then you'd have to change them all, which probably wouldn't be worthwhile. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: What other languages use the same data model as Python?

2011-05-05 Thread Chris Angelico
On Fri, May 6, 2011 at 2:27 AM, Andreas Tawn wrote: > If True and False: >    waveFunction.collapse(cat) > > > That's going to be fun ;o) If a process crashes and init isn't there to hear it, does it produce a core dump? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: What other languages use the same data model as Python?

2011-05-05 Thread Chris Angelico
On Fri, May 6, 2011 at 1:29 AM, Roy Smith wrote: > "Hey, let's override operator,() and have some fun" Destroying sanity, for fun and profit. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: access to some text string in PDFs

2011-05-05 Thread Chris Rebert
2]: http://pybrary.net/pyPdf/ [3]: http://www.reportlab.com/software/#pagecatcher [4]: http://www.nltk.org/ Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Py_XDECREF/Py_DECREF evaluating its argument more than once

2011-05-05 Thread Chris Angelico
I'd solved it. *whoops* Just figured it might be worth mentioning, in case someone else is tempted to take a shortcut! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Py_XDECREF/Py_DECREF evaluating its argument more than once

2011-05-05 Thread Chris Angelico
on...) Since inline functions are a part of C99 as well as C++, would it be possible to have configure.sh detect its availability and optionally use that instead of preprocessor macros, or would this run the risk of encouraging trickily unportable code? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Py_XDECREF/Py_DECREF evaluating its argument more than once

2011-05-05 Thread Chris Rebert
On Thu, May 5, 2011 at 5:59 PM, Chris Angelico wrote: > Since inline functions are a part of C99 as well as C++, would it be > possible to have configure.sh detect its availability and optionally > use that instead of preprocessor macros, or would this run the risk of > encourag

Re: checking if a list is empty

2011-05-06 Thread Chris Rebert
On Thu, May 5, 2011 at 11:36 PM, Jabba Laci wrote: > Hi, > > If I want to check if a list is empty, which is the more pythonic way? Option (2), IMO. > li = [] > > (1) if len(li) == 0: > ... FYI, also equivalent: if not len(li): ... > or > (2) if not

Re: string formatting

2011-05-06 Thread Chris Rebert
nk you are wrong, % formatting is not deprecated. Do you have a link > showing otherwise? I'm not them, but: "Note: The formatting operations described here [involving %] are obsolete and may go away in future versions of Python. Use the new String Formatting [i.e. format()] in new code." http://docs.python.org/dev/library/stdtypes.html#old-string-formatting-operations Technically, not formally deprecated, but such a characterization isn't too far off the mark either. Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: seems like a bug in isinstance()

2011-05-06 Thread Chris Rebert
s will thus reference the already-previously-imported instance of a module rather than importing a copy of it from scratch again. Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

<    31   32   33   34   35   36   37   38   39   40   >