Re: One module per class, bad idea?

2006-12-12 Thread Carl Banks
(I think it's just convention, really. You don't have to use one class per module in Python, and given that freedom, most Python programmers didn't.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: One module per class, bad idea?

2006-12-12 Thread Carl Banks
Carl J. Van Arsdall wrote: > Carl Banks wrote: > > Carl J. Van Arsdall wrote: > >> A module per class makes a lot of sense in some cases, or rather, make > >> your module your class (look at the singleton pattern). I actually like > >> to structure all of

Re: Iterating over several lists at once

2006-12-13 Thread Carl Banks
, and that's doubtful. OTOH, something like this has decent shot of appearing in a standard functional or iterator module of some sort. > Thanks for replying me. You're welcome in advance. Also, one note about comp.lang.python and/or python-list: it's conventional here to put replies beneath the quoted text. This is for the benefit of future readers, so they don't have read conversations in reverse order. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Conditional iteration

2006-12-13 Thread Carl Banks
way to nest for and if clauses in listcomps, and the two methods are considered distinct. Although Guido has said that saving indentation levels is important, he hasn't said anything (that I'm aware of) that suggests it's important enough to add this complexity and redundancy

Re: Conditional iteration

2006-12-13 Thread Carl Banks
nvince him. By the way, I'd suggest when posting to comp.lang.python and/or python-list in the future, you put your replies beneath the quoted text for the benefit of any future readers (not to mention present readers). Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Conditional iteration

2006-12-14 Thread Carl Banks
at wrote: > Carl Banks wrote: > > > at wrote: > >> Well, all I can say that for me as a user it would make sense... > > > > Which is, like, step one out of a hundred for getting a syntax change > > into the language. > > > >> Curiosity: in what

Re: tuple.index()

2006-12-14 Thread Carl Banks
read, making sense is about step one out of a hundred for getting your change into the language. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Conditional iteration

2006-12-14 Thread Carl Banks
. If you think that this change was made for "psychological" reasons, you are terribly deluded. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Conditional iteration

2006-12-14 Thread Carl Banks
ve with, therefore it has to make sense for the community as a whole, not just one person. But you've completely ignored concerns that don't apply to YOU this whole thread. Carl Banks PS. You're top-posting again. Please respect other readers. -- http://mail.python.org/mailman/listinfo/python-list

Re: tuple.index()

2006-12-14 Thread Carl Banks
tent" fear is a better word. It's like when people are deathly afraid to get on an airplane, but think nothing of riding in a car without a seatbelt. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Has comparison of instancemethods changed between python 2.5 and 2.4?

2006-12-16 Thread Carl Banks
ef same_method(a,b): return a.im_class is b.im_class and a.im_func is b.im_func and a.im_self is b.im_self Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Wrapping classes with pure virtual functions

2006-12-17 Thread Carl Banks
ler always knows the exact type of a direct, non-pointer-accessed object. So even if you could create a class_, it would only ever be a Base, and never a derived class. You have to use pointers to get polymorphism. As an alternative, consider wrapping the derived classes instead. It might not be much more work if Boost wraps everything nicely. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionary, iterate & update objects

2006-12-18 Thread Carl Banks
ontain Python objects (__dict__ excepted). tuples, frozensets, instancemethods, are immutable but do contain Python objects. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: python-hosting.com projects: dead?

2006-12-18 Thread Carl Banks
x27;re overreacting? Try checking the SVN tomorrow. Even Python programs can have downtime. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: what is wrong with my code?

2006-12-20 Thread Carl Banks
t questions to answer. "What is wrong with my code?" is > > a container of many many smaller questions, and you need to focus your > > questions better. > > it says that progress_table is not defined. i don't know why. It looks like you have bigger problems than an undefined variable. Python does not have implicit access to methods and attributes (members) like C++ and Java do. Methods must accept an explicit self parameter that refers to the object (analogous to this in C++ and Java) to access attributes. Your code defines a class, but self is nowhere to be found. I suggest getting a good book and/or reading the tutorial (http://docs.python.org/tut/) and making sure you can do easy stuff first. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: what is wrong with my code?

2006-12-20 Thread Carl Banks
Pyenos wrote: > thanks for your point. so because i have said class blah: i must > explicitly say self for every instantiation of object? http://docs.python.org/tut/ Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: One module per class, bad idea?

