Re: A critique of cgi.escape

2006-09-27 Thread Georg Brandl
latest response simply proves that >> there is indeed no remark, however irrelevant, that you will allow to go >> unanswered. > > The Complaints department is down the hall... Though some discussion participants seemingly want to stay for more being-hit-on-the-head lessons ;) Geo

Re: What's up with site.Quitter?

2006-09-27 Thread Georg Brandl
at would you do with it? It's an internal object used for only exit() and quit(), and of no real use elsewhere. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Surprise using the 'is' operator

2006-09-27 Thread Georg Brandl
pointed to the same integer object? Why should more be made, > when they all do the same thing, and are not subject to change? Because for typical usage of integers (which doesn't include your example), it is more expensive to check if there's already an integer with that specific value out there than to create a new one. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Surprise using the 'is' operator

2006-09-27 Thread Georg Brandl
they all do the same thing, and are not subject to change? >> >> Because for typical usage of integers (which doesn't include your example), >> it is more expensive to check if there's already an integer with that >> specific >> value out there than to create

Re: Why don't optional mutable objects show up in vars(func)?

2006-09-27 Thread Georg Brandl
gt; '__setattr__', '__str__', 'func_closure', 'func_code', 'func_defaults', > 'func_dict', 'func_doc', 'func_globals', 'func_name'] > > I'm using Python 2.4.3, if that is at all relevant. Thanks in advance > for any help. y is not an attribute of func, it's a default parameter value and as such stored in func_defaults: >>> def f(x=1): ... pass ... >>> print f.func_defaults (1,) >>> Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Surprise using the 'is' operator

2006-09-27 Thread Georg Brandl
Terry Reedy wrote: > "Georg Brandl" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> tobiah wrote: >>> Suppose I fill an list with 100 million random integers in the range >>> of 1 - 65535. Wouldn't I save much memory if all o

Re: How to read() twice from file-like objects (and get some data)?

2006-09-27 Thread Georg Brandl
> in order to see HTML source anymore. In other words I will see only an > empty string. Suggestions? response = urlopen(url) content = response.read() forms = ParseResponse(content) i.e., adapt ParseResponse to accept a string, or wrap the string in a StringIO: import cStringIO forms = Pa

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Georg Brandl
;>>> lst = range(10) >>>> lst[:Top] FWIW, this works with 2.5 and the __index__ slot: >>> class Top(object): ... def __index__(self): ... return sys.maxint ... >>> a=range(5) >>> a[:Top()] [0, 1, 2, 3, 4] >>> Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Georg Brandl
s because the builtin xrange insist on its arguments > being ints instead of allowing duck typing. xrange() *could* be implemented as shown above, but do you realize that it would be a severe performance hit compared to the current implementation, which doesn't give almost all users a benefit at all? Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Continuing after error

2006-09-28 Thread Georg Brandl
n the except clause. If that's successful, your program will continue normally. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Resuming a program's execution after correcting error

2006-09-28 Thread Georg Brandl
itself doesn't offer such an option. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: remove the last character or the newline character?

2006-09-28 Thread Georg Brandl
e character > from a string if it exists? fileName = fileName.rstrip("\n") though this will remove more than one newline if present. If you only want to remove one newline, use if fileName[-1:] == '\n': fileName = fileName[:-1] Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-29 Thread Georg Brandl
) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: str() takes at most 1 argument (2 given) str() is not only for converting integers, but all other types too. An explicit argument for this special case is not Pythonic IMO. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: why logging re-raise my exception and can't be caught?

2006-09-30 Thread Georg Brandl
ror() is that exception() passes the "exc_info=1" keyword argument to error() which means that the stack trace is added to the logging message. The default logger prints to stdout, which is why the stack trace is printed there too. (In the sense of the logging docs, an except:-clause *IS* an error handler). Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Georg Brandl
at > will have the exact same function as itertools.repeat? There's no possible value. You'll have to write this like def myrepeat(obj, times=None): if times is None: return itertools.repeat(obj) else: return itertools.repeat(obj, times) Many functions implemented in C have this behavior. For all functions written in Python, you can look up the default value in the source. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing/Splitting Line

