Re: Creating classes and objects more than once?

2008-11-28 Thread Carl Banks
On Nov 28, 2:59 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > Carl Banks <[EMAIL PROTECTED]> writes: > > On Nov 28, 3:15 am, Ben Finney <[EMAIL PROTECTED]> > > wrote: > > > This is resolved in the Python 2.x series by implementing PEP 328 > > > h

Re: Creating classes and objects more than once?

2008-11-28 Thread Carl Banks
On Nov 28, 11:51 pm, Carl Banks > Absolute versus relative imports don't have anything to do with the > issue here.  PEP 328 concerns itself with imports relative to the > executing module in package space.  It has nothing to do with imports > relative to the current directory

Re: Confused about class relationships

2008-11-29 Thread Carl Banks
a second engine object (maybe of a different type altogether), and play the very same Bar objects with that engine instead. > I'm hoping this is a common trap I've fallen into; I just haven't been able to > get my head around it. (I'm a musician...) Well I think it looks pret

Re: Pyhon (with wxPython) on Windows' cygwin: can it be done fully ?

2008-11-30 Thread Carl Banks
own syntax (and the print statement had lots of peculiarities), whereas all function calls follow the same syntax. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: optimization

2008-12-02 Thread Carl Banks
space pollution. IMHO, namespace pollution occurs when you do things like "from module import *"; there is no pollution when you control the whole namespace yourself. Having said that, I do use local functions without closures here and there, when it's something either too silly or too specific to introduce a module-level function for. Judgment call, mostly, but typically I go to the module level. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: optimization

2008-12-02 Thread Carl Banks
bit of time. If it is a concern, run it through a profiler to get an idea of how much it costs, so you can make an informed decision. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: RELEASED Python 3.0 final

2008-12-03 Thread Carl Banks
On Dec 3, 7:51 pm, Barry Warsaw <[EMAIL PROTECTED]> wrote: > On behalf of the Python development team and the Python community, I > am happy to announce the release of Python 3.0 final. Congratulations! This is a great day for the Python community. Carl Banks -- http://mail.python

Re: How can I do this (from Perl) in Python? (closures)