2006-12-22 Thread Carl Banks
Kent Johnson wrote: > Carl Banks wrote: > > Now, I think this is the best way to use modules, but you don't need to > > use modules to do get higher-level organization; you could use packages > > instead. It's a pain if you're working on two different classe

Re: One module per class, bad idea?

2006-12-22 Thread Carl Banks
sses--though in fairness the one with 24 has a bunch of small mixins.) Soon as this overloaded holiday season is over, they're getting broken up. > So... there's no magic "one size fits all" answer here - do what makes > sense. > > As Carl points out, decen

Re: One module per class, bad idea?

2006-12-22 Thread Carl Banks
Paddy wrote: > Carl Banks wrote: > > Erik Johnson wrote: > > > The file has now grown into a 6800 line beast (including docstring, > > > whitespace, and CVS history). Pretty much any time we implement some new > > > functionality, there are at least

Re: One module per class, bad idea?

2006-12-22 Thread Carl Banks
ctoring, it's a partial solution hack that'll lead to more confusion and delay a real solution even more. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Use a Thread to reload a Module?

2006-12-22 Thread Carl Banks
t. For example, can requests come in fast enough to spawn another load_data before the first had ended? You should consider trying to acquire a threading.Lock in load_data and waiting and/or returning immediately if you can't. Other things can go wrong, too. Using threads requires care. But hopefully this'll get you started. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: One module per class, bad idea?

2006-12-22 Thread Carl Banks
Gabriel Genellina wrote: > At Friday 22/12/2006 22:58, Carl Banks wrote: > > > > Usually no other files need to change. Ex: you have BigOldModule > > > including ClassA, ClassB and FunctionC. Move each one onto its own > > > module, perhaps including a

Re: One module per class, bad idea?

2006-12-25 Thread Carl Banks
Kent Johnson wrote: > Carl Banks wrote: > > Kent Johnson wrote: > >> Carl Banks wrote: > >>> Now, I think this is the best way to use modules, but you don't need to > >>> use modules to do get higher-level organization; you could use packages >

Re: How to depress the output of an external module ?

2006-12-26 Thread Carl Banks
ion. Try this: fd = os.dup(1) os.close(1) sys.stdout = os.fdopen(fd) It's poor design and extremely inconsiderate for a library to print to stdout except as an overridable default.(Not to mention it gives ammo to people who want dynamically scoped globals.) A long term solution might be to hag

Re: How to depress the output of an external module ?

2006-12-26 Thread Carl Banks
Carl Banks wrote: > [EMAIL PROTECTED] wrote: > > After some trials I found that put "os.close(1)" before calling the > > function will depress the output. In fact, "os.close(1)" closed > > standard output, but I don't know how to open it again af

Re: Getting unicode escape sequence from unicode character?

2006-12-27 Thread Carl Banks
cape": >>> a = u'\u1234' >>> a u'\u1234' >>> print a ሴ >>> ord(a) 4660 >>> hex(ord(a)) '0x1234' >>> a.encode('unicode_escape') '\\u1234' Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: loose methods: Smalltalk asPython

2006-12-27 Thread Carl Banks
van Rossum as I am, simply because > so-and-so says something is bad and therefore it must be true is a > fallacious response. The same could be said of Smalltalk, i.e., because Smalltalk does it therefore it is good is just as fallacious. Regardless, whatever Guido pronounces is what happens. If he's adamantly against something, it's pretty much an academic discussion. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Anyone persuaded by "merits of Lisp vs Python"?

2006-12-28 Thread Carl Banks
the first thing you should have done is to not cross-post this. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Anyone persuaded by "merits of Lisp vs Python"?

2006-12-29 Thread Carl Banks
Paddy wrote: > Carl Banks wrote: > > If you were so keen on avoiding a flame war, the first thing you should > > have done is to not cross-post this. > > I want to cover Pythonistas looking at Lisp and Lispers looking at > Python because of the thread. The cross post

Re: probably a stupid question: MatLab equivalent of "diff" ?

2006-12-29 Thread Carl Banks
ample: [ x-y for (x,y) in zip(a[1:],a[:-1]) ] Or, to avoid creating two new arrays, use iterators: import itertools [ x-y for (x,y) in itertools.izip(itertools.islice(a,0,-1),itertools.islice(a,1)) ] Carl -- http://mail.python.org/mailman/listinfo/python-list

