wxpython-OGL fails to render objects with Python-3

2020-09-17 Thread Frank Miles
I have a substantial wxpython-based application that I'm trying to port from python-2 to -3. Almost everything is working properly, except for a few small but important sections that use the OGL library. That executes without any exceptions, but the objects created within the diagram/canvas

Re: python3.7 installation failing - so why?

2019-02-22 Thread Frank Miles
On Sat, 23 Feb 2019 14:56:03 +1100, Chris Angelico wrote: > On Sat, Feb 23, 2019 at 2:51 PM Frank Miles > wrote: >> >> I have a Debian/Linux machine that I just upgraded to the newer >> "testing" >> distribution. I'd done that earlier to another m

python3.7 installation failing - so why?

2019-02-22 Thread Frank Miles
I have a Debian/Linux machine that I just upgraded to the newer "testing" distribution. I'd done that earlier to another machine and all went well. With the latest machine, python2 is OK but python3 can barely run at all. For example: $ python3 Python 3.7.2+ (default, Feb 2 2019, 14:31:48)

Re: closing image automatically in for loop , python

2017-04-12 Thread Frank Miles
On Wed, 12 Apr 2017 04:18:45 -0700, Masoud Afshari wrote: > filename ="Ex_resample" +'_sdf_'+ str(n)+'.dat' > with open(filename, 'rb') as f: #read binary file data = np.fromfile(f, > dtype='float64', count=nx*ny) #float64 for Double precision float numbers > Ex = np.reshape(data, [ny, nx], ord

Re: Data exchange between python script and bash script

2017-04-04 Thread Frank Miles
On Tue, 04 Apr 2017 08:01:42 -0700, venkatachalam.19 wrote: > Hello All, > > I am writing a python code for processing a data obtained from a sensor. The > data from sensor is obtained by executing a python script. The data obtained > should be further given to another python module where the r

Re: Multiprocessing queue in py2.7

2017-03-28 Thread Frank Miles
On Tue, 28 Mar 2017 15:38:38 -0400, Terry Reedy wrote: > On 3/28/2017 2:51 PM, Frank Miles wrote: >> I tried running a bit of example code from the py2.7 docs >> (16.6.1.2. Exchanging objects between processes) >> only to have it fail. The code is simply: >

Multiprocessing queue in py2.7

2017-03-28 Thread Frank Miles
I tried running a bit of example code from the py2.7 docs (16.6.1.2. Exchanging objects between processes) only to have it fail. The code is simply: # from multiprocessing import Process, Queue def f(q): q.put([42, None, 'hello']) if __name__ == '__main__': q = Queue()

Re: Does anyone here use wxGlade on Linux?

2016-02-11 Thread Frank Miles
On Thu, 11 Feb 2016 14:29:04 +, cl wrote: > I am trying out wxGlade on Linux, version 0.7.1 of wxGlade on xubuntu > 15.10. > > I have already written something using wxPython directly so I have the > basics (of my Python skills and the environment) OK I think. > > I am having a lot of troubl

Re: Which GUI?

2015-07-24 Thread Frank Miles
On Fri, 24 Jul 2015 19:31:36 +0100, Paulo da Silva wrote: [snip] > Which technology is better? > matplotlib? > tkinter? > wxwidgets? > qt? Sadly - I don't think wxpython has been ported to python3 yet. -- https://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way to iterate through multidimensional space?

2014-08-05 Thread Frank Miles
On Tue, 05 Aug 2014 20:06:05 +, Frank Miles wrote: > I need to evaluate a complicated function over a multidimensional space > as part of an optimization problem. This is a somewhat general problem > in which the number of dimensions and the function being evaluated can > vary

Pythonic way to iterate through multidimensional space?

2014-08-05 Thread Frank Miles
I need to evaluate a complicated function over a multidimensional space as part of an optimization problem. This is a somewhat general problem in which the number of dimensions and the function being evaluated can vary from problem to problem. I've got a working version (with loads of conditional

Re: wx (not responding)