2006-11-22 Thread Georg Brandl
line("helloiamsuperman") >> ['hell', 'oiam', 'supe', 'rman'] > > there are laws against such use of regular expressions in certain > jurisdictions. ... and in particularly bad cases, you will be punished by Perl not less than 5 years ... Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Python25.zip

2006-12-02 Thread Georg Brandl
lpful warning that the above should follow the home > directory in the path list. > > PEP 302 says "[PYTHONPATH] is directly needed for Zip imports." > > The role of Python25.zip is not clear. Is it required in the path just > to enable the import X.zip capability? No. It's there just *in case* you have a Python25.zip lying around containing the library. By default, it isn't. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Common Python Idioms

2006-12-07 Thread Georg Brandl
One Way to Do It", I > didn't bother searching for alternatives. > > Is there a list somewhere listing those not-so-obvious-idioms? I've > seen some in this thread (like the replacement for .startswith). > > I do think that, if it is faster, Python should translate > "x.has_key(y)" to "y in x". How and when should it do that? Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: funcs without () like print

2006-12-07 Thread Georg Brandl
iwl wrote: > Hello can I make funktions callable without () like print > at time the interpreter seems to printout the adres when I type the > function without () print is not a function, it's a statement, and as such equivalent to raise or assert. Georg -- http://mail.pyth

Re: tuple.index()

2006-12-14 Thread Georg Brandl
* point of tuples. They are an ordered collection of values, and you are supposed to know which data is found at which index. Don't tell me that tuples in maths are sets. For a mathematical example, take A = { (x,y) : 0 < x < 1, 0 < y < 1 } Here, (x,y) is a 2-tuple, and you know that at index 0 there's the x-coordinate of a point contained in the square A, and at index 1 there's the y-coordinate. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Property error

2006-12-15 Thread Georg Brandl
Peter Otten wrote: > @decorator > def f(): ># ... > > is the same as > > def f(): > # ... > f = decorator(f()) ^^ Nope, f is not called here. (Think of staticmethod). Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Property error

2006-12-15 Thread Georg Brandl
ound that allow you to do a similar thing, like class Person(object): age = 0 @Property def age(): def fget(self): return self.age def fset(self, value): self.age = value return locals() but here, Property is not the built-in "proper

Re: Fall of Roman Empire

2006-12-20 Thread Georg Brandl
ot;); return NULL; } universe->un_god = PyGod_FromName(god_name); universe->un_size = 0; universe->un_expand_rate = COSMOLOGICAL_CONSTANT; return universe; } Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: perl better than python for users with disabilities?

2006-12-20 Thread Georg Brandl
#x27;t think he'd have the time for that. I heard he's busy planning his lawsuit to enforce his claim for more pension. > Regarding the topic: > > I can't see where Perl should be more accessible than Python. Well, not really. But your $, @, %, {, }, ! etc. keys should b

ANN: Pygments 0.6 "Zimtstern" released

2006-12-20 Thread Georg Brandl
... and it highlights even Brainf*ck! The home page is at <http://pygments.pocoo.org>. Read more in the FAQ list <http://pygments.pocoo.org/faq> or look at the documentation <http://pygments.pocoo.org/docs>. regards, Georg Brandl -- http://mail.python.org/mailman/listinfo/python-list

Re: list1.append(list2) returns None

2006-12-21 Thread Georg Brandl
,col): > return table.remove(col) table.remove() also returns None. > print enlargetable([[1],[2],[3]],[4]) > > # and this code works. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic gui format?

2006-02-13 Thread Georg Brandl
text) class TestList(ListBox): items = ['First', 'Second'] _Slight_ misuse of "class" though... Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Which is faster? (if not b in m) or (if m.count(b) > 0)

2006-02-15 Thread Georg Brandl
in (relatively slow) pure Python, while > the count method executes (relatively fast) C code. So even though count > may do more work, it may do it faster. Why does "not b in m" execute in pure Python? list.__contains__ is implemented in C code as well as list.count. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Python advocacy in scientific computation