Re: array of class

2007-01-02 Thread Carl Banks
ter Word. You have to call the class object, same as you'd call a function, so you have to follow it with parentheses: s1.append(Word()) You could, in fact, have an array of classes, and there are actually reasons you might want to do that, but that's pretty advanced. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Why is pow a builtin, anyways?

2007-01-04 Thread Carl Banks
7;Traceback (most recent call last): > File "", line 1, in > sqrt(9) > NameError: name 'sqrt' is not defined' The third argument to the builtin pow is a special usage for cryptography, and something specific like that needs no representation in the builtin n

Re: subclassing a module: misleading(?) error message

2007-01-04 Thread Carl Banks
guments that a normal type constructor does, so you get the error. Does that clear things up? Probably not. For a detailed explanation of how this all works, look for some resources on learning "metaclasses" or "metatypes" in Python. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: What is proper way to require a method to be overridden?

2007-01-04 Thread Carl Banks
results in a more informative error message But, in the end, if someone wants to define a class that defiantly refuses to declare a method, you can't stop them. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: (newbie) Is there a way to prevent "name redundancy" in OOP ?

2007-01-05 Thread Carl Banks
p in a dictionary is that, in many real applications, the pin name would often be specified in the input. (This is very often the case whenever people want to know the symbol an object is bound to, for any application.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: What is proper way to require a method to be overridden?

2007-01-05 Thread Carl Banks
Fuzzyman wrote: > Carl Banks wrote: > > jeremito wrote: > > > I am writing a class that is intended to be subclassed. What is the > > > proper way to indicate that a sub class must override a method? > > > > You can't (easily). > > > > Well

Re: (newbie) Is there a way to prevent "name redundancy" in OOP ?

2007-01-05 Thread Carl Banks
, you might as well just use globals() and do it explicitly, rather than mucking around with Python frame internals. (And it doesn't make the class unusable for more straightforward uses.) for _name in ('aap','dcr'): globals()[_name] = Pin(_name) del _name Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: (newbie) Is there a way to prevent "name redundancy" in OOP ?

2007-01-07 Thread Carl Banks
Martin Miller wrote: > Carl Banks wrote: > > > Martin Miller wrote: > > > ### non-redundant example ### > > > import sys > > > > > > class Pin: > > > def __init__(self, name, namespace=None): > > > self.name = name

Re: Python code written in 1998, how to improve/change it?

2006-01-22 Thread Carl Cerecke
tate]) > ... > A > B > C Good idea. But we can eliminate the dictionary lookup: a1 = compile('print "A"; state=b1','','exec') b1 = compile('print "B"; state=c1','','exec') c1 = compile('print "C"; state=None','','exec') state = a1 while state: eval(state) Cheers, Carl -- http://mail.python.org/mailman/listinfo/python-list

Re: Python code written in 1998, how to improve/change it?