2008-12-03 Thread Carl Banks
ent, so the best you can do is improvise something like this: def make_counter(start_num): start = [start_num] def counter(): start[0] += 1 return start[0] return counter You can access variables from an enclosing scope starting from Python 2.2 (from 2.1 with from __futu

Re: "as" keyword woes

2008-12-04 Thread Carl Banks
developers. So stop complaining. If you don't want to take a few minutes a year to visit Python.org to see what changes are planned for upcoming releases, then feel free to use a language like Java that has the corporate backing to keep bad decisions around for decades. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: "as" keyword woes

2008-12-04 Thread Carl Banks
grown in popularity in spite of (and, I would say, in part because of) a history of backward- incompatible changes with every major release. It's not like Python has ignored the users; it's been very careful and considerate when making backwards-incompatible change. This

Re: "as" keyword woes

2008-12-04 Thread Carl Banks
Warren here who have distributed codebases they can't easily fix up, and who were neither smart nor informed enough to avoid using "as", are a pretty tiny minority, I would guess. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: "as" keyword woes

2008-12-06 Thread Carl Banks
ject.as(class_reference) is highly convenient because it mirrors textually the Java convention of object.asFloat" will go over a lot better than "object.as (class_reference) is the only obvious concise answer". Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Learning Python now coming from Perl

2008-12-06 Thread Carl Banks
7;t think it's really advisable to be completely ignorant of the 2.x difference even if one intends to start with 3.0. There is a lot of code and material out there for 2.x, and until these start to be widely available for 3.x, people will sometimes have to make do with the 2.x stuff. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido's new method definition idea

2008-12-06 Thread Carl Banks
the following are equivalent: def foo(): return bar foo = lambda: bar I had been -0 on this, but now I think I'm -1. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido's new method definition idea

2008-12-06 Thread Carl Banks
#x27;t chime well with this approach. > > "self" is a speaking identifier, "$" isn't. > > Is "@" a "speaking identifier? How about "#" and "!="? Last I heard, > they were all part of Python. None of them are identifiers. $, used as proposed, would be. (Then again, _ is an identifier.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido's new method definition idea

2008-12-06 Thread Carl Banks
e proposal is viable. > > > >> I'd like this new way of defining methods, what do you guys think? > > >> Anyone ready for writing a PEP? > > > >> Cheers, > > >> Daniel > > > >> -- > > >> Psss, psss, put it down! -

Re: Guido's new method definition idea

2008-12-06 Thread Carl Banks
ing like def a.b() would be. The above statement is not equivalent to: self.method = lambda: 1 but I think that's what it ought to be, in general. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido's new method definition idea

2008-12-06 Thread Carl Banks
On Dec 6, 4:39 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > On Dec 6, 1:21 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > > > > > On Dec 6, 9:12 am, "Russ P." <[EMAIL PROTECTED]> wrote: > > > > On Dec 6, 1:02 am, Antoine De Groote &

Re: "as" keyword woes

2008-12-06 Thread Carl Banks
the type while preserving the semantic value as much as possble, so cast is a perfectly appropriate name for it. (BTW, in C++, even pointer-to-pointer static casts don't always preserve the bits.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido's new method definition idea

2008-12-06 Thread Carl Banks
On Dec 6, 6:42 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > > But it's ugly.  No amount of rationalization will make it not ugly. > > The dollar sign is ugly? I beg to differ. Nope, you're wrong. Carl Banks (See where this is going?) -- http://mail.python.org/mailman/listinfo/python-list

Re: "as" keyword woes

2008-12-09 Thread Carl Banks
for once again Python showed what the best way to enter unpleasant waters is: with a lot of restraint--but a "better parsing framework" that eliminated keywords would cause lots of confusion. And finally: it's just plain bad style to use a syntactic element as an identifier, even when allowed. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: internal circular class references

2008-12-10 Thread Carl Banks
(self): return False def create_date_from_dbf_cell(dbf_cell): if dbf_cell.empty(): return NullDate() return ValidDate(dbf_cell.value) If you do this, you don't have to muck around with __getattr__ or __new__ or snooping to datetime.date's class dict anything like that. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: internal circular class references

2008-12-10 Thread Carl Banks
he language. I think mostly it's just a logistical issue. It's reasonable for a class's attributes to be objects of that class (the datetime.date class is a perfect example of when it's useful). It would be preferrable to assign such objects inside the class scope like all ot

Re: Python is slow

2008-12-10 Thread Carl Banks
On Dec 10, 12:42 pm, cm_gui <[EMAIL PROTECTED]> wrote: > Python is SLOW.    And I am not comparing it with compiled languages > like C. > Python is even slower than PHP! cm_gui is TROLL. And I am not compring it with bots like Aaron Castironpi Brody. cm_gui is even troller than

Re: internal circular class references

2008-12-11 Thread Carl Banks
er,NullDate): return True return False # note: in Python 3.0 you would want to throw exceptions # for unexpected types Then use ValidDate instead of datetime.date when the date is specified. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: curses and refreshing problem

2008-12-13 Thread Carl Banks
terminal the underlying I/O is usually line-buffered, meaning that nothing actually gets output until a newline character is sent. Therefore we have to call sys.stdout.flush() to flush the buffer manually. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: curses and refreshing problem

2008-12-14 Thread Carl Banks
On Dec 14, 5:52 am, Karlo Lozovina <_kar...@_mosor.net_> wrote: > Carl Banks wrote > innews:69d2698a-6f44-4d85-adc3-1180ab158...@r15g2000prd.googlegroups.com: > > > Unless you are referring to some wget screen mode I don't know about, > > I suspect wget outputs

Re: alt.possessive.its.has.no.apostrophe

2008-12-15 Thread Carl Banks
ronounce* their possessives exactly as nouns do. They just spell them differently, for no really good reason. The way I see it, if the rule had been, "Use an apostrophe for any word that forms it's possessive by adding an s or z sound", it would have been less inconsistent.

Re: confused about __str__ vs. __repr__

2008-12-18 Thread Carl Banks
out on you with > >> unicode-errors. > > >> So, IMHO the current behavior is desired. > > > So if I want to overload something in my custom class, so that I get a > > nice string whether it's printed directly, or as part of a container, what > > is the recommendation?  Overload both __str__ and __repr__? > > Yep. I would say no. __repr__ should be specific--something that when evaled yields an equal object, if possible--about what the object is. Overloading __repr__ to return an unspecific human-readable message is a mistake, and will frustrate users who are debugging, logging, inspecting objects at the interactive prompt. Neal's problem seems to be with the behavior of dict's __str__ method, which prints repr() of objects when he wants str(). That is intended behavior, like it or not, so I would say the appropriate thing is not use dict's default printed representation, and just write a custom formating function for dicts. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python 3.0 string formatting - really necessary?