2006-02-15 Thread Georg Brandl
Michael Tobis wrote: > Someone asked me to write a brief essay regarding the value-add > proposition for Python in the Fortran community. Slightly modified to > remove a few climatology-related specifics, here it is. Great text. Do you want to put it onto a Wiki page at wiki.python.or

Re: define loop statement?

2006-02-17 Thread Georg Brandl
possible to create a new statement, with suite and indentation rules without hacking the interpreter or resorting to alternative bytecode compilers such as "pyc". Creating a _function_ named "loop" is easy as Jonathan's answer shows. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Merging two lists of data (Pythonic way)

2006-02-17 Thread Georg Brandl
> > You might also look at list comprehensions. Replacing the first line > in the above with > >codes = [x[0] for x in list1] > > should yield the same result. Even another way: import operator codes = map(operator.itemgetter(0), list1) Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: embedding python in HTML

2006-02-17 Thread Georg Brandl
ill basically look like this: #!/bin/env python # these are custom headers, Content-type is mandatory print "Content-Type: text/html" # an empty line separates headers from content print print "..." # do stuff here print "..." Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Another stupid newbie question

2006-02-17 Thread Georg Brandl
through the Python Tutorial. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Does python have an internal data structure with functions imported from a module?

2006-02-17 Thread Georg Brandl
def functA(): > ... pass > > >>> functA > > > And what I'd like to do is: > > >>>__internalFuncDict__['functA'] > Read about globals(), dir() and module.__dict__. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: define loop statement?

2006-02-18 Thread Georg Brandl
while loop: > print "OK" Seems you forgot "()" after "while loop" above. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Pickling/unpickling Cookie.SimpleCookie fails with protocol=2

2006-02-24 Thread Georg Brandl
key\'\\012p17\\012S\'hi\'\\012p18\\012sb."', > 'value': , 'key': 'hi'} > > > I can't really say what goes wrong here, but it looks like a bug to me > -- comments? I guess I'll have to go to protocol 0 for this, or not > serialize the cookie but re-parse it on the other side (this pickle > gets passed down a UNIX socket together with the file descriptor of a > request, in a load balancing system). You can report a bug at SourceForge. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Bragging about Python

2007-06-07 Thread Georg Brandl
strengths to >>> non-Python programmers? >>> Small examples that will make them go "Wow, that >>> _is_ neat"? >>> >> >> 15 small programs here: >> >> http://wiki.python.org/moin/SimplePrograms >> > > IMHO a few python

Python Binding

2007-05-05 Thread Georg Grabler
ot;information" i get from the list in C structures which can be converted. Basically, it are list of packages, which have several attributes (next, prev, etc). But i don't know how to supply a proper list from the binding / object written in C. Any suggestions or hints about this?

Re: Python Binding

2007-05-12 Thread Georg Grabler
ster with pyrex, for some reason it fits me better. I'd like to use swig, but for some reason i've troubles defining a completely new type, so a type which is not a wrapper type, but a type provided to python. Kind regards, Georg Stefan Behnel wrote: > STiAT wrote: >> Why do yo

Pyrex char *x[]

2007-05-15 Thread Georg Grabler
t function directly works properly, the function extends a C list for the object. Now i want a function adding the whole array to a the list, using the 2nd function. Does anyone of you have an idea how to archive this? Thank you, Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Weekly Python Patch/Bug Summary

2007-03-12 Thread Georg Brandl
Kurt B. Kaiser schrieb: > Patch / Bug Summary > ___ > > Patches : 380 open (-36) / 3658 closed (+65) / 4038 total (+29) We should really try to keep the numbers in this magnitude :) Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: very strange syntax errors

2007-03-28 Thread Georg Brandl
ndows ("\r\n") newlines. Try > to ensure that every line ends with "\r\n". That shouldn't be a problem since Python reads source files in universal newline mode. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about extending tuple

2007-03-28 Thread Georg Brandl
e): def __new__(cls, *args): return tuple.__new__(cls, args) should work. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about extending tuple

2007-03-28 Thread Georg Brandl
abcd schrieb: >> As an immutable type, tuple makes use of __new__. >> >> class MyTuple(tuple): >> def __new__(cls, *args): >> return tuple.__new__(cls, args) >> >> should work. >> >> Georg > > strange. not very consiste