2014-01-14 Thread Frank Miles
On Tue, 14 Jan 2014 07:26:10 -0800, ngangsia akumbo wrote: > When i run this code on my pc it actually runs but signals that the app is > not responding. [snip most of the code]- > def main(): > ex = wx.App() > Example(None) > ex.Mainloop() > > > if __name__ == "__main__": > m

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-13 Thread Frank Miles
On Thu, 12 Dec 2013 16:18:22 -0500, Larry Martell wrote: > On Thu, Dec 12, 2013 at 11:51 AM, bob gailer wrote: >> On 12/11/2013 9:07 PM, Larry Martell wrote: >> >>> Nope. Long before that I was working on computers that didn't boot when >>> you powered them up, You had to manually key in a bootst

Re: Python Front-end to GCC

2013-10-22 Thread Frank Miles
On Tue, 22 Oct 2013 16:40:32 +, Steven D'Aprano wrote: > On Tue, 22 Oct 2013 15:39:42 +, Grant Edwards wrote: > >>> No, I was thinking of an array. Arrays aren't automatically >>> initialised in C. >> >> If they are static or global, then _yes_they_are_. They are zeroed. > > Not that I

Re: PDF generator decision

2013-05-14 Thread Frank Miles
On Tue, 14 May 2013 08:05:53 -0700, Christian Jurk wrote: > Hi folks, > > This questions may be asked several times already, but the development > of relevant software continues day-for-day. For some time now I've been > using xhtml2pdf [1] to generate PDF documents from HTML templates (which > a

Re: Urgent:Serial Port Read/Write

2013-05-09 Thread Frank Miles
On Thu, 09 May 2013 23:35:53 +0800, chandan kumar wrote: > Hi all,I'm new to python and facing issue using serial in python.I'm > facing the below error >     ser.write(port,command)NameError: global name 'ser' is not defined > Please find the attached script and let me know whats wrong in my scri

Re: Reinforced Concrete: Mechanics and Design (5th Ed., James G. MacGregor & James K. Wight)

2013-01-18 Thread Robert Miles
On 1/18/2013 7:32 PM, Roy Smith wrote: Can whoever manages the mailing list block this bozo? In article , kalvinmanual1 wrote: I have solutions manuals to all problems and exercises in these textbooks. To get one in an electronic format contact me at: kalvinmanual(at)gmail(dot)com and let m

Re: Spam source (Re: Horror Horror Horror!!!!!)

2012-11-22 Thread Robert Miles
On Sunday, November 18, 2012 8:18:53 PM UTC-6, Mark Lawrence wrote: > On 18/11/2012 19:31, Terry Reedy wrote: > > > The question was raised as to how much spam comes from googlegroups. > > I don't know the answer but I take the greatest pleasure in hurtling > onto the dread googlegroups and gman

Re: Spam source (Re: Horror Horror Horror!!!!!)

2012-11-18 Thread Robert Miles
On Sunday, November 18, 2012 1:35:00 PM UTC-6, Terry Reedy wrote: > The question was raised as to how much spam comes from googlegroups. > > Not all, but more that half, I believe. This one does. > > > > From: MoneyMaker > > ... > > Message-ID: <2d2a0b98-c587-4459-9489-680b1ddc4...@googlegro

Re: Unpaking Tuple

2012-11-18 Thread Robert Miles
On 10/9/2012 1:07 AM, Bob Martin wrote: in 682592 20121008 232126 "Prasad, Ramit" wrote: Thomas Bach wrote:=0D=0A> Hi there,=0D=0A> =0D=0A> On Sat, Oct 06, 2012 at = 03:08:38PM +, Steven D'Aprano wrote:=0D=0A> >=0D=0A> > my_tuple =3D my_= tuple[:4]=0D=0A> > a,b,c,d =3D my_tuple if len(my_tu

Re: Python garbage collector/memory manager behaving strangely