2008-12-19 Thread Carl Banks
he > transition to C programming for this student. Lets not forget how > important C is! C programmers who learn Python have to learn all kinds of new things, a new string formating method would be a minor one. As for everyone else, they'll probably have an easier time of it. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python 3.0 string formatting - really necessary?

2008-12-19 Thread Carl Banks
ble to maintain your own hacked- up fork of a highly wrought out programming language? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python 3.0 string formatting - really necessary?

2008-12-19 Thread Carl Banks
hey would have at least deprecated or got rid of the % operator, because that's ugly. There's no reason they couldn't have added another method for printf-style formating, e.g.: "The answer is %s.".sprintf("yes") Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: I always wonder ...

2008-12-22 Thread Carl Banks
doubt over whether he had any credibility, but now there is no doubt that he none at all, so he's not worth replying to, so I don't. I suggest everyone else does likewise and ignores the fool. If you have to followup, at least keep your reply to something short and witty, like, &qu

Re: python3 urlopen(...).read() returns bytes

2008-12-22 Thread Carl Banks
what encoding to use, since it ostensibly has to parse the header. It's reasonable that IF a url request's "Content-type" is text, and/or the "Content-encoding" is given, for urllib to have an option to automatically decode and return a string instead of bytes. (For all I know, it already can do that.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi-dimension list

2008-12-23 Thread Carl Banks
w multidimensional indexing and slicing, most notably numpy. So, for instance, if you were install numpy, you could get multidimensional arrays and slice 'em up however you'd like: import numpy a = numpy.array([[1,2,3],[4,5,6],[7,8,9]]) print a[1:3,0:2] Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Doing set operation on non-hashable objects

2008-12-24 Thread Carl Banks
er, you could create an IdentitySet class that subclasses set and wraps the methods so that they automatically apply wrap and unwrap the arguments on their way in and out (I'd bet there's already a cookbook recipe to do that). Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Exec inside a class method to call other class methods?

2008-12-25 Thread Carl Banks
usually entail a performance penalty (since the compiler has to be invoked for every call), so please use them only what they were intended for. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Exec inside a class method to call other class methods?

2008-12-25 Thread Carl Banks
s supplied through the input. To be honest I am a little concerned over the more-or-less knee-jerk suggestions to refactor this into a highly object-oriented approach. For the task at hand the OP's approach is fine (aside from the use of exec). Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Python module import loop issue

2008-12-29 Thread Carl Banks
change it to do a search by a tag class attribute if you wish; left as an exercise. > 2. Update A1Factory in each module which implements refinements. > _Very_important_, how do I make sure each module is hit - so that the > factory is updated? The module EN will be looking only at base module, > so the other modules is not hit. I will have to import every module in > EN - just to make sure that the A1Factory updation code is hit. This > looks in-elegent. Not worth it. The straightforward, good-enough way above is good enough. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Python module import loop issue

2008-12-29 Thread Carl Banks
Gabriel Genellina wrote: > En Mon, 29 Dec 2008 19:47:51 -0200, Carl Banks > escribi�: > > On Dec 29, 10:51�am, Kottiyath wrote: > > >> Module Factory: > >> A1Factory: {'B1Tag':1.1.B1, 'C1Tag':1.2.C1, 'D1Tag':1.3.D1'} > >&g

Re: pep-8 vs. external interfaces?

2009-01-04 Thread Carl Banks
en you should use camel case for the protocol primitives but prepend an underscore. 4. If you answered, "I include those functions in the same namespace because I am following the example of other language bindings in Perl, Java, Ruby, etc.,", then figure out whether it's important to b

Re: reflection as in Java: how to create an instance from a classname

2009-01-06 Thread Carl Banks
string and use the Reflection API to get at it at run-time. Python, OTOH, is very dynamic, so there is not much demand for spiffy introspection APIs. Functions and classes are ordinary objects, so if you don't know what function to call or class to use at compile-time, you can just pass t

Re: looking for tips on how to implement "ruby-style" Domain Specific Language in Python

2009-01-07 Thread Carl Banks
on module. Yes, that can be done. See PEP 302, Import Hooks: http://www.python.org/dev/peps/pep-0302/ Python's standard importer looks for files with *.py, *.pyc, *.pyd, or *.so extensions. You could write an importer that looks for *.dsl files, and, instead of loading it as a Python file, invokes your DSL parser. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it ok to type check a boolean argument?

2009-01-08 Thread Carl Banks
a function that accepted integers, and 442 was an invalid value, and the function failed silently in a unit test, they would also consider whether it should instead fail loudly. It's always a judgment call how much to screen for bad input, but type errors aren't different from any o

Re: cPickle vs pickle discrepancy

2009-01-08 Thread Carl Banks
lute (since PyImport_Import calls it) so the two modules should both use absolute imports in 2.6. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Making a decorator a staticmethod

2009-01-08 Thread Carl Banks
): widget and self would always be the same object, and that's just a waste. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: BadZipfile "file is not a zip file"

2009-01-09 Thread Carl Banks
;s zipfile module just assumes it's corrupted. The following post from a while back gives a solution that tries to snip the comment off so that zipfile module can handle it. It might help you out. http://groups.google.com/group/comp.lang.python/msg/c2008e48368c6543 Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with -3 switch

2009-01-09 Thread Carl Banks
in questionable practices like relying on accidental side effects, rather than taking the time to try to program robustly. I expect people with that style of programming will have many more issues with the transition. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: I built a nice html templater!

2008-10-06 Thread Carl Banks
cookbook. He probably wrote his own faster than it would have taken him to search for existing systems, and as an added bonus wouldn't have had to work around all those things that are almost but not quite the way he wanted. Cut him some slack. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Emacs users: feedback on diffs between python-mode.el and python.el?

2008-10-16 Thread Carl Banks
n on source forge, not the ancient version of python-mode in the Python repository) has a fix for this issue. It doesn't look like there's any way to browse the subversion any more, though. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Emacs users: feedback on diffs between python-mode.el and python.el?