Re: PyPy for dummies

2007-03-31 Thread Georg Brandl
? There is already a whole bunch of reports for the EU at http://codespeak.net/pypy/extradoc/eu-report/ HTH, Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode list

2007-04-01 Thread Georg Brandl
s with an explicit encoding before printing codecs.open() is very helpful for step 1, BTW. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: How can i compare a string which is non null and empty

2007-04-01 Thread Georg Brandl
if (str != null) && (!str.equals("")) > > how can i do that in python? Strings cannot be "null" in Python. If you want to check if a string is not empty, use "if str". This also includes the case that "str" may not only be an empty string, but also None. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: block scope?

2007-04-08 Thread Georg Brandl
value. > I think that ideally there should be a runtime error when assigning an > item of locals() with a key that's not a local variable name (possibly > excepting functions containing exec, which are kind of screwy anyway). I would make the locals() result completely independent from the frame, and document that it is read only. (though, this needs some other way for trace functions to interact with the frame's local variables.) Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I get a slice of a string held in a tuple?

2007-04-08 Thread Georg Brandl
elapsedTime[-1:] always contains at most one character. If you replace "find" by "index", you get a ValueError exception if "real" was not found, if that helps you. Whenever one calls str.find(), one has to check the return value for -1. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Exec Statement Question

2007-04-08 Thread Georg Brandl
't have access to any more > objects than I explicitly give it? The function f has a func_globals attribute which points to the globals it will use for execution. This is of course set at definition time so that functions from, e.g., another module, have the globals of that module available. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: tuples, index method, Python's design

2007-04-09 Thread Georg Brandl
ver Python/Django. Given that so many web sites still decide to (re)write in PHP, I don't think that is much of an argument. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: tuples, index method, Python's design

2007-04-09 Thread Georg Brandl
def f(*a): ... > > shows that the "immutable list" interpretation is firmly ensconced in > the language. IIRC, for this use case of tuples there was a practical reason rather than an interpretation one. It is also on the list of potential changes for Python 3000. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode problem

2007-04-09 Thread Georg Brandl
ings is explicitly set to None? IMO the docs don't make it clear that getwriter() is the correct API to use here. I've wanted to write "sys.stdout = codecs.EncodedFile(sys.stdout, 'utf-8')" more than once. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: RFC: Assignment as expression (pre-PEP)

2007-04-10 Thread Georg Brandl
t it's probably worth proposing there > (ideally together with a patch to implement it, just to avoid any > [otherwise likely] whines about this being difficult to implement:-). The patch is already done -- I have it lying around here :) Georg -- Thus spake the Lord: Thou shalt indent with

Re: exec statement Syntax Error on string pulled from MySQL

2007-04-10 Thread Georg Brandl
> File "/home/public/utility.py", line 177, in run > exec code+'\n' in context > File "", line 1 > print 'greg' > ^ > SyntaxError: invalid syntax > (Note the ^ actually appears under after the ' ) You have

Re: Python Feature Request: Add the "using" keyword which works like "with" in Visual Basic

2007-04-14 Thread Georg Brandl
t;> q.doit() > > Er.. I guess there are some details you need to work out for that. But > in principle, it works fine. No, it does not. The "q" here is *not* assigned to self.quit, but to the result of self.quit.__enter__(). Georg -- Thus spake the Lord: Thou shal

Re: proposed PEP: iterator splicing

2007-04-15 Thread Georg Brandl
y it has any chance is if someone takes the > time to implement it and posts a full-fledged PEP to python-dev. BTW, I've implemented a different feature, namely extended unpacking, such as a, *b, c = range(10) where I already had to add the concept of a ``starred'' expression. If

Re: What makes an iterator an iterator?

2007-04-18 Thread Georg Brandl
n the instance (I think). > I had the same troubles trying to dynamically reassign a __call__ method... This is correct. It's not properly documented though, and not applied consistently, e.g. __enter__ and __exit__ are looked up in the instance itself. Georg -- http://mail.python.org/mailman/listinfo/python-list

ANN: Pygments 0.7 "Faschingskrapfn" released

2007-02-14 Thread Georg Brandl
and-line tool and as a library * ... and it highlights even Brainf*ck! The home page is at <http://pygments.org>. Read more in the FAQ list <http://pygments.org/faq> or look at the documentation <http://pygments.org/docs>. regards and happy Valentine's day, Georg --

Re: unable to resize mmap object

2006-05-04 Thread Georg Brandl
the way. It would > accept a filename rather than a file descriptor, anonymous blocks would > be handled OS-independently, rather than mapping /dev/zero, and so on.) I'm sure that we will gladly accept a patch implementing this approach. Cheers, Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: C API: getting sys.argv