2012-10-31 Thread Robert Miles
On 9/16/2012 9:12 PM, Dave Angel wrote: On 09/16/2012 09:07 PM, Jadhav, Alok wrote: Hi Everyone, I have a simple program which reads a large file containing few million rows, parses each row (`numpy array`) and converts into an array of doubles (`python array`) and later writes into an `hdf5

Re: datetime issue

2012-10-31 Thread Robert Miles
On 10/31/2012 4:38 PM, Mark Lawrence wrote: On 31/10/2012 19:35, ru...@yahoo.com wrote: On 10/31/2012 09:11 AM, Grant Edwards wrote:> On 2012-09-16, ?? wrote:. "Broken"? Yes. But so is every piece of software in one way or another. Thunderbird is one of the most perpetually bug

Re: datetime issue

2012-10-31 Thread Robert Miles
On 10/31/2012 2:35 PM, ru...@yahoo.com wrote: On 10/31/2012 09:11 AM, Grant Edwards wrote:> On 2012-09-16, ?? wrote: Iam positng via google groups using chrome, thats all i know. Learn something else. Google Groups is seriously and permanently broken, and all posts from Googl

Re: Obnoxious postings from Google Groups

2012-10-30 Thread Robert Miles
On 9/16/2012 8:14 PM, alex23 wrote: On Sep 17, 10:55 am, Roy Smith wrote: They didn't buy the service. They bought the data. Well, they really bought both, but the data is all they wanted. I thought they'd taken most of the historical data offline now too? Some of it, but they still had m

Re: Obnoxious postings from Google Groups

2012-10-30 Thread Robert Miles
On 9/16/2012 10:44 AM, pandora.ko...@gmail.com wrote: Whaen i tried to post just now by hitting sumbit, google groups told me that the following addresssed has benn found in this thread! i guess is used them all to notify everything! cdf072b2-7359-4417-b1e4-d984e4317...@googlegroups.com mailma

Re: Obnoxious postings from Google Groups

2012-10-30 Thread Robert Miles
ple levels of quoting. The incompatibility tends to insert a blank line after every line. With multiple levels of quoting, this gives blank line groups that often roughly double in size for every level of quoting. Robert Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Obnoxious postings from Google Groups

2012-09-20 Thread Robert Miles
, not something you have much control over, except to stop using Google Groups. Could this mean that Google wants all the spam posted through Google Groups to look obnoxious to the rest of Usenet that the spammers will go elsewhere? Robert Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: Text editors

2012-08-30 Thread Robert Miles
uperminis. I'm not sure whether I still could, though. Robert Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Dumping all the sql statements as backup

2012-08-29 Thread Robert Miles
On 7/25/2012 8:56 AM, andrea crotti wrote: I have some long running processes that do very long simulations which at the end need to write things on a database. At the moment sometimes there are network problems and we end up with half the data on the database. The half-data problem is probably

Re: catch UnicodeDecodeError

2012-08-29 Thread Robert Miles
On 7/26/2012 5:51 AM, Jaroslav Dobrek wrote: And the cool thing is: you can! :) In Python 2.6 and later, the new Py3 open() function is a bit more hidden, but it's still available: from io import open filename = "somefile.txt" try: with open(filename, encoding="utf-8")

Re: the meaning of r?.......ï¾

2012-08-28 Thread Robert Miles
On 7/23/2012 1:10 PM, Dennis Lee Bieber wrote: On Mon, 23 Jul 2012 16:42:51 +0200, Henrik Faber declaimed the following in gmane.comp.python.general: If that was written by my coworkers, I'd strangle them. My first real assignment, 31 years ago, was porting an application to CDC MP-

Re: Encapsulation, inheritance and polymorphism

2012-08-18 Thread Robert Miles
On 7/23/2012 11:18 AM, Albert van der Horst wrote: In article <5006b48a$0$29978$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: Even with a break, why bother continuing through the body of the function when you already have the result? When your calculation is done, it's done, just

Re: lambda in list comprehension acting funny

2012-08-15 Thread Robert Miles
n has a version of Python available, in case you're interested. Robert Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Interview Questions

2012-08-14 Thread Robert Miles
On 7/10/2012 1:08 PM, Demian Brecht wrote: I also judge candidates on their beards (http://www.wired.com/wiredenterprise/2012/06/beard-gallery/). If the beard's awesome enough, no questions needed. They're pro. You should hire me quickly, then, since I have a beard, already turning partly gr

Re: Create directories and modify files with Python

2012-06-08 Thread Robert Miles
ery slowly - as in 5 minutes after I tell it to post. Robert Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Some posts do not show up in Google Groups

2012-06-08 Thread Robert Miles
they get that contains any HTML. This may be because Google Groups often adds HTML even if you don't ask for it, and those servers want to avoid the poor signal to noise ratio from Google Groups. Robert Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Some posts do not show up in Google Groups

2012-06-08 Thread Robert Miles
s are moving toward newsgroups where no one reports the spam. Robert Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Half-baked idea: list comprehensions with "while"

2012-04-27 Thread Miles Rout
On 27/04/2012 5:57 a.m., Kiuhnm wrote: On 4/26/2012 19:48, Paul Rubin wrote: Roy Smith writes: x = [a for a in iterable while a] from itertools import takewhile x = takewhile(bool, a) I see that as a 'temporary' solution, otherwise we wouldn't need 'if' inside of list comprehensions either

Re: Strange __import__() behavior

2012-04-26 Thread Frank Miles
On Wed, 25 Apr 2012 23:03:36 +0200, Kiuhnm wrote: > On 4/25/2012 22:05, Frank Miles wrote: >> I have an exceedingly simple function that does a "named import". It >> works perfectly for one file "r"- and fails for the second "x". >> >> If

Strange __import__() behavior

2012-04-25 Thread Frank Miles
I have an exceedingly simple function that does a "named import". It works perfectly for one file "r"- and fails for the second "x". If I reverse the order of being called, it is still "x" that fails, and "r" still succeeds. os.access() always reports that the file is readable (i.e. "true") If I

Re: Complex sort on big files

2011-08-02 Thread Alistair Miles
ght you could apply the complex sort to each chunk before >> writing it to disk, so each chunk was completely sorted, but then the >> heapq.merge wouldn't work properly, because afaik you can only give it >> one key. >> >> Any help much appreciated (I may well be missi

Re: weak reference to bound method

2009-10-02 Thread Miles Kaufmann
f obj is None: return None return types.MethodType(self.im_func, obj, self.im_class) # could alternately act like a callableproxy -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Timestamps for TCP packets?

2009-10-02 Thread Miles Kaufmann
ied it? I don't know of any reason that using sockets and doing a packet capture would interfere with each other. What are you trying to accomplish with the packet sniffing, though? -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Are min() and max() thread-safe?

2009-09-17 Thread Miles Kaufmann
On Sep 16, 2009, at 10:39 PM, Steven D'Aprano wrote: On Wed, 16 Sep 2009 22:08:40 -0700, Miles Kaufmann wrote: On Sep 16, 2009, at 9:33 PM, Steven D'Aprano wrote: I have two threads, one running min() and the other running max() over the same list. I'm getting some mysteriou

Re: (A Possible Solution) Re: preferred way to set encoding for print

2009-09-16 Thread Miles Kaufmann
, encoding=sys.stdout.encoding, errors='xmlcharrefreplace') http://mail.python.org/pipermail/python-list/2009-August/725100.html -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Are min() and max() thread-safe?

2009-09-16 Thread Miles Kaufmann
Python interpreter, but not necessarily to your application). But a threaded approach is somewhat silly, since the GIL ensures that they *won't* walk over the same list simultaneously (two separate lists, for that matter). -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: list as an instance attribute

2009-09-14 Thread Miles Kaufmann
not classes at all; they couldn't be instantiated directly (from Python code), so you had to call the str() function to create an object of type "string". I think there may have been some discussion of renaming the built-ins to match PEP 8 for Python 3, but if so I

Re: Why indentation is use to denote block of code?

2009-09-14 Thread Miles Kaufmann
comments that act as block closers to your code, and can then use those comments to restore the correct indentation to a mangled version. (Most forums offer some sort of whitespace-preserving [code] tag, though; and pindent is relatively old, and apparently not well maintained (no support

Re: Variables vs attributes

2009-09-12 Thread Miles Kaufmann
Teaching/Lectures/guido-intro-2.pdf We're blessed with a variety of object-oriented almost-synonyms to choose from, some of which are more Pythonic than others. But I don't think it's worth "correcting" everyone who uses the phrase "class variable", especially when their use of it causes no confusion. -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Where regexs listed for Python language's tokenizer/lexer?

2009-09-11 Thread Miles Kaufmann
The Python tokenization process is described here: http://docs.python.org/reference/lexical_analysis.html The tokenizer can't be expressed in terms of regular expressions, because it's non-regular (thanks to things like matching nested braces and keeping track of the indentation level

Re: Why does this group have so much spam?

2009-08-30 Thread Miles Kaufmann
wing it via the python-list@ mailing list. The list owners do a great job of keeping the level of spam at a minimum, though there are occasional false positives (like your post, apparently, since I'm only seeing the replies). -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help with Python scoping rules

2009-08-27 Thread Miles Kaufmann
On Aug 27, 2009, at 4:49 PM, kj wrote: Miles Kaufmann writes: Guido's design justifications: http://mail.python.org/pipermail/python-dev/2000-November/010598.html Ah! Clarity! Thanks! How did you find this? Did you know of this post already? Or is there some special way to s

Re: Need help with Python scoping rules

2009-08-27 Thread Miles Kaufmann
ace visible to nested scopes at all. But it's better than the alternative of trying to unify the class suite namespace and the class namespace, which would be a nightmare of special cases (adding/deleting class attributes? descriptors? __getattr__?) and require an implementation completel

Re: Object Reference question

2009-08-20 Thread Miles Kaufmann
the object reference name (a,b,c,d) from dk to use as input for a file. It sounds like you should either be storing that name as an attribute of the object, or using a dictionary ({'a': a, 'b': b, ...}). -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Waiting for a subprocess to exit

2009-08-20 Thread Miles Kaufmann
s 2 installer debacle[1]). Leaving shell=False makes scripts more secure and robust; besides, when I'm putting together a command and its arguments, it's as convenient to build a list (['mycmd', 'myarg']) as it is a string (if not more so). -Miles [1]: http://

Re: Skipping a superclass

2009-08-02 Thread Miles Kaufmann
but is this safe to do? Or are there strange side-effects I haven't seen yet? In a diamond-inheritance situation, you may end up skipping methods besides just B.method(). -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: python 3 and stringio.seek

2009-07-29 Thread Miles Kaufmann
implementation. If what you actually want is a stream of bytes, use BytesIO, which may be seeked (sought?) however you please. I'm basing this all on my reading of the Python source (and svn history), since it doesn't seem to be documented, so take it with a grain of salt. -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: trouble with minidom

2009-07-22 Thread Miles Kaufmann
On Jul 21, 2009, at 8:08 PM, Ronn Ross wrote: Hello I'm trying to read an xml file using minidome. The xml looks like: myProj /here/ My code looks like so: from xml.dom.minidom import parse dom = parse("myfile.xml") for node in dom.getElementsByTagName("project'): p

Re: Why not enforce four space indentations in version 3.x?

2009-07-15 Thread Miles Kaufmann
On Jul 15, 2009, at 4:26 PM, David Bolen wrote: Miles Kaufmann writes: On Jul 14, 2009, at 5:06 PM, David Bolen wrote: Are you sure? It seems to restrict them in the same block, but not in the entire file. At least I was able to use both space and tab indented blocks in the same file

Re: Why not enforce four space indentations in version 3.x?

2009-07-15 Thread Miles Kaufmann
them all), which previously would have been allowed, is now an error. -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: python first assignment of a global variable

2009-07-15 Thread Miles Kaufmann
generates bytecode such that all references to that name within the function will be looked up in the local scope only, including those before the assignment statement. -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: missing 'xor' Boolean operator

2009-07-15 Thread Miles Kaufmann
... example it doesn't short-circuit. No; like 'A or B', 'not (not A and not B)' does in fact short-circuit if A is True. (The 'and' condition does not have to evaluate the right operand when 'not A' is False.) -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: missing 'xor' Boolean operator

2009-07-15 Thread Miles Kaufmann
[snip] Did I make twice the same obvious error ? Try again with: l = [('foo','bar'), ('foo', ''), ('', 'bar'), ('', '')] -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: missing 'xor' Boolean operator

2009-07-14 Thread Miles Kaufmann
eally see the utility. def xor2(a, b): return (not b and a) or (not a and b) def xor(*args): return reduce(xor2, args) You may also find this question interesting: http://stackoverflow.com/questions/432842/ -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: How to keep a function as a generator function when the yield operator is moved into its sub-functions??

2009-07-14 Thread Miles Kaufmann
def func1(): ... while cond: ... for x in commoncode(): yield x ... See also: - PEP 380: http://www.python.org/dev/peps/pep-0380/ - Stackless: http://www.stackless.com/ -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Catching control-C

2009-07-09 Thread Miles Kaufmann
ameEx(), those opcodes that don't end in goto fast_next_opcode are ticks. Please correct me if _I'm_ wrong! :) -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: function local namespace question

2009-07-08 Thread Miles Kaufmann
7;m aware of to directly hook into function namespace access and manipulation. -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Passing parameters for a C program in Linux.

2009-06-30 Thread Miles Kaufmann
On Jun 30, 2009, at 6:46 AM, venutaurus...@gmail.com wrote: I have to write an automted script which will test my c program. That program when run will ask for the commands. Keep in mind that, if your test script checks the program's output before giving it input, you can run into pro

Re: No trees in the stdlib?

2009-06-27 Thread Miles Kaufmann
are others out there, but it's usually the first recommended), rather than having to search out and evaluate a dozen different ones. -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression Non Capturing Grouping Does Not Work.

2009-06-27 Thread Miles Kaufmann
to work. ... Notice that you are calling .group() on the match object instead of .groups(). Without any arguments, .group() is equivalent to .group(0), which means "return the entire matching string." http://docs.python.org/library/re.html#re.MatchObject.group -Mile

Re: No trees in the stdlib?

2009-06-25 Thread Miles Kaufmann
pretty much the bisect module in a nutshell. It manipulates a sorted list using binary search. With O(n) insertions and removals, though. A decent self-balancing binary tree will generally do those in O(log n). -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib2.urlopen issue

2009-06-24 Thread Miles Kaufmann
me(socket.gethostname()) If it throws a similar exception (Name or service not known), the root problem may be a misconfiguration in your /etc/hosts or /etc/ resolv.conf files. -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: [Mac] file copy

2009-06-23 Thread Miles Kaufmann
-test: on dirs ... ok (Important) Verifying: fifo ... ok Verifying: devices ... ok Verifying: combo-tests ... Sub-test: xattrs + rsrc forks ... ok Sub-test: lots of metadata ... ok -Miles -- http://mail.python.org/mailman/listinfo/p

Re: Idioms and Anti-Idioms Question

2009-06-22 Thread Miles Kaufmann
Perhaps, along with one of those gotchas, a mix of tabs and spaces are used such that the second line only _appears_ to have a different level of indentation? ;) -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: class or instance method

2009-06-21 Thread Miles Kaufmann
MethodType(self._func, cls if obj is None else obj, cls) -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: generator expression works in shell, NameError in script

2009-06-21 Thread Miles Kaufmann
for b in _0: yield (b, b) baaz = list(_gen(iter(bar)) # PEP 227: "the name bindings that occur in the class block # are not visible to enclosed functions" class Foo(object): bar = ['a', 'b', 'c'] def _gen(_0): for b in _0: yield (bar.index(b), b) baaz = list(_gen(iter(bar)) -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib2 content-type headers

2009-06-21 Thread Miles Kaufmann
ot;? Those headers are added (by AbstractHTTPHandler.do_request_) only if they are missing. -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Miles Kaufmann
n a random floating point number N such that a <= N <= b for a <= b That's wrong. Where did you get it? http://docs.python.org/library/random.html -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Function/method returning list of chars in string?

2009-06-09 Thread Miles Kaufmann
On Jun 9, 2009, at 6:05 AM, Diez B. Roggisch wrote: Also as list-comps are going away and are replaced by list() Where did you hear that? -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Winter Madness - Passing Python objects as Strings

2009-06-06 Thread Miles Kaufmann
you the source. Sounds like di(), which can be written: import _ctypes di = _ctypes.PyObj_FromPtr def can(o): return str(id(o)) def uncan(s): return di(int(s)) http://www.friday.com/bbum/2007/08/24/python-di/ -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: How to check all elements of a list are same or different

2009-04-15 Thread Miles
crowd: from functools import partial from operator import eq from itertools import imap def all_same(iterable): it = iter(iterable) return all(imap(partial(eq, it.next()), it)) -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: video capture in Python ? (Tim Roberts)

2009-04-12 Thread Miles Lee
Hi, You could try the python wrapper for OpenCV, here is the link: http://code.google.com/p/ctypes-opencv/ Regards Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding a Badge to an Icon in Mac OS X

2009-04-10 Thread Miles
gure out how it is done! I believe those programs are able to do so because they are Finder plugins--it's not something that a separate program could do. This isn't really a Python question, though; you'd probably have better luck finding answers on a OS X-related list. -Mile

Re: Unsupported operand types in if/else list comprehension

2009-04-10 Thread Miles
nsert the parameters into the SQL query for you; it will look something like this (though the exact details will vary depending on what module you're using): cursor.execute('INSERT INTO my_table VALUES (?, ?, ?)', ['test',1,'two']) -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does Python show the whole array?

2009-04-09 Thread Miles
Clearly, any comparison with a boolean literal should be illegal. ;) -Miles P.S. ... really, though. -- http://mail.python.org/mailman/listinfo/python-list

Re: is there a rwlock implementation in python library?

2009-04-08 Thread Miles
/ http://code.activestate.com/recipes/465156/ -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: more fun with iterators (mux, demux)

2009-04-08 Thread Miles
then skips over, whereas your version places items only into the deque of the generator that needs it. However, for small n, the tee-based solution has the advantage of having most of the work done in C instead of in Python generator functions; in my limited benchmarking, the point where your vers

Re: more fun with iterators (mux, demux)

2009-04-06 Thread Miles
  yield i.next() > > > This is like a zip, and can be re-written using itertools.izip. > > def mux(*iterables): >    for i in itertools.izip(*iterables): >        for item in i: >            yield item In Python 2.6, you could also do this: def mux(*iterables): return iterto

Re: more fun with iterators (mux, demux)

2009-04-06 Thread Miles
mped.  The demux should return a tuple of N generators. from itertools import islice, tee def demux(iterable, n): return tuple(islice(it, i, None, n) for (i, it) in enumerate(tee(iterable, n))) -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Tab completion

2009-04-05 Thread Miles
' else: return None return rlcompleter.Completer.complete(self, text, state) readline.set_completer(TabCompleter().complete) -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Generators/iterators, Pythonicity, and primes

2009-04-04 Thread Miles
eld n break elif n % p == 0: break else: raise Exception("Shouldn't have run out of primes!") When generating the first 1000 primes, this version's approximately 20 times faster; for the first 10,000 primes, ~80x (but

Re: Python print and types selection

2009-03-27 Thread Miles
t_hex does the long conversion) > -- redefine __str__ and use %s Or make your class a subclass of long. -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: dict view to list

2009-03-27 Thread Miles
vert to a flat sequence but rather a list tree. I don't see the special case for dict views, at all. -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntax error when importing a file which starts with a number

2009-03-23 Thread Miles
ry/functions.html#__import__ But a far better solution is to fix your naming scheme—it's completely illogical to have a Python module naming scheme where the names aren't valid identifiers. -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I do bit operation on python float value

2009-03-23 Thread Miles
_to_float(x): ... return cast(ctypes.c_uint64(x), ctypes.c_double) ... >>> float_to_int(5) 4617315517961601024 >>> bin(float_to_int(5)) '0b1010100' >>> int_to_float(float_to_int(5) & float_to_int(10)) 2.5 -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: How evil is this use of sys.getrefcount?

2009-03-20 Thread Miles
self._object) # Define your own methods to wrap those of the object, # or maybe define __getattr__ -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this type of forward referencing possible?

2009-03-15 Thread Miles
d to point out that A and B likely both inherit from db.Model). The Django solution is to allow forward references in the form of strings of class names (e.g., ReferenceType('B')). It doesn't look like App Engine has a solution for this situation: http://code.google.com/p/goo

Re: don't understand behaviour of recursive structure

2009-03-14 Thread Miles
a FAQ: http://effbot.org/zone/default-values.htm http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re:

2009-03-13 Thread Miles
On Fri, Mar 13, 2009 at 3:13 PM, Miles wrote: > [snip] Sorry, didn't see the original thread on this. -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re:

2009-03-13 Thread Miles
2), (2, 4)] b = [2, 4, 1, 3] bdict = dict((v,k) for (k,v) in enumerate(b)) a.sort(key=lambda k: bdict[k[1]]) If you don't want to build the intermediary dict, a less efficient version that runs in O(n^2): a.sort(key=lambda k: b.index(k[1])) Which is mostly similar to John's solutio

  1   2   >