2008-10-16 Thread Carl Banks
On Oct 16, 12:21 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Carl Banks a écrit : > > > On Oct 14, 1:05 pm, Bruno Desthuilliers > > <[EMAIL PROTECTED]> wrote: > >> - a slightly less but still annoying problem (I wouldn't > > call it a b

Re: Emacs users: feedback on diffs between python-mode.el and python.el?

2008-10-17 Thread Carl Banks
On Oct 17, 4:25 am, Damien Wyart <[EMAIL PROTECTED]> wrote: > * Carl Banks <[EMAIL PROTECTED]> in comp.lang.python: > > > The python-mode.el on Subversion (python-mode's Subversion on source > > forge, not the ancient version of python-mode in the Python >

Re: I want to release the GIL

2008-10-21 Thread Carl Banks
threading.Condition() def f(): global counter c.acquire() while counter % 1 == 0: # == 1 for the other thread c.wait() do_something() counter += 1 c.notify() c.release() The reason threading.Condition is required and not a simple lock is that simply acquiring the lock is not enough; the counter must be in the right state as well. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: I want to release the GIL

2008-10-21 Thread Carl Banks
the lock almost always acquired it right back, since there was only a tiny window in which a thread switch could take place. Obviously the wisdom of what he was doing was suspect, but the OP was right in that a manual GIL release would allow a thread switch and could have helped avoid starvation in that case. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: better scheduler with correct sleep times

2008-10-21 Thread Carl Banks
this is > that the only way to insert something new inside a queue > is by doing it from scheduled function. Yeah, that does happen. I often used this sort of thing (pre-Python days, so a long time ago) in single-threaded, real-time simulations. Don't know mcuh about the sched module, but time scheduling in general doesn't need multithreading, not one bit. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: I want to release the GIL

2008-10-21 Thread Carl Banks
On Oct 21, 7:49 am, MRAB <[EMAIL PROTECTED]> wrote: > On Oct 21, 10:22 am, Carl Banks <[EMAIL PROTECTED]> wrote: > > > On Oct 21, 5:09 am, "Gabriel Genellina" <[EMAIL PROTECTED]> > > wrote: > > > > En Tue, 21 Oct 2008 04:58:00 -0

Re: Possible read()/readline() bug?

2008-10-23 Thread Carl Banks
o tried this with read(), and I get the same > results.  It's not acceptable that I have to close and reopen the file > before every read when I'm doing random record access. You can call f.flush() to force it to discard the cache. Or use unbuffered I/O. Better yet, get rid of file I/O altogether and use an memory mapped file. > So, is this a bug, or am I being stupid? Well, it's not a bug, so Seriously, I advise you not to submit a bug report. Doesn't mean you're stupid, maybe you didn't know about unbuffered I/O or the flush() method. That just means you're uneducated. :) But please leave seek() out it. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Ordering python sets

2008-10-27 Thread Carl Banks
t; > > Bye, > > bearophile > > > Since python is dynamic language, I think it should be possible to do > something like this: > > a = list([1, 2, 3, 4, 5], implementation = 'linkedlist') > b = dict({'a': 'A'}, implementation = 'bi

Database specialized in storing directed graphs?

2008-10-27 Thread Carl Banks
why I hope someone else has done it. I'm guessing no. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Simplifying anonymous inner classes?

2008-11-01 Thread Carl Banks
, bases,clsdict) obj = cls() return obj class load(Action): __metaclass__ = self_instantiate Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: False and 0 in the same dictionary

2008-11-05 Thread Carl Banks
ct() self.false_surrogate = object() super(special_dict,self).__init__(*args,**kwargs) def __getitem__(self,value): if value is True: value = self.true_surrogate elif value is False: value = self.false_surrogate super(special_dict,self).__getitem__(value) ## etc. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Code in __init__.py, is it bad form?

2009-02-23 Thread Carl Banks
de I don't need, too, and I never concern myself with them, so it's probably a misplaced irk. Go ahead and use it. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: A tale of two execs

2009-02-24 Thread Carl Banks
if I wanted that type of > functionality I would have to use os.dup, fork, exec, which meant > reinventing the wheel.  I overcame the issue of dealing with msvcrt > and _subprocess under windows by requiring python24 or greater under > windows. Distributing the interpreter doesn't

Re: What's so wrong about execfile?

2009-02-27 Thread Carl Banks
d safer ways to do this (use getattr, setattr, globals, and locals built-ins). And if you find yourself using them a lot, it's a red flag that you should be using dicts instead. - Don't ever pass any data to exec or eval that you didn't either write, or thoroughly inspect, yourself. Especially don't pass it any data you received over the network. You have to be the super extreme expert that Steven described, and own a lot of liability insurance, befor you can do that. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: OTish: convince the team to drop VBScript

2009-02-28 Thread Carl Banks
self well, and it might have even been a real issue. Python is not, unfortunately, the easiest language to deploy applications in. I don't think there is any deployment difficulty so great that I would ever chose VBscript, but opinions might differ. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: setting PYTHONPATH to override system wide site-packages

2009-02-28 Thread Carl Banks
ot; at your csh prompt? Is the module you're trying to import there? You approach should work. These are just suggestions on how to diagnose the problem; we can't really help you figure out what's wrong without more information. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: setting PYTHONPATH to override system wide site-packages

2009-02-28 Thread Carl Banks
On Feb 28, 9:18 pm, per wrote: > On Feb 28, 11:53 pm, per wrote: > > > > > On Feb 28, 11:24 pm, Carl Banks wrote: > > > > On Feb 28, 7:30 pm, per wrote: > > > > > hi all, > > > > > i recently installed a new version of a package usi

Re: What's so wrong about execfile?

2009-03-02 Thread Carl Banks
On Mar 2, 8:43 am, John Nagle wrote: > Carl Banks wrote: > > On Feb 27, 7:21 pm, Sammo wrote: > >> Given that execfile has been removed in py3k, I want to understand > >> exactly why. > > >> Okay, I get that execfile is bad from the following thread:

Re: random module gives same results across all configurations?

2009-03-03 Thread Carl Banks
ou can subclass random.Random to do it. (See the source code to random.py for example.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: random module gives same results across all configurations?

2009-03-04 Thread Carl Banks
nned fake-random sequence. Sometimes random sequences are used to generate data, and you might want to give the user power to regenerate the same data by seeding the PRNG with the same seed. (A well-known example is "Free Cell", where the game number is just an RNG seed.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Inverse of dict(zip(x,y))

2009-03-05 Thread Carl Banks
and values() match in order) Just as an example, if you are using a third-party library function that demands side-by-side inputs in respective lists, you could make use of it. That's not a good interface, IMHO, but if you have to use such a library, and you want to supply key-value pairs, then you can use keys and values seperately. populate_database(d.keys(),d.values()) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: "/a" is not "/a" ?

2009-03-06 Thread Carl Banks
e same object they created themselves, or is an object guaranteed by a library or the langauge to never change, irrespective of whether the object is mutable or not. At no point on the learning curve is the distinction of when to use "is" or not ever mutability. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: how to prevent python import from looking into the current directory

2009-03-06 Thread Carl Banks
inction between “absolute” and > “relative” imports http://www.python.org/dev/peps/pep-0328/>. He might, but it won't help him with his problem. Relative imports aren't involved in this situation. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: RELEASED Python 3.1 alpha 1

2009-03-07 Thread Carl Banks
schedule details: > >      http://www.python.org/dev/peps/pep-0361/ I see that Brett Canon's importlib has finally made it into Python standard library. Congrats there (if you still read this list), I am struggling with Python's arcane import semantics (for something ridiculously silly) now and I feel your pain. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: speeding up reading files (possibly with cython)

2009-03-08 Thread Carl Banks
#x27;) # do stuff with split_values finally: gc.enable() Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython fast and slow

2009-03-08 Thread Carl Banks
med_callback_of_some_sort( self.draw_frame,0.005) def draw_frame(self): self.square.SetPosition((self.square_pos, 30)) self.square_pos += 1 if self.square_pos < 200: wx.set_timed_callback_of_some_sort( self.draw_frame,0.005) As for why it works fine in PyScripter but not when started from Explorer, well, let's just say that when you abuse callbacks like you did, you shouldn't expect reasonable behavior. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython fast and slow

2009-03-08 Thread Carl Banks
On Mar 8, 12:35 pm, iu2 wrote: > On Mar 8, 1:42 pm, Carl Banks wrote: > > > > > On Mar 8, 1:52 am, iu2 wrote: > > > > On Mar 6, 6:52 pm, Mike Driscoll wrote: > > > > > ... > > > > Can you post a sample application so we can try to figure

Re: "/a" is not "/a" ?

2009-03-09 Thread Carl Banks
hat you can avoid ever having to use the "is" operator, be my guest. As for me, I do program in the sort of areas where identity testing is common, and I don't care to define ids just to test for identity alone, so for me "is" is useful. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem--Extending the behavior of an upstream package

2009-03-10 Thread Carl Banks
On Mar 10, 9:33 pm, a...@pythoncraft.com (Aahz) wrote: > In article > <60848752-2c3f-4512-bf61-0bc11c919...@i20g2000prf.googlegroups.com>, > Carl Banks   wrote: > > > > >The problem comes when a different part of the upstream package also > >subclasses or creat

Re: pickle.load() extremely slow performance

2009-03-20 Thread Carl Banks
f = open('dirlisting.dat','rb') try: f.seek(0,2) size = f.tell() f.seek(0,0) m = mmap.mmap(f.fileno(),size,access=mmap.ACCESS_READ) try: dir_listing = pickle.loads(m) finally: m.close() finally: f.close() Pickling the output left as an exercise. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Relative Imports, why the hell is it so hard?

2009-03-24 Thread Carl Banks
d at least it has the blessing of the language designers so it won't unceremoniously break at some point. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Relative Imports, why the hell is it so hard?

2009-03-25 Thread Carl Banks
On Mar 25, 1:07 am, Kay Schluehr wrote: > On 25 Mrz., 05:56, Carl Banks wrote: > > > > > > > On Mar 24, 8:32 pm, Istvan Albert wrote: > > > > On Mar 24, 9:35 pm, Maxim Khitrov wrote: > > > > > Works perfectly fine with relative imports. >

Re: What way is the best to check an empty list?

2009-03-25 Thread Carl Banks
27;t need to do something else in the case of no items. But in that case you have no choice but to iterate and see if any items are produced. There are some iterables for which no if-test at all works. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: What way is the best to check an empty list?

2009-03-25 Thread Carl Banks
of generators, but I now find that > those will have boolean value 'true' whether or not they have > something to generate, so they will go wrong under either method. Yes, but notice that one of them goes wrong by raising an exception, whereas the other goes wrong by failing silently

Re: What way is the best to check an empty list?

2009-03-25 Thread Carl Banks
A) == 0" test and no other. This is to allow interaction with numpy, which doesn't work with the "if not A" test. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Any way to use a range as a key in a dictionary?

2009-03-26 Thread Carl Banks
;w", 4363: "n", 8953: "k" } d.get(1) -> "s" d.get(56) -> "w" d.get(10) -> None d.get(10,"x") -> "x" Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Any way to use a range as a key in a dictionary?

2009-03-27 Thread Carl Banks
that the OP asked about what to do with the the other 65526 values suggests that he only wanted to use intervals to fill in the gaps between meaningful values (thus having complete coverage over the 16-bit integer range). An interval tree would not be a good approach for that situation. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: please include python26_d.lib in the installer

2009-03-27 Thread Carl Banks
e macro to indicate debugging mode. So I think you raise a valid point that this can be problematic. Perhaps something like _Py_DEBUG should be used instead. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Any way to use a range as a key in a dictionary?

2009-03-27 Thread Carl Banks
On Mar 27, 11:20 am, Paul Rubin <http://phr...@nospam.invalid> wrote: > Carl Banks writes: > > >      if x in theDict: > > >           print x, v > > > Where does v come from? > > Oops, pasted from original.  Meant of course "print x, theDict[x]"

Re: Any way to use a range as a key in a dictionary?

2009-03-27 Thread Carl Banks
On Mar 27, 1:06 pm, Duncan Booth wrote: > Carl Banks wrote: > > On Mar 27, 11:20 am, Paul Rubin <http://phr...@nospam.invalid> wrote: > >> Carl Banks writes: > >> > >      if x in theDict: > >> > >           print x, v > > >> &

Re: please include python26_d.lib in the installer

2009-03-31 Thread Carl Banks
On Mar 31, 12:50 pm, Compie wrote: > On 27 mrt, 17:01, Carl Banks wrote: > > > OTOH, it's possible that SWIG and Python just happen to use the same > > macro to indicate debugging mode.  So I think you raise a valid point > > that this can be problematic.  Perhaps so

Re: Relative Imports, why the hell is it so hard?

2009-03-31 Thread Carl Banks
to make sweeping negative judgments once you have the answers, though.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Relative Imports, why the hell is it so hard?

2009-03-31 Thread Carl Banks
On Mar 31, 6:39 pm, Kay Schluehr wrote: > On 1 Apr., 00:38, Carl Banks wrote: > > > On Mar 31, 12:08 pm, Kay Schluehr wrote: > > > > > And your proposal is? > > > > I have still more questions than answers. > > > That's obvious. >

Re: Python Goes Mercurial

2009-04-01 Thread Carl Banks
n-dev was so severe GvR backtracked on his decision. Trying to appease a least common denominator, he changed his mind and Python is going with SCCS instead. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: python for loop

2009-04-01 Thread Carl Banks
ulled when interfacing C to Fortran. Python is zero-based, and you are going to have a much better experience if you don't fight it. I assure you that it is really not that hard to cope with indices being off by one from what you have written down. Really. I have to interface two lang

Re: python for loop

2009-04-01 Thread Carl Banks
On Apr 1, 7:08 am, Lada Kugis wrote: > On Wed, 1 Apr 2009 00:40:17 -0700 (PDT), Carl Banks > > > > > > wrote: > > >Lada, > > >I am also an engineer, and I can tell your idea of intuitive is not > >universal, even among engineers.  I certainly do not

Re: A design problem I met again and again.

2009-04-01 Thread Carl Banks
em calls, but never mind that. Ordinarily a bunch of functions operating on common data should be organized as a class.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Beazley on Generators

2009-04-01 Thread Carl Banks
ty to run coroutines in Matlab would make my working life a lot easier right now. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: python for loop

2009-04-01 Thread Carl Banks
#x27;radd', 'rmul': >         exec "def __%s__(*r): return List1(list.__%s__(*r))" % (op, op) > > l1 = List1(range(10)) > l2 = List1("Python rules") > > I'll let you play with l1 and l2. If I were your boss and you ever pulled something like this, your ass would be so fired. This is unforgiveable, not only changing the indexing semantics of Python (because a user would have NO CLUE that something underlying has been changed, and thus it should never be done), but also for the needless abuse of exec. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: python for loop

2009-04-01 Thread Carl Banks
ty of zero actually mean? (That's a sincere question.) I think people were being facetious. To me the first item in the list is x[0]--ordinal does not match cardinal. However, I don't use ordinals much when talking about list items; I'll say item 2, not third item. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

<    3   4   5   6   7   8   9   10   11   12   >