2006-05-16 Thread Georg Brandl
> expense of making the caller pass sys.argv. But it would save you >> having to muck about with importing "sys", then plucking out the >> module's argv attribute. > > but this is great advice. Actually, use can use PySys_GetObject("argv") instead. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: how to clear up a List in python?

2006-05-26 Thread Georg Brandl
here... > pathetic for sure... You perhaps shouldn't become so excited. Next time, if you're not sure of the correctness of your solution, try to wait a bit before posting it, and see if someone other comes up with the same thing you would have posted. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: how to clear up a List in python?

2006-05-26 Thread Georg Brandl
my ten years here... > pathetic for sure... You perhaps shouldn't become so excited. Next time, if you're not sure of the correctness of your solution, try to wait a bit before posting it, and see if someone other comes up with the same thing you would have posted. Georg -- http://mail.python.org/mailman/listinfo/python-list

SetUp functions for multiple test cases

2009-01-20 Thread Georg Schmid
I've just started working with unittests and already hit a snag. I couldn't find out how to implement a setup function, that is executed only _once_ before all of the tests. Specifically, I need this for testing my database interface, and naturally I don't want to create a new database in-memory an

Re: SetUp functions for multiple test cases

2009-01-20 Thread Georg Schmid
On Jan 20, 3:57 pm, Roy Smith wrote: > In article > <45b0bf56-673c-40cd-a27a-62f9943d9...@r41g2000prr.googlegroups.com>, >  Georg Schmid wrote: > > > I've just started working with unittests and already hit a snag. I > > couldn't find out how to impl

Python Bug Day on April 23

2009-04-15 Thread Georg Brandl
over IRC, in #python-dev on irc.freenode.net, and the Wiki page http://wiki.python.org/moin/PythonBugDay has all important information and a short list of steps how to get set up. Please spread the word! Georg -- http://mail.python.org/mailman/listinfo/python-list

Correction: Python Bug Day on April 25

2009-04-15 Thread Georg Brandl
them together with the core developers. We will coordinate over IRC, in #python-dev on irc.freenode.net, and the Wiki page http://wiki.python.org/moin/PythonBugDay has all important information and a short list of steps how to get set up. Please spread the word! Georg -- http://mail.python.org/ma

Reminder: Python Bug Day on Saturday

2009-04-23 Thread Georg Brandl
will coordinate over IRC, in #python-dev on irc.freenode.net, and the Wiki page http://wiki.python.org/moin/PythonBugDay has all important information and a short list of steps how to get set up. Hope to see you there! Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: MVC with Python

2008-09-16 Thread Georg Altmann
Maric Michaud schrieb: Le Tuesday 16 September 2008 14:47:02 Marco Bizzarri, vous avez écrit : On Tue, Sep 16, 2008 at 1:26 PM, Georg Altmann <[EMAIL PROTECTED]> wrote: Marco Bizzarri schrieb: On Mon, Sep 15, 2008 at 9:37 PM, Georg Altmann <[EMAIL PROTECTED]> wrote: But this imp

Re: andmap and ormap

2006-03-14 Thread Georg Brandl
x27;s quite possible that people do checkout the SVN trunk and play with them. Course, Fredrik could have said "In 2.5 you'll be able to write..." Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: andmap and ormap

2006-03-14 Thread Georg Brandl
Peter Otten wrote: > Python 2.5 will feature similar functions any() and all() which seem to have > a fixed predicate == bool, though. You cannot write all(predicate, list) but all(predicate(x) for x in list) Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Python poly obsolete?