2006-01-22 Thread Carl Cerecke
s_on = compile(''' print 'on' action = next_action() if action == 'lift': state = s_on elif action == 'push': state = s_off else: state = None ''','','exec') s_off = compile(''' print 

Re: ANN: Introduction to Event-Driven Programming

2006-01-23 Thread Carl Cerecke
n python (without resorting to bytecode hacks) under the thread "Python code written in 1998, how to improve/change it?". That would be a part of what you want. Cheers, Carl. -- http://mail.python.org/mailman/listinfo/python-list

Weird generator id() behaviour (was Re: Python code written in 1998, how to improve/change it?)

2006-01-24 Thread Carl Cerecke
clock() #print "action generator:",z-a next_action = actions(r).next #print "---" state = s_on # start state #a = time.clock() while state: eval(state) #z = time.clock() #print z-a print "---" next_action = actions(r).next s_g_on = g_on() s_g_off = g_off() state = s_g_on #a = time.clock() while state: print id(state) state = state.next() #z = time.clock() #print z-a #Cheers, #Carl. -- http://mail.python.org/mailman/listinfo/python-list

Re: Weird generator id() behaviour (was Re: Python code written in1998, how to improve/change it?)

2006-01-24 Thread Carl Cerecke
Fredrik Lundh wrote: > Carl Cerecke wrote: > > >>It turns out that generators are more efficient than the eval function >>excuting bits of compiled code. About 20-25% faster. > > > why are you using generators to return things from a function, when > you can ju

Re: Weird generator id() behaviour (was Re: Python code written in1998, how to improve/change it?)

2006-01-24 Thread Carl Cerecke
Carl Cerecke wrote: > Fredrik Lundh wrote: > >> Carl Cerecke wrote: >> >> >>> It turns out that generators are more efficient than the eval function >>> excuting bits of compiled code. About 20-25% faster. >> >> >> >> why are you

Re: Weird generator id() behaviour (was Re: Python code written in1998, howto improve/change it?)

2006-01-24 Thread Carl Cerecke
Adding a continue statemtent after the yield statements yields :-) a speed increase. Still not as good as functions though. (about 30% slower) Cheers, Carl Carl Cerecke wrote: > Carl Cerecke wrote: > Generator FSM done properly (well, better anyway). They are still almost > twice a

while/break - The pure-python FSM implementation to Rule Them All.

2006-01-25 Thread Carl Cerecke
code. Running this code will print out the generated FSM code for both a while/break implementation of the FSM and a function-based implementation. It then does some timing measurements. Cheers, Carl. #!/usr/bin/env python from StringIO import StringIO # number of random inputs fed to the FSM (if we

Re: while/break - The pure-python FSM implementation to Rule Them All.

2006-01-25 Thread Carl Cerecke
Paul Rubin wrote: > Carl Cerecke <[EMAIL PROTECTED]> writes: > >>3. Not as fast as byte code hacks, or using pyrex/psyco. Peter Hansen >>is right. One of those is likely a better solution if you don't need >>pure python. > > > If you don'

Re: 2-dimensional data structures

2006-01-26 Thread Carl Cerecke
One list with nine elements, each of which is a list with nine numbers. [[5,2,7,3,9,8,1,4,6], [3,1,4,], ] Cheers, Carl. -- http://mail.python.org/mailman/listinfo/python-list

Re: beta.python.org content

2006-01-26 Thread Carl Banks
ble. It cuts down on the sensory overload from the previous site. And, it passes the no-style litmus test (i.e.,whether you can still read and understand the site with the style sheets disabled.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: CLI

2006-02-09 Thread Carl Cerecke
it. Any help? > Try: pexpect.sourceforge.net Cheers, Carl. -- http://mail.python.org/mailman/listinfo/python-list

Re: appending to a list via properties

2006-02-11 Thread Carl Banks
, list.append) This is an impressive, spiffy little class. > Well? I suspect it's too sneaky and not commonly useful enough to get serious consideration for the standard library. But definitely submit it to Python Cookbook: http://aspn.activestate.com/ASPN/Python/Cookbook/ Carl Banks P

Re: appending to a list via properties

2006-02-11 Thread Carl Banks
Alex Martelli wrote: > Carl Banks <[EMAIL PROTECTED]> wrote: >... > > > class better_list (list): > > > tail = property(None, list.append) > > > > This is an impressive, spiffy little class. > > Yes, nice use of property. > &

Re: invert the order of a string

2006-02-13 Thread Carl Cerecke
away and gives me what I want... no >>Computer Sciencey > to deal with :) > > > A can be turned back into a string: > >>> st = '0123456789' > >>> reversed(st) > > >>> ''.join( reversed(st) ) > '98765432

Re: Loop Backwards

2006-02-13 Thread Carl Cerecke
but I don't want to. I want it to > stay exactly the same, but I want to start at the end and end at the > beginning. > > Thanks! > > - Dave > for i in reversed(ls): do_stuff() reversed doesn't reverse the list. It returns an iterator that iterates throu

Re: how do you pronounce 'tuple'?

2006-02-13 Thread Carl Cerecke
; that's not nearly as gruesome enough a name to go with the special > lopsided Pythonic creature mentioned above. I suggest we name it a > hurgledink. > So, ahhh, what about zero-tuples? zuple? uple? Surely it would be better for 2,1, and 0-tuples to be called 2,1, and 0-tuples. And, BTW, in New Zealand, I've only ever heard the pronunciation 'tupple'. toople sounds kind-of stoopid. Cheers, Carl. -- http://mail.python.org/mailman/listinfo/python-list

Re: Unexpected behaviour of getattr(obj, __dict__)

2006-02-14 Thread Carl Banks
it. To wit: >>> Parrot.f is Parrot.f False >>> Parrot.__dict__ is Parrot.__dict__ False But wait, it gets weirder. >>> id(Parrot.f) == id(Parrot.f) True >>> id(Parrot.__dict__) == id(Parrot.__dict__) True But that's not all. Redefine Parrot as: class Parrot(object): def f(self): pass def g(self): pass Then, >>> id(Parrot.f) == id(Parrot.g) True your-milage-may-vary-ly yr's, Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Carl Banks
t. > This usually leads to > having each class follow the Singleton pattern, further complicating > the design. Meh. I don't feel too strongly about this, but I'd think an enum as a class is better, because you can't (or, rather, oughtn't) compare constants from different enums. That's a logical demarcation of classes. Sorry if I was a little blunt here. In the end, I really don't see the problems that this enum addresses being all that common; it seems a lot of work for minor benefit. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 354: Enumerations in Python

2006-02-28 Thread Carl Banks
Stefan Rank wrote: > on 28.02.2006 07:50 Carl Banks said the following: > > Ben Finney wrote: > >> This PEP specifies an enumeration data type for Python. > > > [snip] > > > > Here's why I think it's not too useful to begin with: the benefits

Re: C++ OpenGL rendering, wxPython GUI?

2006-02-28 Thread Carl Banks
;ve done similar things in GTK on Linux. I had a gtkglarea canvas, PyOpenGL, and my own C extension all making OpenGL calls. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: how do you move to a new line in your text editor?

2006-03-02 Thread Carl Banks
ems to have a variable tab stop) to edit the file with tabs, but save it with spaces. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: how do you move to a new line in your text editor?

2006-03-02 Thread Carl Banks
John Salerno wrote: > Carl Banks wrote: > > John Salerno wrote: > >> So I'm wondering, how do you all handle moving around in your code in > >> cases like this? Is there some sort of consistency to these things that > >> you can write rules for you

Re: Python rocks

2007-06-14 Thread Carl Banks
1] := 10! Out[1]= 3628800 (The more you know) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: overriding base class

2007-06-29 Thread Carl Banks
On Jun 29, 7:36 pm, alf <[EMAIL PROTECTED]> wrote: > Hi, > > I want to develop a following lib: > > lib space user space > > A -> B -> | -> user_class > > however A and B are abstrac enough to have following: > > user_super_base_class -> | -> A -> B -> | -> user_class > > user space

sys.exit versus termination of source code

2007-07-13 Thread Carl DHalluin
wise idea? Thanks Carl D'Halluin www.qlayer.com -- http://mail.python.org/mailman/listinfo/python-list

mysql "rows affected"

2007-04-26 Thread Carl K
using MySQLdb, I do cursor.execute("update...") How can I tell how many rows were affected ? Carl K -- http://mail.python.org/mailman/listinfo/python-list

Re: mysql "rows affected"

2007-04-26 Thread Carl K
John Nagle wrote: > Carl K wrote: >> using MySQLdb, I do cursor.execute("update...") >> >> How can I tell how many rows were affected ? >> >> Carl K > > cursor = db.cursor() # get cursor > cursor.execute(sql

Re: mysql "rows affected"

2007-04-29 Thread Carl K
Dennis Lee Bieber wrote: > On Thu, 26 Apr 2007 18:18:57 -0700, John Nagle <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> Carl K wrote: >>> using MySQLdb, I do cursor.execute("update...") >>> >>> How can I tell h

ctree data

2007-05-12 Thread Carl K
e.html - This just shows what lengths I am willing to go to. but I really don't want to start learning perl. TIA Carl K -- http://mail.python.org/mailman/listinfo/python-list

installing cx_Oracle.

2007-05-24 Thread Carl K
;, line 17, in __getitem__ def __getitem__(self, key): return self.data[key] KeyError: 'ORACLE_HOME' Now I don't really know whos problem this is. Carl K -- http://mail.python.org/mailman/listinfo/python-list

Re: installing cx_Oracle.

2007-05-24 Thread Carl K
tError: libclntsh.so.10.1: cannot open shared object file: No such file or directory guessing I need to add /usr/lib/oracle/xe/app/oracle/product/10.2.0/client/lib/ to some path? btw - anyone know of a .deb that will install this? Carl K -- http://mail.python.org/mailman/listinfo/python-list

Re: installing cx_Oracle.

2007-05-24 Thread Carl K
Bill Scherer wrote: > Carl K wrote: >> Getting closer, thanks Bill and Diez. >> >> $ export ORACLE_HOME >> $ ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/client >> $ python setup.py build >> $ sudo python setup.py install >> >> $ pyt

Re: installing cx_Oracle.

2007-05-24 Thread Carl K
Dennis Lee Bieber wrote: > On Thu, 24 May 2007 09:07:07 -0500, Carl K <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> Getting closer, thanks Bill and Diez. >> >> $ export ORACLE_HOME >> $ ORACLE_HOME=/usr/lib/oracle/xe/app/oracle

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-30 Thread Carl Banks
(selected value) This is not a joke. I don't mean Python should necessarily do this (though it could be done without any ambiguity or backward incompatibility: there is currently nowhere in Python where two identifiers can be separated by only a space), but new languages should be designed

Re: __call__ considered harmful or indispensable?

2007-08-02 Thread Carl Banks
re glob.glob, select.select, or time.time. It's ugly and potentially confusing. And if I were Polynesian I would keep thinking I was seeing plurals. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: __call__ considered harmful or indispensable?

2007-08-02 Thread Carl Banks
if obj is not None: obj._refcount += 1 else: obj = super(CachedResourceMetaclass,self).__call__(*args) obj._key = args obj._refcount = 1 self._cache[args] = obj return obj Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: How to say $a=$b->{"A"} ||={} in Python?

2007-08-16 Thread Carl Banks
{"A"} ||={}. > > Thanks, > Geoffrey Define b as a default dict: b = defaultdict(dict) b[k]['A'] = l Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: How to say $a=$b->{"A"} ||={} in Python?

2007-08-17 Thread Carl Banks
://docs.python.org/lib/typesmapping.html > > No, this has already been proposed and discarded. The OP does NOT > want this, because it always generates an empty {} whether it is > needed or not. Not really a big hardship, but if the default value > were some expensive-to-construct c

Re: How to setup pyOpenGL3.0.a6 for window xp?

2007-08-17 Thread Carl Banks
oesn't (easily) work with common GUIs like GTK and Wx. If you want to use use OpenGL in a GUI app, then you'll want to find an "OpenGL canvas widget" for that GUI. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Python question (PyNoob)

2007-08-20 Thread Carl Banks
2 Python supports timestamp checking and subprocess calling and whatnot, but stuff like dependency trees you'll have to work out yourself. (BTW, if "make" is failing or annoying you, you might want to consider SCons, which for me has been a lot more intelligent and straight

Re: Python question (PyNoob)

2007-08-20 Thread Carl Banks
and several others are misunderstanding the OP: the OP wants to learn some details of Python without having to *relearn* the basics of programming. It's a reasonable request. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: py2exe/distutils: how to include a tree of files?

2007-08-24 Thread Carl Banks
se because "data_files" wasn't too helpful, there was never much incentive to improve it. Which (getting back to py2exe) is unfortunate since you CAN rely on the location when using py2exe, but it is stuck with the unwieldy usage. Oh well. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: "Try:" which only encompasses head of compound statement

2007-08-27 Thread Carl Banks
ld have to check the error code to distinguish, and reraise if not file not found. # this is the point where success or failure # determines what I do next, that's why I handle # the exception here. try: load_myFile() except IOError, e: if e.errno == 2: # file not found is usually errno 2 print "file not found" else: raise else: # load succeeded, do whatever. One other useful technique is recasting: catching an error close to the call, and raising a different error. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Haskell like (c:cs) syntax

2007-08-29 Thread Carl Banks
one of the more pleasant ones. (At least not without a good set of slice-matching patterns handy, which I don't know if Haskell has.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: We need PIGs :)

2007-08-30 Thread Carl Banks
y people often call Python a good "glue" language for this reason. And when you have a good "glue" language, formal interface guidelines aren't so important. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: status of Programming by Contract (PEP 316)?

2007-08-30 Thread Carl Banks
current project, we're struggling with throughput even though we use highly optimized code. Python would be completely out of the question. Now, control towers don't have these constraints, and system failure is not nearly as critical, so Python is a better option there. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: status of Programming by Contract (PEP 316)?

2007-08-30 Thread Carl Banks
out actually running the code) that the code fulfills the > DBC conditions. I don't see any way to do that with Python > decorators. I don't see any way to do that in Python with built-in DBC syntax, either. :) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Carl Banks
On Fri, 31 Aug 2007 01:15:04 -0400, Roy Smith wrote: > Carl Banks <[EMAIL PROTECTED]> wrote: >> Python really isn't suitable for in-flight controls for various >> reasons, and mission critical concerns is a minor one (systems with >> less underlying complexity

Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Carl Banks
reason why Python couldn't be certified if it passed the tests, but it likely wouldn't pass as easily as a compiled language. OTOH, spiffy features like design-by- contract aren't going to improve your chances of getting FAA cert, either. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Carl Banks
tors, dams, and so on? Come on. BTW, I'm not really agreeing with Russ here. His suggestion (that because Python is not used in highly critical systems, it is not suitable for them) is logically flawed. And Alex's point, that Python has a good track record of reliabilty (look at Go

Re: status of Programming by Contract (PEP 316)?

2007-09-01 Thread Carl Banks
On Sat, 01 Sep 2007 08:38:38 -0300, Jorge Godoy wrote: > Carl Banks wrote: > >> This is starting to sound silly, people. Critical is a relative term, >> and one project's critical may be anothers mundane. Sure a flaw in >> your flagship product is a critical proble

Re: status of Programming by Contract (PEP 316)?

2007-09-01 Thread Carl Banks
On Sat, 01 Sep 2007 17:19:49 +0200, Pierre Hanser wrote: > Carl Banks a écrit : >> >> This is starting to sound silly, people. Critical is a relative term, >> and one project's critical may be anothers mundane. Sure a flaw in >> your flagship product is a cr

py3k - format specifier for strings

2007-09-03 Thread Carl Trachte
ting them. The doc has not yet been written. I haven't consulted the source code yet. Any help in the way of examples would be appreciated. Carl T. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why 'class spam(object)' instead of class spam(Object)' ?

2007-09-07 Thread Carl Banks
;str" were once functions. When these symbols became the names of their respective types, they kept the lower-case spelling, and it became convention for built-in types to be spelled lower-case. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Speed of Python

2007-09-07 Thread Carl Banks
Are there any > way to speed it up? It seems Python automatically created bench1.pyc. Does > Python automatically execute the bench1.pyc to speed it up? Yes, as others have explained. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Python syntax wart

2007-09-09 Thread Carl Banks
n community with your eye for syntax. You're relatively new to Python, correct? If so, maybe you should give yourself some time to see if some of Python's unconventional features grow on you. I've found that wherever Python differs from the common ways to do things,

Re: Python syntax wart

2007-09-10 Thread Carl Banks
e implicit line continuations everywhere between the opening keyword and the colon". To be honest, I've always thought this would be a nice feature to have, but now that I've seen what kind of abominations are possible with it, I'm not so sure. Carl Banks P.S. The &quo

Re: An ordered dictionary for the Python library?

2007-09-12 Thread Carl Banks
hat would make insertion and deletion would be quite expensive. Which might be ok for the OP, but it's often better to go with a btree. Which, you know, would be a reasonable candidate for collections module. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: An ordered dictionary for the Python library?

2007-09-12 Thread Carl Banks
have kept the order separately, but what was the point? I just whipped up a homemade ordered dict class, it worked fine, and I didn't have to worry about keeping them synchronized. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie: self.member syntax seems /really/ annoying

2007-09-12 Thread Carl Banks
rstand where the OP is coming from. I've done flight simulations in Java where there are lot of complex calculations using symbols. This is a typical formula (drag force calculation) that I would NOT want to have to use self.xxx for: FX_wind = -0.5 * rho * Vsq * Sref * (C_D_0 + C_D_alphasq*al

Re: newbie: self.member syntax seems /really/ annoying

2007-09-12 Thread Carl Banks
On Sep 12, 4:52 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > (The loops would necessarily be unwrapped in the actual > bytecode.) And by unwrapped, I mean unrolled. :E3 Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   8   9   10   >