2006-03-17 Thread Georg Brandl
ere that's it's obsolete now. What's the > alternative? This module was not useful enough to remain in the standard library. However, you can find poly.py in /usr/lib/python2.x/lib-old and use it from there (either adding this directory to sys.path or copying the file to your workin

__dict__ strangeness

2006-03-18 Thread Georg Brandl
line 1, in ? AttributeError: 'C' object has no attribute 'a' >>> >>> class D(object): ... __dict__ = {} ... >>> d = D() >>> d.a = 1 >>> d.__dict__ {} >>> d.__dict__ = {} >>> d.a 1 Thanks, Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there no end to Python?

2006-03-18 Thread Georg Brandl
if you need it, you'll have used a library PEP328 multi-line imports: a matter of parentheses PEP331 locale-independent float/string conversions: never heard of it myself ;) Summa summarum, exactly one new syntax, one new builtin and one new stdlib module to care about. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: __dict__ strangeness

2006-03-18 Thread Georg Brandl
Alan Franzoni wrote: > Georg Brandl on comp.lang.python said: > >>>>> d.__dict__ >> {} > > Which Python version, on which system? I can see the properly inserted > attribute in __dict__, both with old style and new style classes. It's 2.4.2, on Linu

Re: __dict__ strangeness

2006-03-18 Thread Georg Brandl
[moving to python-dev] Alex Martelli wrote: > Georg Brandl <[EMAIL PROTECTED]> wrote: > >> can someone please tell me that this is correct and why: > > IMHO, it is not correct: it is a Python bug (and it would be nice to fix > it in 2.5). Fine. Credits go to Michal

Re: Can I use a conditional in a variable declaration?

2006-03-19 Thread Georg Brandl
ly have to > define it once. > > def mux(s, t, f): > if s: > return t > return f But be aware that this is not a complete replacement for a syntactic construct. With that function, Python will always evaluate all three arguments, in contrast to the and/or-for

Re: C-API: A beginner's problem

2006-03-19 Thread Georg Brandl
t needed anymore: Py_DECREF(seq); > return newseq; > > bubblesort(int list[], int seqlen) is doing the actual job and it is > working. > > What did I do wrong? As I am quite new to C, I probably made many > mistakes, so please feel free to correct me. There

Re: C-API: A beginner's problem

2006-03-19 Thread Georg Brandl
Fabian Steiner wrote: > Georg Brandl wrote: >> Fabian Steiner wrote: >>> [...] >>> for (i = 0; i <= seqlen; i++) { >> >> That is one iteration too much. Use >> >> for (i = 0; i < seglen; i++) >> >>>

Bug Day on Friday, 31st of March

2006-03-20 Thread Georg Brandl
thon.org/cgi-bin/moinmoin/PythonBugDay Cheers, Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: ** Operator

2006-03-21 Thread Georg Brandl
dge, viewpoints and experiences, who sometimes disagree. Had I seen the tracker item and/or read this thread to the end before I made that checkin, I probably wouldn't have made it... ;) Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Module documentation

2006-03-26 Thread Georg Brandl
stand how the methods work. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: __slots__

2006-03-27 Thread Georg Brandl
thinks I shouldn't use something like > > for i in lst: > ... > > in my code at the global level because some module in the standard > library has a function with a local i. > > Pychecker also froze on my system. Pychecker imports the modules. Thus these things can happen when a module expects not to be imported as-is. > I don't recommend the use of these tools. Well, then I don't recommend anyone reading your code Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: 1.090516455488E9 / 1000000.000 ???

2006-03-28 Thread Georg Brandl
print 1.090516455488E15 / 100 1090516455.49 print is using str() which formats the float number with 12 digits precision and therefore rounds the result. repr() however, which is used by the interpreter when printing out expression results, uses 17 digits precision which is why you can

Re: Why are so many built-in types inheritable?

2006-03-28 Thread Georg Brandl
Fabiano Sidler wrote: > I really wanted to learn the reason for this, nothing else! ;) I suspect performance reasons. Can't give you details but function is used so often that it deserves special treatment. Georg -- http://mail.python.org/mailman/listinfo/python-list

Reminder: Bug Day this Friday, 31st of March

2006-03-29 Thread Georg Brandl
and more information, see the Wiki page at http://www.python.org/cgi-bin/moinmoin/PythonBugDay Cheers, Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Command line option -Q (floor division)

2006-03-29 Thread Georg Brandl
changed with Python 3.0. Most certainly. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: any() and all() on empty list?

2006-03-30 Thread Georg Brandl
ts which are pink) => true > all(flying elephants which are not pink) => true > > So, these flying elephants -- are they pink or not? No, you ask two different sets whether they are true. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are so many built-in types inheritable?

2006-03-30 Thread Georg Brandl
Antoon Pardon wrote: > Op 2006-03-28, Georg Brandl schreef <[EMAIL PROTECTED]>: >> Fabiano Sidler wrote: >>> I really wanted to learn the reason for this, nothing else! ;) >> >> I suspect performance reasons. Can't give you details but function >

Re: Why are so many built-in types inheritable?

2006-03-30 Thread Georg Brandl
that hard to understand, is it? Whoever made the builtin types new- style types didn't add the BASETYPE flag to function or slice. Apparently he thought it wasn't worth the effort as he couldn't imagine a use case for it. So, when someone had liked them to be subclassable, he'd have written a patch. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are so many built-in types inheritable?

2006-03-31 Thread Georg Brandl
s expected, although they had no reason to suspect so. I've told you already: if a developer wants a feature not currently implemented, he/she can - ask on python-dev why - submit a feature request - submit a patch If he/she's not able to do one of these, he/she can at least convince so

Re: Why are so many built-in types inheritable?

2006-03-31 Thread Georg Brandl
Antoon Pardon wrote: > Op 2006-03-31, Georg Brandl schreef <[EMAIL PROTECTED]>: >> Antoon Pardon wrote: >> >>> Well that looks somewhat short sighted to me. It is also why python >>> seems to throws so many surprises at people. >>> >>> My

Re: very very basic question

2006-04-02 Thread Georg Brandl
t; x=input ('enter a number betwenen 0 and 1: ') > for i range (10) > x=3.9*x*(1-x) > print x > > main() At the very end of the program, that is here, after main(), just insert raw_input() Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: print() in Python 3000 return value?

2006-04-02 Thread Georg Brandl
bayerj wrote: > Expressions like > >>>> 2 + 2 > > return None, too. Sorry? 2+2 here returns 4, and certainly should with your Python. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: very very basic question

2006-04-02 Thread Georg Brandl
as the program terminates. To prevent that, add a call to raw_input() at the end of your script. Python will then prompt you for input, and therefore the window will stay open. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: print() in Python 3000 return value?

2006-04-03 Thread Georg Brandl
function with two operations. Let > "print" print, and propose a separate function (named "format" --yuck-- > or some such) that returns the same text as a string. Yes! That's really a good idea. But "format" is a bad name. Let's call it

Re: tuple syntax ',' (ending in comma?)

2006-04-04 Thread Georg Brandl
uld if all expressions in parentheses were tuples. Thus, the comma is necessary to disambiguate and explicitly tell the parser that you mean to construct a tuple. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: using range() in for loops

2006-04-05 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > hi John, > Python doesn't provide for loop like C / C++ but using Range() or > Xrange() you can achive all the functionalities of the C for loop. Not quite. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: using range() in for loops

2006-04-05 Thread Georg Brandl
the range. But it's a problem when someone just does l = range(100) and assumes that he's got a list, probably doing l.remove(5) and so on. In Python 3000, plans are that range() will be the same as xrange() is now, and anyone needing a list can call list(range(...)). Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: using range() in for loops

2006-04-05 Thread Georg Brandl
Steven D'Aprano wrote: > On Wed, 05 Apr 2006 16:21:02 +0200, Georg Brandl wrote: > >> Because of backwards compatibility. range() returns a list, xrange() an >> iterator: list(xrange(...)) will give the same results as range(...). > > Georg is pretty much correct in

<    1   2   3   4   5   >