OSCON 2015 CfP DEADLINE Feb 2
OSCON (O'Reilly Open Source Conference) will be held in Portland, OR July 20-24. The Call for Proposals is now open with a DEADLINE of Monday February 2: http://www.oscon.com/open-source-2015/public/cfp/360 O'Reilly has completely reorganized OSCON. Instead of focusing on individual technologies, there are a bunch of themes: * Identity - An emerging and nuanced facet in the digital age and an exciting cross-functional track at OSCON 2015. * Security - We'll explore security from top to bottom, offering frameworks and libraries, strategies for testing, and field reports of both security failure and success. * Privacy - Computers remember our interactions at a level of detail the physical world never has. Do we want to be remembered, and for how long? * Performance - From compilation and interpreter time to DOM manipulation, browser responsiveness, and network latency, we'll explore performance in all its facets. * Mobility - We'll look at what it means to have a successful mobile game plan, from wearables to native apps. * People - Making projects work requires communications, collaboration, and respect; we'll look at the ways a new generation of tools and approaches can help you work. * Architecture - Software architecture is a massive multidisciplinary subject, covering many roles and responsibilities--and a key position in the success of any business. * Scale - You've created a great web interface that is well designed, secure, and works well in a beta with 100 consumers, but how about 10,000, 1,000,000, or more? * Storage - Find your way among the myriad choices for storing data and optimizing your systems for stability, distribution, convenience, and performance. * Teaching - You want to share your best practices, projects, and tools with the world, but how do you go about sharing this knowledge? We'll examine learning theory and methods of teaching. * Design - It's critical for success; learn how to incorporate design best practices from the beginning of your project rather and all the way through. * Solve - Harness the power of math to manipulate, secure, and create data. * Data - Let's tackle data's continued, growing influence over the entire business world and how you can make it work for you. * Foundations - A strong foundation in computational thinking, problem solving, and programming best practices makes for a successful programmer. See the CfP page for more details. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The joy of coding Python should be in seeing short, concise, readable classes that express a lot of action in a small amount of clear code -- not in reams of trivial code that bores the reader to death. --GvR -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
OSCON 2013 registration is open (7/22-26)
OSCON (O'Reilly Open Source Conference) will be held in Portland, OR July 22-26. This year we're celebrating the fifteenth anniversary! Registration is now open: http://www.oscon.com/oscon2013 http://www.oscon.com/oscon2013/public/schedule/grid Hope to see you there! -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The joy of coding Python should be in seeing short, concise, readable classes that express a lot of action in a small amount of clear code -- not in reams of trivial code that bores the reader to death. --GvR -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Final reminder: OSCON Call for Proposals (deadline 2/4)
DEADLINE Monday February 4 OSCON (O'Reilly Open Source Convention), the premier Open Source gathering, will be held in Portland, OR July 22-26. We're looking for people to deliver tutorials and shorter presentations. http://www.oscon.com/oscon2013 http://www.oscon.com/oscon2013/public/cfp/251 Hope to see you there! -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The joy of coding Python should be in seeing short, concise, readable classes that express a lot of action in a small amount of clear code -- not in reams of trivial code that bores the reader to death. --GvR -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
OSCON Call for Proposals (deadline 2/4)
DEADLINE Monday February 4 OSCON (O'Reilly Open Source Convention), the premier Open Source gathering, will be held in Portland, OR July 22-26. We're looking for people to deliver tutorials and shorter presentations. http://www.oscon.com/oscon2013 http://www.oscon.com/oscon2013/public/cfp/251 Hope to see you there! -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The joy of coding Python should be in seeing short, concise, readable classes that express a lot of action in a small amount of clear code -- not in reams of trivial code that bores the reader to death. --GvR -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: debugging in eclipse
In article roy-f45720.08540815112...@news.panix.com, Roy Smith r...@panix.com wrote: In article mailman.3714.1352986928.27098.python-l...@python.org, Dave Angel d...@davea.name wrote: I'd also add a print statement, just to assure yourself that it's running. My trick to make sure something is running is to add assert 0. ``1/0`` is shorter. ;-) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ LL YR VWL R BLNG T S -- www.nancybuttons.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Detect file is locked - windows
In article mailman.3676.1352887368.27098.python-l...@python.org, Tim Golden m...@timgolden.me.uk wrote: On 14/11/2012 00:33, Ali Akhavan wrote: I am trying to open a file in 'w' mode open('file', 'wb'). open() will throw with IOError with errno 13 if the file is locked by another application or if user does not have permission to open/write to the file. How can I distinguish these two cases ? Namely, if some application has the file open or not. Can I ask what you expect to do differently in each of those cases? In other words, if you can't access the file, you can't access it. (Not to dismiss your question; I just wonder how you're going to handle the different cases) Real-life use case for user-requested operation: if no permission, skip the file permanently (until it changes, at least); if locked, place in retry loop. And in response to your other post, you absolutely want to use CreateFileW()... ;-) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ LL YR VWL R BLNG T S -- www.nancybuttons.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python garbage collector/memory manager behaving strangely
In article 50570de3$0$29981$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 17 Sep 2012 06:46:55 -0400, Dave Angel wrote: On 09/16/2012 11:25 PM, alex23 wrote: def readlines(f): lines = [] while f is not empty: line = f.readline() if not line: break if len(line) 2 and line[-2:] == '|\n': lines.append(line) yield ''.join(lines) lines = [] else: lines.append(line) There's a few changes I'd make: I'd change the name to something else, so as not to shadow the built-in, Which built-in are you referring to? There is no readlines built-in. py readlines Traceback (most recent call last): File stdin, line 1, in module NameError: name 'readlines' is not defined There is a file.readlines method, but that lives in a different namespace to the function readlines so there should be no confusion. At least not for a moderately experienced programmer, beginners can be confused by the littlest things sometimes. Actually, as an experienced programmer, I *do* think it is confusing as evidenced by the mistake Dave made! Segregated namespaces are wonderful (per Zen), but let's not pollute multiple namespaces with same name, either. It may not be literally shadowing the built-in, but it definitely mentally shadows the built-in. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
DNS from Python (was Re: Subprocess puzzle and two questions)
In article mailman.3700.1352930072.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Thu, Nov 15, 2012 at 3:20 AM, Roy Smith r...@panix.com wrote: My first thought to solve both of these is that it shouldn't be too hard to hand-craft a minimal DNS query and send it over UDP. Then, I hunted around a bit and found that somebody had already done that, in spades. Take a look at http://www.dnspython.org; it might be exactly what's needed here. Yeah, that sounds like a good option. I'm slightly surprised that there's no way with the Python stdlib to point a DNS query at a specific server, but dnspython might be the solution. On the flip side, dnspython is dauntingly large; it looks like a full implementation of DNS, but I don't see a simple entrypoint that wraps it all up into a simple function that can be bracketed with time.time() calls (granted, I only skimmed the docs VERY quickly). So it may be simpler to hand-craft an outgoing UDP packet once, save it as a string literal, send that, and just wait for any response. That eliminates all DNS protocolling and just times the round trip. From one of my scripts lying around: domain = MAILTO.split('@',1)[1] server = str(dns.resolver.query(domain, 'MX')[0].exchange) You'll need to play around a bit to find out what that does, but it should point you in the right direction. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ LL YR VWL R BLNG T S -- www.nancybuttons.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a simpler way to modify all arguments in a function before using the arguments?
In article mailman.3530.1352538537.27098.python-l...@python.org, Peter Otten __pete...@web.de wrote: Miki Tebeka wrote: Is there a simpler way to modify all arguments in a function before using the arguments? You can use a decorator: from functools import wraps def fix_args(fn): @wraps(fn) def wrapper(*args): args = (arg.replace('_', '') for arg in args) return fn(*args) return wrapper @fix_args def foo(x, y): print(x) print(y) I was tempted to post that myself, but he said /simpler/ ;) From my POV, that *is* simpler. When you change the parameters for foo, you don't need to change the arg pre-processing. Also allows code reuse, probably any program needing this kind of processing once will need it again. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
Re: Single leading dash in member variable names?
In article mailman.514.1347390405.27098.python-l...@python.org, Ian Kelly ian.g.ke...@gmail.com wrote: On Tue, Sep 11, 2012 at 12:45 PM, e.doxta...@gmail.com wrote: Python noob here. Trying to understand a particular syntax: class stuff: def __init__(self): self._bongo = BongoWorld What is the significance of the leading underscore in self._bongo? I've seen this a few times and, after looking through PEP 8, I didn't see anything relevant, but I could have missed it. Single leading underscore is a convention indicating that the name should be considered private and not used externally. It's a softer version of the double leading underscore that means basically the same thing but has syntactic significance. Note that the convention is rooted in an actual semantic meaning for single underscore: ``from foo import *`` ignores any module global names in foo that start with a single leading underscore. Obviously, this has little effect for most Python programs because you DON'T USE ``import *``. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py
In article k2p9da$ktu$1...@r03.glglgl.gl, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de wrote: Am 11.09.2012 05:46 schrieb Steven D'Aprano: Good for you. (Sorry, that comes across as more condescending than it is intended as.) Monkey-patching often gets used for quick scripts and tiny pieces of code because it works. Just beware that if you extend that technique to larger bodies of code, say when using a large framework, or multiple libraries, your experience may not be quite so good. Especially if *they* are monkey-patching too, as some very large frameworks sometimes do. (Or so I am lead to believe.) This sonds like a good use case for a context manager, like the one in decimal.Context.get_manager(). Note that because get_manager() applies to a specific Context instance it is safe in a threaded application, which is NOT true for monkey-patching modules even with a context manager. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
Re: Numpy combine channels
In article mailman.465.1347307911.27098.python-l...@python.org, MRAB python-list@python.org wrote: On 10/09/2012 20:39, Wanderer wrote: I have an array generated by audiolab of left and right stereo channels. It looks like [[1,1],[1,2],[2,3]]. I would like to combine the left and right channels to get an array [2,3,5]. Is there a numpy command to do that? import numpy numpy.array([[1,1],[1,2],[2,3]], dtype=i) array([[1, 1], [1, 2], [2, 3]]) a[:, 0] array([1, 1, 2]) a[:, 1] array([1, 2, 3]) a[:, 0] + a[:, 1] array([2, 3, 5]) But should they be added together to make mono? Suppose, for example, that both channels have a maximum value. Their sum would be _twice_ the maximum. Therefore, I think that it should probably be the average. (a[:, 0] + a[:, 1]) / 2 array([1, 1, 2]) I'd actually think it should be the max. Consider a stereo where one side is playing a booming bass while the other side is playing a rest note -- should the mono combination be half as loud as as the bass? -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
Re: __unicode__() works, unicode() blows up. (Never mind!)
In article roy-30ba92.08410804112...@news.panix.com, Roy Smith r...@panix.com wrote: In article roy-90d9a2.08321804112...@news.panix.com, Roy Smith r...@panix.com wrote: print u.__unicode__() None print unicode(u) Traceback (most recent call last): File stdin, line 1, in module TypeError: coercing to Unicode: need string or buffer, NoneType found What's going on here? I thought (http://docs.python.org/2/library/functions.html#unicode) the latter two calls should be identical, but obviously they're not. Why is it, that no matter how long you stare at a problem, the answer comes to you moments after you hit the Post button? :-) The problem is that __unicode__() is supposed to return a Unicode object, and unicode() enforces that. The fix is to change: def __unicode__(self): return self.username to be: def __unicode__(self): return unicode(self.username) This never got noticed before because normally, self.username already is a unicode string, so it just works. You apparently need more coffee when programming after waking up! (Or even worse, staying up all night.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
Re: is implemented with id ?
[got some free time, catching up to threads two months old] In article 50475822$0$6867$e4fe5...@news2.news.xs4all.nl, Hans Mulder han...@xs4all.nl wrote: On 5/09/12 15:19:47, Franck Ditter wrote: - I should have said that I work with Python 3. Does that matter ? - May I reformulate the queston : a is b and id(a) == id(b) both mean : a et b share the same physical address. Is that True ? Yes. Keep in mind, though, that in some implementation (e.g. Jython), the physical address may change during the life time of an object. It's usually phrased as a and b are the same object. If the object is mutable, then changing a will also change b. If a and b aren't mutable, then it doesn't really matter whether they share a physical address. That last sentence is not quite true. intern() is used to ensure that strings share a physical address to save memory. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
Re: is implemented with id ?
In article mailman.3250.1351999198.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Sun, Nov 4, 2012 at 2:10 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: /* Shortcut for empty or interned objects */ if (v == u) { Py_DECREF(u); Py_DECREF(v); return 0; } result = unicode_compare(u, v); where v and u are pointers to the unicode object. There's a shortcut if they're the same. There's no shortcut if they're both interned and have different pointers, which is a guarantee that they're distinct strings. They'll still be compared char-for-char until there's a difference. Without looking at the code, I'm pretty sure there's a hash check first. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
Re: is implemented with id ?
In article 50959827$0$29967$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Actually, for many applications, the space savings may actually be *costs*, since interning forces Python to hold onto strings even after they would normally be garbage collected. That's old news, fixed in 2.5 or 2.6 IIRC -- interned strings now get collected by refcounting like everything else. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
Re: is implemented with id ?
In article 50959154$0$6880$e4fe5...@news2.news.xs4all.nl, Hans Mulder han...@xs4all.nl wrote: On 3/11/12 20:41:28, Aahz wrote: In article 50475822$0$6867$e4fe5...@news2.news.xs4all.nl, Hans Mulder han...@xs4all.nl wrote: On 5/09/12 15:19:47, Franck Ditter wrote: - I should have said that I work with Python 3. Does that matter ? - May I reformulate the queston : a is b and id(a) == id(b) both mean : a et b share the same physical address. Is that True ? Yes. Keep in mind, though, that in some implementation (e.g. Jython), the physical address may change during the life time of an object. It's usually phrased as a and b are the same object. If the object is mutable, then changing a will also change b. If a and b aren't mutable, then it doesn't really matter whether they share a physical address. That last sentence is not quite true. intern() is used to ensure that strings share a physical address to save memory. That's a matter of perspective: in my book, the primary advantage of working with interned strings is that I can use 'is' rather than '==' to test for equality if I know my strings are interned. The space savings are minor; the time savings may be significant. As others have pointed out, using ``is`` with strings is a Bad Habit likely leading to nasty, hard-to-find bugs. intern() costs time, but saves considerable space in any application with lots of duplicate computed strings (hundreds of megabytes in some cases). -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
Re: Haskell - Python
In article b19e3922-d86f-426f-afb8-1f75b793f...@googlegroups.com, foste...@gmail.com wrote: def options( heaps ): if heaps == []: return [] head, tail = heaps[:1], heaps[1:] # Calculate all possible moves which is the sum of # prepending all possible head moves to the tail # and appending all possible tail moves to the head return [ [h] + tail for h in range( head[0] ) ] \ + [ head + t for t in options( tail ) ] Is there anything anyone could recommend to make it more Pythonic or more functional. It looks clumsy next to the Haskell. If you want more Pythonic, follow PEP8 in your formatting. ;-) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
Re: Proper place for everything
In article 509441cb$0$29967$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Fri, 02 Nov 2012 04:20:20 -0700, Jason Benjamin wrote: Anybody know of the appropriate place to troll and flame about various Python related issues? I'm kind of mad about some Python stuff and I need a place to vent where people may or may not listen, but at at least respond. Thought this would be a strange question, but I might as well start somewhere. Thank you for your honesty, but trolling is not welcome. However if you have actual issues about Python, either pro or con, and hope to have a serious, respectful dialog where both parties listen to each other, feel free to raise them here. Keep in mind three things: - We've probably heard all your arguments a thousand times before. It's unlikely that you are either the first or the last person to notice that (e.g.) Python has significant indentation. So expect a certain amount of brusqueness. - If your argument boils down to Python isn't insert language here we will not be sympathetic, and will probably sneer or laugh at you privately. And possibly publicly too. - If you hope to convince the Python community to change feature X, we are constrained by backwards-compatibility issues, policies, and design decisions. Frequently there are (mis-)features that we simply have to live with, for good or ill. You forgot the fourth point. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
FINAL REMINDER: OSCON Call for Proposals (deadline 1/12)
DEADLINE Thursday January 12 OSCON (O'Reilly Open Source Convention), the premier Open Source gathering, will be held in Portland, OR July 16-20. We're looking for people to deliver tutorials and shorter presentations. http://www.oscon.com/oscon2012 http://www.oscon.com/oscon2012/public/cfp/197 Hope to see you there! -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Do not taunt happy fun for loops. Do not change lists you are looping over. --Remco Gerlich -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
REMINDER: OSCON Call for Proposals (deadline 1/12)
DEADLINE Thursday January 12 Ring in the Gnu year with a proposal for OSCON! OSCON (O'Reilly Open Source Convention), the premier Open Source gathering, will be held in Portland, OR July 16-20. We're looking for people to deliver tutorials and shorter presentations. http://www.oscon.com/oscon2012 http://www.oscon.com/oscon2012/public/cfp/197 Hope to see you there! -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Do not taunt happy fun for loops. Do not change lists you are looping over. --Remco Gerlich -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
OSCON Call for Proposals (deadline 1/12)
DEADLINE Thursday January 12 OSCON (O'Reilly Open Source Convention), the premier Open Source gathering, will be held in Portland, OR July 16-20. We're looking for people to deliver tutorials and shorter presentations. http://www.oscon.com/oscon2012 http://www.oscon.com/oscon2012/public/cfp/197 Hope to see you there! -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Do not taunt happy fun for loops. Do not change lists you are looping over. --Remco Gerlich -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Feature suggestion -- return if true
In article mailman.461.1303043638.9059.python-l...@python.org, D'Arcy J.M. Cain da...@druid.net wrote: On Sun, 17 Apr 2011 16:21:53 +1200 Gregory Ewing greg.ew...@canterbury.ac.nz wrote: My idiom for fetching from a cache looks like this: def get_from_cache(x): y = cache.get(x) if not y: y = compute_from(x) cache[x] = y return y I prefer not to create and destroy objects needlessly. def get_from_cache(x): if not x in cache: cache[x] = compute_from(x) return cache[x] Aside from Steven's entirely appropriate pointed question, I find this more readable: if x not in cache: Without testing, I'm not sure, but I believe it's more efficient, too (creates fewer bytecodes). -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-) --Michael Foord paraphrases Christian Muirhead on python-dev, 2009-03-22 -- http://mail.python.org/mailman/listinfo/python-list
Re: Questions about GIL and web services from a n00b
In article e6008cc8-50f0-4d78-be78-ec6e73b97...@22g2000prx.googlegroups.com, Raymond Hettinger pyt...@rcn.com wrote: Threading is really only an answer if you need to share data between threads, if you only have limited scaling needs, and are I/O bound rather than CPU bound Threads are also useful for user interaction (i.e. GUI apps). I think that limited scaling needs to be defined, too; CherryPy performs pretty well, and the blocking model does simplify development. One problem that my company has run into with threading is that it's not always obvious where you'll hit GIL blocks. For example, one would think that pickle.loads() releases the GIL, but it doesn't; you need to use pickle.load() (and cStringIO if you want to do it in memory). -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-) --Michael Foord paraphrases Christian Muirhead on python-dev, 2009-03-22 -- http://mail.python.org/mailman/listinfo/python-list
Re: Forcing absolute package imports in 2.7?
In article mailman.23.1301538403.2990.python-l...@python.org, Michael Parker michael.g.par...@gmail.com wrote: I'm reading Learning Python 4th Edition by Lutz. In the section on relative package imports, he says: In Python 3.0, the `import modname` statement is always absolute, skipping the containing package=92s directory. In 2.6, this statement form still performs relative imports today (i.e., the package=92s directory is searched first), but these will become absolute in Python 2.7, too.` But in my own testing I'm not seeing this behavior. Was it not included in 2.7 for fear of breaking too many programs? from __future__ import absolute_import -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-) --Michael Foord paraphrases Christian Muirhead on python-dev, 2009-03-22 -- http://mail.python.org/mailman/listinfo/python-list
Re: threading.Semaphore (quite long)
In article imqr00$5hb$1...@r03.glglgl.eu, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de wrote: I want to implement an alternative concept to worker threads processing a job queue. The alternative consists of threads being the jobs themselves and thus running only this one job. The job threads are started after a Semaphore's acquire() giving the OK to do so. The Semaphore's release() gets called inside the jobs/threads, saying done, the next one please. But the program doesn't always stop on Ctrl-C. [...] 0. (First and in general) Am I doing bad things when calling release() at a completely different place than acquire() with a Semaphore? I used to believe that's why there are Semaphores? Should be fine. 1. Is a bug report useful, or would that worsen the problem, as the race condition doesn't disappear completely? shrug If you can demonstrate that the problem occurs outside signals (keyboard interrupt uses a signal), that would be more interesting (signals and threads are often problematic). 2. Is in, in general, an error to work with Semaphores (ore, more general with Locks) in the MainThread? Or should this be done in a separate thread being informed about a keyboard exception by the main thread? Outside of signals, there should not be a problem with that. I don't have time to look further, I just noticed that nobody responded. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-) --Michael Foord paraphrases Christian Muirhead on python-dev, 2009-03-22 -- http://mail.python.org/mailman/listinfo/python-list
Re: Dump interpreter history?
In article mailman.222.1302543313.9059.python-l...@python.org, Terry Reedy tjre...@udel.edu wrote: On 4/11/2011 11:54 AM, Aahz wrote: In articlemailman.1266.1301087057.1189.python-l...@python.org, Ken D'Ambrosiok...@jots.org wrote: Hey, all. A co-worker asked me a question, and I've got no idea how (or if) it can be done. Bottom line: he'd like to save off the text from an interpreter session, his thinking being that you've already tried to get what you want, and now you just need to gussy it up in an editor. I've never used it myself, but IIRC ipython does what you want very nicely. Idle will save the contents of the shell window, including opening slash line and prompts. The problem is that normally you *don't* want the prompts. I believe IPython handles that. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-) --Michael Foord paraphrases Christian Muirhead on python-dev, 2009-03-22 -- http://mail.python.org/mailman/listinfo/python-list
Re: Dump interpreter history?
In article mailman.1266.1301087057.1189.python-l...@python.org, Ken D'Ambrosio k...@jots.org wrote: Hey, all. A co-worker asked me a question, and I've got no idea how (or if) it can be done. Bottom line: he'd like to save off the text from an interpreter session, his thinking being that you've already tried to get what you want, and now you just need to gussy it up in an editor. I've never used it myself, but IIRC ipython does what you want very nicely. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-) --Michael Foord paraphrases Christian Muirhead on python-dev, 2009-03-22 -- http://mail.python.org/mailman/listinfo/python-list
Re: python on iPad (PyPad)
In article 4d9feaea$0$29996$c3e8da3$54964...@news.astraweb.com, Jon Dowdall jon_dot_dowdall_at@_gmail.com wrote: Sorry for the blatant advertising but hope some of you may be interested to know that I've created an iPad application containing the python interpreter and a simple execution environment. It's available in iTunes at http://itunes.apple.com/us/app/pypad/id428928902?mt=8# There's nothing wrong with advertising this, I suggest that you also announce it on c.l.py.announce -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-) --Michael Foord paraphrases Christian Muirhead on python-dev, 2009-03-22 -- http://mail.python.org/mailman/listinfo/python-list
Re: Guido rethinking removal of cmp from sort method
In article 4d8be3bb.4030...@v.loewis.de, Martin v. Loewis mar...@v.loewis.de wrote: Martin deleted the attribution for Carl Banks: The cmp argument doesn't depend in any way on an object's __cmp__ method, so getting rid of __cmp__ wasn't any good readon to also get rid of the cmp argument So what do you think about the cmp() builtin? Should have stayed, or was it ok to remove it? If it should have stayed: how should it's implementation have looked like? If it was ok to remove it: how are people supposed to fill out the cmp= argument in cases where they use the cmp() builtin in 2.x? Actually, my take is that removing __cmp__ was a mistake. (I already argued about it back in python-dev before it happened, and I see little point rehashing it. My reason is strictly efficiency grounds: when comparisons are expensive -- such as Decimal object -- __cmp__ is faster.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Beware of companies that claim to be like a family. They might not be lying. --Jill Lundquist -- http://mail.python.org/mailman/listinfo/python-list
Re: Guido rethinking removal of cmp from sort method
In article 4d9f32a2$1...@dnews.tpgi.com.au, Lie Ryan lie.1...@gmail.com wrote: On 04/09/11 01:08, Aahz wrote: Actually, my take is that removing __cmp__ was a mistake. (I already argued about it back in python-dev before it happened, and I see little point rehashing it. My reason is strictly efficiency grounds: when comparisons are expensive -- such as Decimal object -- __cmp__ is faster.) I don't get you... why would sorting a list using __cmp__ be faster when comparisons are expensive? Not sorting (because sorting only requires one comparison), but any operation involving multiple comparisons. Consider this: if a b: x() elif a == b: y() else: z() For a = b, you need to make two comparisons. Now consider this: r = cmp(a, b) if r 0: x() elif r == 0: y() else: z() -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-) --Michael Foord paraphrases Christian Muirhead on python-dev, 2009-03-22 -- http://mail.python.org/mailman/listinfo/python-list
Re: reimport module every n seconds
In article 753e9884-60eb-43cf-a647-12b29ed28...@y31g2000prd.googlegroups.com, Santiago Caracol santiago.cara...@gmail.com wrote: Don't do that. =A0;-) =A0I suggest using exec instead. =A0However, I wo= uld be surprised if import worked faster than, say, JSON (more precisely, I doubt that it's enough faster to warrnat this kludge). I'm with Aahz. =A0Don't do that. I don't know what you're doing, but I suspect an even better solution would be to have your program run a reconfigure thread which listens on a UDP socket and reads a JSON object from it. =A0Or, at the very least= , which listens for a signal which kicks it to re-read some JSON from a disk file. =A0This will be more responsive when the data changes quickly and more efficient when it changes slowly. =A0As opposed to just polling for changes every 10 seconds. Somehow I guessed that I would be told not to do it. But it's my fault. I should have been more explicit. The data is not just data. It is a large set of Django objects I call ContentClassifiers that have each certain methods that calculate from user input very large regular expressions. They they have a method classify that is applied to messages and uses the very large regular expressions. To classify a message I simply apply the classify method of all ContentClassifiers. There are very many Contentclassifiers. I compile the ContentClassifiers, which are Django objects, to pure Python objects in order to not have to fetch them from the database each time I need them and in order to be able to compile the large regular expressions offline. In Django, I generated and compiled each regular expressions of each ContentClassifier each time I needed it to classify a message. I didn't find a good way to calculate and compile the regular expressions once and store them. I already tested the automatically generated module: Before, classifying a message took about 10 seconds, now it takes miliseconds. My only problem is reloading the module: At the time being, I simply restart the web server manually from time to time in order to load the freshly compiled module. Why not just create a second process and send the messages there? Then restart the second process each time you need to reload. That can be easily automated. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Beware of companies that claim to be like a family. They might not be lying. --Jill Lundquist -- http://mail.python.org/mailman/listinfo/python-list
Re: PostgreSQL vs MySQL
In article 87bp1a3g59@benfinney.id.au, Ben Finney ben+pyt...@benfinney.id.au wrote: a...@pythoncraft.com (Aahz) writes: (I always recommend people to use PostgreSQL, though; which is superior in almost every way, especially the C client library and the wire protocol.) Can you point at a reference for the latter? I have been trying to convince my company that PG is better than MySQL. These may be helpful: URL:http://wiki.postgresql.org/wiki/Why_PostgreSQL_Instead_of_MySQL_2009 URL:http://www.wikivs.com/wiki/MySQL_vs_PostgreSQL Thanks! I've forwarded this. However, it doesn't address the assertion about the client library and wire protocol. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Beware of companies that claim to be like a family. They might not be lying. --Jill Lundquist -- http://mail.python.org/mailman/listinfo/python-list
PostgreSQL vs MySQL (was Re: How to handle sockets - easily?)
In article fdjt28-flo@wilbur.25thandclement.com, William Ahern will...@wilbur.25thandclement.com wrote: I think that there's an asynchronous all-Python MySQL library, but I'm not sure. Maybe one day I can open source my asynchronous MySQL C library. (I always recommend people to use PostgreSQL, though; which is superior in almost every way, especially the C client library and the wire protocol.) Can you point at a reference for the latter? I have been trying to convince my company that PG is better than MySQL. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Beware of companies that claim to be like a family. They might not be lying. --Jill Lundquist -- http://mail.python.org/mailman/listinfo/python-list
Re: Plumber, an alternative to mixin-based subclassing
[posted e-mailed] In article mailman.1666.1296864671.6505.python-l...@python.org, Florian Friesdorf f...@chaoflow.net wrote: An alternative to mixin-based subclassing: http://pypi.python.org/pypi/plumber You'll probably get more interest if you provide a summary. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Programming language design is not a rational science. Most reasoning about it is at best rationalization of gut feelings, and at worst plain wrong. --GvR, python-ideas, 2009-03-01 -- http://mail.python.org/mailman/listinfo/python-list
Re: Idea for removing the GIL...
In article b8112a95-0c8d-41b7-9e42-805e63a78...@o32g2000prb.googlegroups.com, Carl Banks pavlovevide...@gmail.com wrote: The real reason they never replaced the GIL is that fine-grained locking is expensive with reference counting. The only way the cost of finer-grained locking would be acceptable, then, is if they got rid of the reference counting altogether, and that was considered too drastic a change. ...especially given CPython's goal of easy integration with C libraries. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Programming language design is not a rational science. Most reasoning about it is at best rationalization of gut feelings, and at worst plain wrong. --GvR, python-ideas, 2009-03-01 -- http://mail.python.org/mailman/listinfo/python-list
Re: reimport module every n seconds
In article 6cde71c6-5c56-40ea-9849-50fc44e5d...@o14g2000prb.googlegroups.com, Santiago Caracol santiago.cara...@gmail.com wrote: a server program of mine uses data which are compiled to a Python module for efficiency reasons. In some module of the server program I import the data: from data import data As the data often changes, I would like to reimport it every n (e.g. 10) seconds. Don't do that. ;-) I suggest using exec instead. However, I would be surprised if import worked faster than, say, JSON (more precisely, I doubt that it's enough faster to warrnat this kludge). -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Programming language design is not a rational science. Most reasoning about it is at best rationalization of gut feelings, and at worst plain wrong. --GvR, python-ideas, 2009-03-01 -- http://mail.python.org/mailman/listinfo/python-list
Re: Which is the best book to learn python
In article mailman.1150.1295890778.6505.python-l...@python.org, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Python is easy to learn, I'm not sure it's possible to write a bad book about it. Yes, it is. I can name two: Deitel: Python How to Program Perl to Python Migration -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Programming language design is not a rational science. Most reasoning about it is at best rationalization of gut feelings, and at worst plain wrong. --GvR, python-ideas, 2009-03-01 -- http://mail.python.org/mailman/listinfo/python-list
Re: Which non SQL Database ?
In article 4d3c8d53$0$44021$742ec...@news.sonic.net, John Nagle na...@animats.com wrote: Google's BigTable and Facebook's Cassandra offer impressive performance at very large scale. But they're way overkill for a desktop app. Even the midrange systems, like CouchDB, are far too much machinery for a desktop app. Side note: one reason we chose Cassandra for our midrange requirements was that it doesn't have master nodes, and we wanted to avoid single point of failure. Side note 2: do NOT run Cassandra on a virtual machine. That was a bad mistake we made because our performance requirements are fairly modest. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Programming language design is not a rational science. Most reasoning about it is at best rationalization of gut feelings, and at worst plain wrong. --GvR, python-ideas, 2009-03-01 -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple independently started python processes and sharing of a module
In article igo5a0$r48$1...@news.eternal-september.org, Martin P. Hellwig martin.hell...@dcuktec.org wrote: Currently my solution is to wrap the module around a module that when used creates a directory and pipes to the process (multiprocessing.Connection) thus enforcing single access and within that I have wrapped the db function around again so that select statement as mentioned above is actually an execute followed by a fetchall. I still have the nagging feeling that I have reinvented a squared wheel or am totally missing the point. What you want is a worker pool or connection pool. I.e. you keep around multiple open connections and assign them per request. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Programming language design is not a rational science. Most reasoning about it is at best rationalization of gut feelings, and at worst plain wrong. --GvR, python-ideas, 2009-03-01 -- http://mail.python.org/mailman/listinfo/python-list
LAST CHANCE: OSCON Call for Proposals (deadline 2/7)
DEADLINE Monday February 7 OSCON (O'Reilly Open Source Convention), the premier Open Source gathering, will be held in Portland, OR July 25-29. We're looking for people to deliver tutorials and shorter presentations. http://www.oscon.com/oscon2011 http://www.oscon.com/oscon2011/public/cfp/144 Hope to see you there! -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ All problems in computer science can be solved by another level of indirection. --Butler Lampson -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
REMINDER: OSCON Call for Proposals (deadline 2/7)
DEADLINE Monday February 7 OSCON (O'Reilly Open Source Convention), the premier Open Source gathering, will be held in Portland, OR July 25-29. We're looking for people to deliver tutorials and shorter presentations. http://www.oscon.com/oscon2011 http://www.oscon.com/oscon2011/public/cfp/144 Hope to see you there! -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ All problems in computer science can be solved by another level of indirection. --Butler Lampson -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: how to read the last line of a huge file???
In article mailman.1412.1296196161.6505.python-l...@python.org, John O'Hagan resea...@johnohagan.com wrote: file.seek takes an optional 'whence' argument which is 2 for the end, so you can just work back from there till you hit the first newline that has anything after it: def lastline(filename): offset = 0 line = '' with open(filename) as f: while True: offset -= 1 f.seek(offset, 2) nextline = f.next() if nextline == '\n' and line.strip(): return line else: line = nextline It's a Bad Idea to mix direct file operations with the iterator API. Use f.read() instead of f.next(). -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ All problems in computer science can be solved by another level of indirection. --Butler Lampson -- http://mail.python.org/mailman/listinfo/python-list
Re: apscheduler error
In article mailman.654.1294470254.6505.python-l...@python.org, =?utf-8?Q?Alice_Bevan=E2=80=93McGregor?= al...@gothcandy.com wrote: A package of mine, TurboMail, suffers from the same threading issue if used improperly; you enqueue e-mail, it starts a thread, then you immediately exit. TM tries to work around the issue, but in most cases that workaround does not work properly. (You get strange uncatchable exceptions printed on stderr though AFIK the e-mail does get sent correctly, your application may hang waiting for the thread pool to drain if you have a minimum thread count option set.) Why not write an exit handler that converts your thread to daemon? (Or something like that.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ All problems in computer science can be solved by another level of indirection. --Butler Lampson -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating custom Python objects from C code
In article mailman.537.1294244829.6505.python-l...@python.org, Eric Frederich eric.freder...@gmail.com wrote: I have read through all the documentation here: http://docs.python.org/extending/newtypes.html I have not seen any documentation anywhere else explaining how to create custom defined objects from C. I have this need to create custom objects from C and pass them as arguments to a function call. You should definitely investigate Cython, but if you really want to roll your own, look in the examples inside the Python source itself. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ All problems in computer science can be solved by another level of indirection. --Butler Lampson -- http://mail.python.org/mailman/listinfo/python-list
OSCON Call for Proposals (deadline 2/7)
OSCON (O'Reilly Open Source Convention), the premier Open Source gathering, will be held in Portland, OR July 25-29. We're looking for people to deliver tutorials and shorter presentations. http://www.oscon.com/oscon2011 http://www.oscon.com/oscon2011/public/cfp/144 Hope to see you there! -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ All problems in computer science can be solved by another level of indirection. --Butler Lampson -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: issubclass(dict, Mapping)
In article ieu9bk$mt0$1...@reader1.panix.com, kj no.em...@please.post wrote: standard OOP semantics ...some experts might say a C++ program is not object-oriented without inheritance and virtual functions. As one of the early Smalltalk implementors myself, I can say they are full of themselves. --zconcept -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a -- http://mail.python.org/mailman/listinfo/python-list
Re: Trying to parse a HUGE(1gb) xml file
In article mailman.176.1292919399.6505.python-l...@python.org, Stefan Behnel stefan...@behnel.de wrote: Try import xml.etree.cElementTree as etree instead. Note the leading c, which hints at the C implementations of ElementTree. It's much faster and much more memory friendly than the Python implementation. Thanks! I updated our codebase this afternoon... -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing string for verb noun
In article 0d7143ca-45cf-44c3-9e8d-acb867c52...@f30g2000yqa.googlegroups.com, Daniel da Silva ddasi...@umd.edu wrote: I have come across a task where I would like to scan a short 20-80 character line of text for instances of verb noun. Ideally verb could be of any tense. In Soviet Russia, noun verbs you! -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Think of it as evolution in action. --Tony Rand -- http://mail.python.org/mailman/listinfo/python-list
Re: Integrating doctest with unittest
In article 4d038b63$0$3$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Is there a way to have unittest.main() find and run doc_test_suite together with the other test suites? You probably need to use nose or something. (That's what we're doing.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Think of it as evolution in action. --Tony Rand -- http://mail.python.org/mailman/listinfo/python-list
Re: surprised by import in python 2.6
In article tvxmo.3345$wj4.1...@newsfe12.ams2, Stefaan Himpe stefaan.hi...@gmail.com wrote: Recently someone asked me this question, to which I could not give an answer. I'm hoping for some insight, or a manual page. What follows is python 2.6. The problem is with the difference between from test import * and import test Just adding to this thread for Gooja: Don't use import * -- it makes debugging difficult because you can't tell where a name comes from. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Think of it as evolution in action. --Tony Rand -- http://mail.python.org/mailman/listinfo/python-list
Re: Trying to decide between PHP and Python
In article e5f25444-c4fc-4a24-ac74-e9a5344ac...@k14g2000pre.googlegroups.com, Google Poster gopos...@jonjay.com wrote: The syntax reminds me of Lots of Interspersed Silly Parentheses (L.I.S.P.), but without the parentheses. You're not the first person to make that observation: http://norvig.com/python-lisp.html See also: http://norvig.com/python-iaq.html -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Think of it as evolution in action. --Tony Rand -- http://mail.python.org/mailman/listinfo/python-list
Re: Trying to decide between PHP and Python
In article roy-bde7f0.19310104012...@news.panix.com, Roy Smith r...@panix.com wrote: In article 4d23a29d.7030...@yahoo.com, Alan Meyer amey...@yahoo.com wrote: On 1/4/2011 4:22 PM, Google Poster wrote: The syntax reminds me of Lots of Interspersed Silly Parentheses (L.I.S.P.), but without the parentheses. I haven't heard that version before. The one I heard was: Lots of Irritating Single Parentheses. Long Involved Stupid Parentheses. http://www.netfunny.com/rhf/jokes/90q2/lispcode.html -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Think of it as evolution in action. --Tony Rand -- http://mail.python.org/mailman/listinfo/python-list
Re: How to initialize each multithreading Pool worker with an individual value?
In article mailman.61.1291152972.2649.python-l...@python.org, Valery Khamenya khame...@gmail.com wrote: However it doesn't look possible to use it to initialize each Pool's worker with some individual value (I'd wish to be wrong here) So, how to initialize each multithreading Pool worker with the individual values? The typical use case might be a connection pool, say, of 3 workers, where each of 3 workers has its own TCP/IP port. from multiprocessing.pool import Pool def port_initializer(_port): global port port = _port def use_connection(some_packet): global _port print sending data over port # %s % port if __name__ == __main__: ports=((4001,4002, 4003), ) p = Pool(3, port_initializer, ports) # oops... :-) You probably can't use initargs here. Your port_initializer needs to be some kind of class instance that works with multiprocessing and emits one port number when its __call__() method gets invoked. (There may be other ways to accomplish the same effect, but that's what springs to mind.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Think of it as evolution in action. --Tony Rand -- http://mail.python.org/mailman/listinfo/python-list
Re: Catching user switching and getting current active user from root on linux
In article ff3a2b89-2586-43d2-ae5a-490384687...@32g2000yqz.googlegroups.com, mpnordland mpnordl...@gmail.com wrote: First, to pacify those who hate google groups: What is a good usenet client? trn3.6 ;-) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Think of it as evolution in action. --Tony Rand -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison with False - something I don't understand
In article mailman.187.1291397553.2649.python-l...@python.org, Harishankar v.harishan...@gmail.com wrote: On Thu, 02 Dec 2010 17:33:47 -0800, Aahz wrote: Please demonstrate that using ``if`` blocks for True/False is impler and cleaner than using ``try`` blocks to handle exceptions. It is my personal preference and coding style for certain situations I encounter in my own programs and not something that I could prove to anybody else by theory. Note carefully that I said demonstrate, not prove. If using ``if`` is so clearly better in some situations, you should be able to provide an example. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Think of it as evolution in action. --Tony Rand -- http://mail.python.org/mailman/listinfo/python-list
Re: Get frame object of last called function
In article fe48f5b8-36b4-433d-84f7-e7d749485...@j2g2000yqf.googlegroups.com, moerchendiser2k3 googler.1.webmas...@spamgourmet.com wrote: Hi, is there any chance to get the frame object of the previous called function? sys._current_frames(), sys._getframe() -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Think of it as evolution in action. --Tony Rand -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison with False - something I don't understand
In article mailman.143.1291301807.2649.python-l...@python.org, Harishankar v.harishan...@gmail.com wrote: There are some reasons why I hate exceptions but that is a different topic. However, in short I can say that personally: 1. I hate try blocks which add complexity to the code when none is needed. Try blocks make code much more unreadable in my view and I use it only for the built-in exceptions when absolutely needed. 2. I prefer the less irksome True or False to do error checking. Exceptions seem too heavyweight for simple problems. Please demonstrate that using ``if`` blocks for True/False is impler and cleaner than using ``try`` blocks to handle exceptions. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Think of it as evolution in action. --Tony Rand -- http://mail.python.org/mailman/listinfo/python-list
Re: playful coding problems for 10 year olds
In article mailman.459.1288643471.2218.python-l...@python.org, Daniel Fetchinson fetchin...@googlemail.com wrote: My niece is interested in programming and python looks like a good choice (she already wrote a couple of lines :)) She is 10 and I thought it would be good to have a bunch of playful coding problems for her, stuff that she could code herself maybe after some initial help. What other interests does she have? Might Python play a role? http://micheinnz.livejournal.com/1080735.html (Agent Weasel ended up making a presentation at the NZ PyCon.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Think of it as evolution in action. --Tony Rand -- http://mail.python.org/mailman/listinfo/python-list
Re: a regexp riddle: re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c') =? ('a', 'bbb', 'c')
In article ad755502-bf79-46ea-b7ee-57ac6f7ee...@z26g2000prf.googlegroups.com, Phlip phlip2...@gmail.com wrote: Thanks all for playing! And as usual I forgot a critical detail: I'm writing a matcher for a Morelia /viridis/ Scenario step, so the matcher must be a single regexp. Why? (You're apparently the author of Morelia, but I don't really understand it.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Think of it as evolution in action. --Tony Rand -- http://mail.python.org/mailman/listinfo/python-list
Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance
In article 89b6d53f-dcdc-4442-957f-1f4d29115...@n32g2000pre.googlegroups.com, Raymond Hettinger pyt...@rcn.com wrote: I'm writing-up more guidance on how to use super() and would like to point at some real-world Python examples of cooperative multiple inheritance. My previous job used this rather heavily, but I can't provide you with code. I suspect we weren't the only people, but I have no clue how to locate samples. Were you searching code.google.com or something else? -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Look, it's your affair if you want to play with five people, but don't go calling it doubles. --John Cleese anticipates Usenet -- http://mail.python.org/mailman/listinfo/python-list
Re: is list comprehension necessary?
In article 4cc701e7$0$1606$742ec...@news.sonic.net, John Nagle na...@animats.com wrote: Python isn't a functional language. It has some minimal functional capabilities, and there's a lobby that would like more. So far, that's mostly been resisted. Attempts to allow multiline lambdas have been averted. The weird functional if syntax additions were a cave-in to the functional crowd, and may have been a mistake. Did you actually read the PEP explanation for *why* Guido decided to add conditional expressions? -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Look, it's your affair if you want to play with five people, but don't go calling it doubles. --John Cleese anticipates Usenet -- http://mail.python.org/mailman/listinfo/python-list
Where's the bug? (cPickle/thread edition) (was Re: How to optimize and monitor garbage collection?)
In article mailman.214.1287979505.2218.python-l...@python.org, Steve Holden st...@holdenweb.com wrote: [aside: in general, if you think your program is not working because of a bug in Python, look harder at your program]. Good advice, I certainly agree with you. But sometimes it's not so simple. Right now, my company is running up against a problem with CherryPy because cPickle.dumps() doesn't release the GIL. You could argue that it's our fault for using threads, and you could also argue that we're having problems because our server has heavy memory contention (a dumps() that takes a couple of seconds on a laptop takes more than thirty seconds on the server). Nevertheless, I think it's also arguably a bug that dumps() doesn't release the GIL. (cPickle.dump() *does* release the GIL.) (Fortunately, we're savvy enough that it's easy for us to just make a local copy of cPickle that releases the GIL. Much easier than finding the problem in the first place...) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Look, it's your affair if you want to play with five people, but don't go calling it doubles. --John Cleese anticipates Usenet -- http://mail.python.org/mailman/listinfo/python-list
Re: Python has a really hidden encapsulation?
In article 87fwvw214g@gmail.com, Arnaud Delobelle arno...@gmail.com wrote: Are you referring to the fact that in Python, if an attribute is a property, the __dict__ lookup on the instance is not performed? As in: class A: ... @property ... def x(self): return 42 ... a = A() a.__dict__['x'] = 24 a.x 42 a.__dict__['x'] 24 This is documented, but I actually don't know the reason for it. Because otherwise you would be able to overwrite the property with a value. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Look, it's your affair if you want to play with five people, but don't go calling it doubles. --John Cleese anticipates Usenet -- http://mail.python.org/mailman/listinfo/python-list
Re: Komodo 6, why Workspace Restore after every restart?
[overquoting follows to prove my point] Someone who claims to care as much as you do about Usenet ought to have better quoting habits. You should be ashamed of yourself. In article 4ce0f788$0$30018$c3e8da3$76a7c...@news.astraweb.com, John Doe j...@usenetlove.invalid wrote: alex23 wuwei23 gmail.com wrote: John Doe j... usenetlove.invalid wrote: Google Groups spews a massive amount of sewage onto UseNet everyday. Google Groups is your news server. You should be ashamed Get over yourself. You too, and stop using the spammers den while you are at it. -- See also googled groups Path: news.astraweb.com!border5.newsrouter.astraweb.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!g20g2000prg.googlegroups.com!not-for-mail From: alex23 wuwei23 gmail.com Newsgroups: comp.lang.python Subject: Re: Komodo 6, why Workspace Restore after every restart? Date: Mon, 15 Nov 2010 00:42:36 -0800 (PST) Organization: http://groups.google.com Lines: 6 Message-ID: 15016ae4-b341-4f4e-ac84-62fe7f93f217 g20g2000prg.googlegroups.com References: 4ce07839$0$17214$c3e8da3$eb767761 news.astraweb.com 428b98ca-72bf-4e3b-ad8a-dafe2fc4d553 v28g2000prn.googlegroups.com 4ce0c065$0$23246$c3e8da3$a9097924 news.astraweb.com 6ae54329-c652-4a59-b0e2-4c2038f58d5a x4g2000pre.googlegroups.com 4ce0ea79$0$29271$c3e8da3$88b277c5 news.astraweb.com NNTP-Posting-Host: 115.64.196.128 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1289810556 23916 127.0.0.1 (15 Nov 2010 08:42:36 GMT) X-Complaints-To: groups-abuse google.com NNTP-Posting-Date: Mon, 15 Nov 2010 08:42:36 + (UTC) Complaints-To: groups-abuse google.com Injection-Info: g20g2000prg.googlegroups.com; posting-host=115.64.196.128; posting-account=rYyWJQoAAACVJO77HvcyJfa3TnGYCqK_ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.12 (KHTML, like Gecko) Chrome/9.0.576.0 Safari/534.12,gzip(gfe) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Look, it's your affair if you want to play with five people, but don't go calling it doubles. --John Cleese anticipates Usenet -- http://mail.python.org/mailman/listinfo/python-list
Re: OO and game design questions
In article i9lfbu$1a...@localhost.localdomain, Martin Gregorie mar...@address-in-sig.invalid wrote: On Tue, 19 Oct 2010 19:49:20 -0400, Dave Angel wrote: Thanks, that is what I was trying to say. In the same sense that emptying a list makes it quite small, if it's a general purpose object, you just want to remove all the attributes. I think a 'place' (to generalise it) is quite a small object in any case. All it needs to contain is a few lists: - a list of exits, which in some implementations might be simply references to other places, but might usefully be objects with two sides, each having an appearance and a link to the place where that side appears. - a list of fixed objects which only serve to describe the place. - a list of mobile objects that actors can pick up and move - a list of actors who happen to be there. plus a describePlace() method and add(), remove() and getItem() methods for each list. It may be possible to use a single list for all types of object, in which case the object itself would be very small indeed. Maybe you want a rule-based approach: http://eblong.com/zarf/essays/rule-based-if/ -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Look, it's your affair if you want to play with five people, but don't go calling it doubles. --John Cleese anticipates Usenet -- http://mail.python.org/mailman/listinfo/python-list
Re: how to identify currently running threads QTHreads
In article 4cdfe050$0$10182$426a3...@news.free.fr, News123 news1...@free.fr wrote: Is there a simple way in Python to identify all active Threads / QThreads when trying, such that I can locate the thread, itls related python code and fix it? threading.enumerate() or sys._current_frames() -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Look, it's your affair if you want to play with five people, but don't go calling it doubles. --John Cleese anticipates Usenet -- http://mail.python.org/mailman/listinfo/python-list
Re: how to handle network failures
In article 7bee5155-f1a1-44aa-90f6-eaabb3617...@v6g2000prd.googlegroups.com, harryos oswald.ha...@gmail.com wrote: class DataGrabber(threading.Thread): def __init__(self,url): threading.Thread.__init__(self) self.url=url def run(self): data=self.get_page_data() process_data(data) def get_page_data(): try: f=urllib.urlopen(self.url) data=f.read(1024) except IOError: #wait for some time and try again time.sleep(120) data=self.get_page_data() return data Use urllib2 so that you can set a timeout (Python 2.6+). -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ If you think it's expensive to hire a professional to do the job, wait until you hire an amateur. --Red Adair -- http://mail.python.org/mailman/listinfo/python-list
Re: What people are using to access this mailing list
In article iarmmi$qe...@reader1.panix.com, Grant Edwards inva...@invalid.invalid wrote: On 2010-11-03, Paul Rudin paul.nos...@rudin.co.uk wrote: John Bond li...@asd-group.com writes: On 3/11/2010 11:17 AM, Steven D'Aprano wrote: On Wed, 03 Nov 2010 08:02:29 +, John Bond wrote: Hope this isn't too O/T - I was just wondering how people read/send to this mailing list, eg. normal email client, gmane, some other software or online service? Usenet via my ISP, on comp.lang.python. Using what client (or web client)? Emacs, of course :-; Slrn, of course. trn3.6, of course. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ If you think it's expensive to hire a professional to do the job, wait until you hire an amateur. --Red Adair -- http://mail.python.org/mailman/listinfo/python-list
Re: embedding python in macOS 10.6
[posted e-mailed] In article mailman.1160.1285769782.29448.python-l...@python.org, tinau...@libero.it tinau...@libero.it wrote: i'm trying to embed python in a c++ code.i'm starting with the example in the tutorial.i've problem with setting up the enveiroment. I've installed python with the distributed version (i.e., i did not, as a start, build it myself); i added the library where both python.h and pyconfig are stored and i linked to libpython2.6.a (which is, in the distributed version, an alias). For Mac you probably want to build Python yourself, but I'm certainly not an expert. If you still haven't figured it out, try pythonmac-sig. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ If you think it's expensive to hire a professional to do the job, wait until you hire an amateur. --Red Adair -- http://mail.python.org/mailman/listinfo/python-list
Re: Certificate validation with HTTPSConnection
In article 4ca3a46b.4080...@animats.com, John Nagle na...@animats.com wrote: http://bugs.python.org/issue1589 (2010: Developer Bill Jansen in denial, others disagree. Currently being debated. See bug tracker.) While I agree with you that SSL ended up being rather a cluster, I think that using scare quotes around a person's name is insulting and not appropriate. That goes triple if you misspell their name. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ If you think it's expensive to hire a professional to do the job, wait until you hire an amateur. --Red Adair -- http://mail.python.org/mailman/listinfo/python-list
Re: minimal D: need software testers
[posted e-mailed] In article 43bd55e3-e924-40b5-a157-b57ac8544...@f25g2000yqc.googlegroups.com, Kruptein darragh@gmail.com wrote: I've released the second alpha for minimal-D a program I've written in python which should make developing easier. I need people to test the app on bugs and give ideas. You should probably explain what minimal-D is, I'm certainly not going to look at something when I have no clue. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ If you think it's expensive to hire a professional to do the job, wait until you hire an amateur. --Red Adair -- http://mail.python.org/mailman/listinfo/python-list
Re: Introducing Kids to Programming: 2 or 3?
[posted e-mailed] [chiming in late] In article mailman.1095.1285602516.29448.python-l...@python.org, Marco Gallotta ma...@gallotta.co.za wrote: I'm sure you get a lot of 2 or 3 questions, but here's another. Umonya [1] uses Python to introduce school kids to programming. The initiative is only 15 months old and up till now we've been using existing notes and exercises and thus Python 2. But we're at the stage where we can either stick with 2 for the next few years, or go to 3 now. We received a grant from Google to reach 1,000 kids in South Africa with our course in 2011. People have also shown interest in running the course in Croatia, Poland and Egypt. We're also eyeing developing African countries in the long-term. As such, we're taking the time now to write our very own specialised course notes and exercises, and we this is why we need to decide *now* which path to take: 2 or 3? As we will be translating the notes we'll probably stick with out choice for the next few years. One reason not otherwise mentioned is that overall Unicode support is better in Python 3, and given your international audience, that's a strong point in favor of Python 3. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ If you think it's expensive to hire a professional to do the job, wait until you hire an amateur. --Red Adair -- http://mail.python.org/mailman/listinfo/python-list
Re: Classes in a class: how to access variables from one in another
In article 4cbcca47$0$29979$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: I'm sorry, I don't see that language Foo programmers will be surprised that Python is not language Foo is an argument against Python programmers using nested classes. Surely it's an argument against writing Foo in Python? Maybe, but there's no reason for posting that ten times! ;-) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ If you think it's expensive to hire a professional to do the job, wait until you hire an amateur. --Red Adair -- http://mail.python.org/mailman/listinfo/python-list
Re: Design: Module interface vs. library interface
In article 4c8b8123.80...@sschwarzer.net, Stefan Schwarzer sschwar...@sschwarzer.net wrote: Which approach would you prefer and why? Or some other approach? Would you use a different approach if the library-internal class was named `_FTPFile` instead of `FTPFile`? If it's not a public class, it should have been named `_FTPFile`. When your class isn't public, it doesn't matter much exactly how you expose it internally. (I essentially never use __all__ myself, but I don't write libraries for public consumption.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ If you think it's expensive to hire a professional to do the job, wait until you hire an amateur. --Red Adair -- http://mail.python.org/mailman/listinfo/python-list
[issue10044] small int optimization
Changes by Aahz a...@pythoncraft.com: -- nosy: -Aahz, aahz ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10044 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9800] Fast path for small int-indexing of lists and tuples
Aahz a...@pythoncraft.com added the comment: Wasn't me! And I've spent too little time on python-dev lately to remember stuff like this. :-( -- nosy: +Aahz ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9800 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Help needed with Windows Service in Python
In article mailman.376.1283440944.29448.python-l...@python.org, Ian Hobson i...@ianhobson.co.uk wrote: I am attempting to create a Windows Service in Python. BTW, you probably want to subscribe to http://mail.python.org/mailman/listinfo/python-win32 -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ If you think it's expensive to hire a professional to do the job, wait until you hire an amateur. --Red Adair -- http://mail.python.org/mailman/listinfo/python-list
Re: C++ - Python API
In article mailman.334.1283373081.29448.python-l...@python.org, Thomas Jollans tho...@jollybox.de wrote: On Wednesday 01 September 2010, it occurred to Markus Kraus to exclaim: So the feature overview: First, the obligatory things you don't want to hear: Have you had a look at similar efforts? A while ago, Aahz posted something very similar on this very list. You should be able to find it in any of the archives without too much trouble. You almost certainly have me confused with someone else -- I wouldn't touch C++ with a ten-meter pole if I could possibly help it. (The last time I dealt with C++ code, about a decade ago, I just rewrote it in C.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a -- http://mail.python.org/mailman/listinfo/python-list
Re: This Is International Don’t-Squawk-Like-A -Parrot Day
In article mailman.878.1284897801.29448.python-l...@python.org, Tim Chase python.l...@tim.thechases.com wrote: On 09/18/10 23:46, Lawrence D'Oliveiro wrote: Do your bit to help stamp out parrocy. Did you send this by mistake? It looks like a parroty-error. I think it's a bit off... Agh! -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a -- http://mail.python.org/mailman/listinfo/python-list
Down with tinyurl! (was Re: importing excel data into a python matrix?)
In article mailman.343.1283384585.29448.python-l...@python.org, geremy condra debat...@gmail.com wrote: On Wed, Sep 1, 2010 at 4:35 PM, patrick mcnameeking pmcnameek...@gmail.com wrote: I've been working with Python now for about a year using it primarily for scripting in the Puredata graphical programming environment. I'm working on a project where I have been given a 1000 by 1000 cell excel spreadsheet and I would like to be able to access the data using Python. Does anyone know of a way that I can do this? http://tinyurl.com/2eqqjxv Please don't use tinyurl -- it's opaque and provides zero help to anyone who might later want to look it up (and also no accessibility if tinyurl ever goes down). At the very least, include the original URL for reference. (Yes, I realize this is probably a joke given the smiley I excised, but too many people do just post tinyurl.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a -- http://mail.python.org/mailman/listinfo/python-list
Re: C++ - Python API
In article mailman.882.1284906611.29448.python-l...@python.org, Thomas Jollans tho...@jollybox.de wrote: On Sunday 19 September 2010, it occurred to Aahz to exclaim: In article mailman.334.1283373081.29448.python-l...@python.org, Thomas Jollans tho...@jollybox.de wrote: On Wednesday 01 September 2010, it occurred to Markus Kraus to exclaim: So the feature overview: First, the obligatory things you don't want to hear: Have you had a look at similar efforts? A while ago, Aahz posted something very similar on this very list. You should be able to find it in any of the archives without too much trouble. You almost certainly have me confused with someone else -- I wouldn't touch C++ with a ten-meter pole if I could possibly help it. (The last time I dealt with C++ code, about a decade ago, I just rewrote it in C.) Sorry about that. No biggie, just wanted to prevent further confusion. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a -- http://mail.python.org/mailman/listinfo/python-list
Re: Down with tinyurl! (was Re: importing excel data into a python matrix?)
In article mailman.897.1284944085.29448.python-l...@python.org, Philip Semanchuk phi...@semanchuk.com wrote: Some email systems still insert hard line breaks around the 72 or 80 column mark and as a result long URLs get broken. I hope anyone on this list would be able to surgically repair a broken URL, but I email plenty of people who can't and tinyurl friends are really helpful in that context. There's no reason you can't cater to that problem by using tinyurl *in* *addition* to the full regular URL. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a -- http://mail.python.org/mailman/listinfo/python-list
Re: compile Py2.6 on SL
In article 4c934f3c$0$5417$ba4ac...@reader.news.orange.fr, Michel Claveau - MVP enleverlesx_xx...@xmclavxeaux.com.invalid wrote: SL (SilverLight) is a library/techno who give functions. You cannot compile Python on SL (SilverLight). SL (Snow Leopard) is a popular platform for Python development. I suppose this is another argument against TLAs. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for Python and Python/Django workplaces in Chicago
In article 894aa094-70c8-4c0e-b2c6-f2b783f68...@l20g2000yqe.googlegroups.com, Erik Reppen erik.rep...@gmail.com wrote: I'm a really strong front end web dev with an interest in becoming more of a generalist web and app dev through Python. Anybody aware of studios/agencies that actually prefer Python in Chicago I could keep an eye on. Nobody else has responded, so I'll just refer you to the usual job boards, including http://www.python.org/community/jobs/ -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ [on old computer technologies and programmers] Fancy tail fins on a brand new '59 Cadillac didn't mean throwing out a whole generation of mechanics who started with model As. --Andrew Dalke -- http://mail.python.org/mailman/listinfo/python-list
Re: WMI in Python
In article add6a0b4-2fa5-4aec-ae44-57a4a9a13...@13g2000prf.googlegroups.com, KING LABS kinglabs...@gmail.com wrote: I would like to collect the complete information of system hardware and also software installed from registry and add/remove program and feed this data into database. You should subscribe to the win32 mailing list: http://mail.python.org/mailman/listinfo/python-win32 Before you ask questions there, do a bit of searching first -- there are lots of examples. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ [on old computer technologies and programmers] Fancy tail fins on a brand new '59 Cadillac didn't mean throwing out a whole generation of mechanics who started with model As. --Andrew Dalke -- http://mail.python.org/mailman/listinfo/python-list
Re: How Python works: What do you know about support for negative indices?
In article 87r5gz93sv@benfinney.id.au, Ben Finney ben+pyt...@benfinney.id.au wrote: Neil Hodgson nhodg...@bigpond.net.au writes: There appear to be deliberate wraps at sentence end or automatic wraps to fit 80 columns. The automatic wraps in the code presented in the message are wrong. The automatic wraps in the bullet point list are, if not wrong, at least presumably unintended. That is considerably different from your original claim that the post contained formatting that was long-short-long-short, aka comb formatting. I hope that clears up what I meant in this case. The effort devoted to explaining this issue far outweighs the burden it caused initially. I'll try to be more explicit when presenting it in future, to forestall this. s/explicit/accurate/ Had you noted that some lines of code were wrapped short, I would have agreed with you, but I also would have noted that it's not a big deal. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ [on old computer technologies and programmers] Fancy tail fins on a brand new '59 Cadillac didn't mean throwing out a whole generation of mechanics who started with model As. --Andrew Dalke -- http://mail.python.org/mailman/listinfo/python-list
Re: Anyone using python on Mint Linux ?
In article ok2r86lfacmm53ah75843khja94kjpd...@4ax.com, Dave WB3DWE wrote: Just read that Mint is a fine version of Debian Linux. Any comments about python on this ? Why would there be? Either it works or it's broken, and given that it's Debian, I'd certainly bet that Python works. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ [on old computer technologies and programmers] Fancy tail fins on a brand new '59 Cadillac didn't mean throwing out a whole generation of mechanics who started with model As. --Andrew Dalke -- http://mail.python.org/mailman/listinfo/python-list
Re: How Python works: What do you know about support for negative indices?
In article 87vd6d84f7@benfinney.id.au, Ben Finney ben+pyt...@benfinney.id.au wrote: Ben Finney ben+pyt...@benfinney.id.au writes: Raymond Hettinger pyt...@rcn.com writes: It doesn't seem to be common knowledge when and how a[x] gets translated to a[x+len(x)]. So, here's a short info post on how Python supports negative indices for sequences. Thanks for this. Could you post your messages using a channel that doesn't arbitrarily split your paragraphs into long-short-long-short lines? It makes paragraphs burdensome to read, and I skipped most of the message because of that. For those who think the problem may be with the recipient's software, I see the same annoying line-wrapping problems in the archived message URL:http://mail.python.org/pipermail/python-list/2010-September/1255167.html. Still looks like *your* problem to me; except for exactly one paragraph, I don't see comb-style formatting in Lynx at that URL. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ [on old computer technologies and programmers] Fancy tail fins on a brand new '59 Cadillac didn't mean throwing out a whole generation of mechanics who started with model As. --Andrew Dalke -- http://mail.python.org/mailman/listinfo/python-list
Re: palindrome iteration
In article mailman.103.1282914852.29448.python-l...@python.org, Dave Angel da...@ieee.org wrote: def is_palindrom(s): s = s.lower() return s == s[::-1] To deal with real palindromes such as, Madam, I'm Adam, you should probably strip all spaces and punctuation: # untested pat = re.compile(r'[a-z]') def is_palindrome(s): letters = pat.findall(s.lower()) return letters == reversed(letters) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ [on old computer technologies and programmers] Fancy tail fins on a brand new '59 Cadillac didn't mean throwing out a whole generation of mechanics who started with model As. --Andrew Dalke -- http://mail.python.org/mailman/listinfo/python-list
Re: How Python works: What do you know about support for negative indices?
In article mailman.634.1284115580.29448.python-l...@python.org, Daniel Fetchinson fetchin...@googlemail.com wrote: Attribution missing: I encourage anyone whose messages are munged like that to seek correction from their mail service provider, and switch to a different one until it's fixed. I encourage anyone who has problems with reading various emails, newsgroup postings, forums and what not, to start using modern tools that work with the vast majority of other tools. Why? Raymond's post worked fine for me with trn3.6 -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ [on old computer technologies and programmers] Fancy tail fins on a brand new '59 Cadillac didn't mean throwing out a whole generation of mechanics who started with model As. --Andrew Dalke -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with simple multiprocessing script on OS X
In article e4fd2b01-bfde-4614-a2df-50a8de980...@f6g2000yqa.googlegroups.com, Darren Dale dsdal...@gmail.com wrote: About a year ago, I contributed a patch to h5py which checks to see if h5py is being imported into an active IPython session. If so, then a custom tab completer is loaded to make it easier to navigate hdf5 files. In the development version of IPython, a function that used to return None if there was no instance of an IPython interactive shell now creates and returns a new instance. This was the cause of the error I was reporting. Hoist on your own petard, eh? ;-) Thanks for reporting the solution. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ ...if I were on life-support, I'd rather have it run by a Gameboy than a Windows box. --Cliff Wells -- http://mail.python.org/mailman/listinfo/python-list
Re: Confused about nested scopes and when names get added to namespaces
In article d020e332-f2f2-4a82-ae1b-2ae071211...@n3g2000yqb.googlegroups.com, Russell Warren russandheat...@gmail.com wrote: def test4(): print running test4... x = 1 def innerFunc(): print inner locals():, print %s % locals() # how is x in locals in this case?? print x x = 2 #ONLY ADDED LINE TO TEST3 innerFunc() print x left as %s\n % x In this case I get UnboundLocalError: local variable 'x' referenced before assignment. I think this means that the compiler (prior to runtime) inspected the code, determined I will do an assignment, decided _not_ to bring the parent's x into the local namespace, and as a result caused the unbound name problem at runtime. Bingo! It seems that the parent's x is brought directly into the local namespace (when appropriate), rather than the namespace lookup just moving up the hierarchy when not found. This is confusing to me and is making me question my understanding of namespace lookups. Are nested scopes a special case where the lookup is handled differently? What if I want to change the value of the parent's x? test4 implies that I can't. You need Python 3.x and the nonlocal keyword. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ [on old computer technologies and programmers] Fancy tail fins on a brand new '59 Cadillac didn't mean throwing out a whole generation of mechanics who started with model As. --Andrew Dalke -- http://mail.python.org/mailman/listinfo/python-list
Re: cPickle segfault with nested dicts in threaded env
In article mailman.583.1283975836.29448.python-l...@python.org, Thomas Jollans tho...@jollybox.de wrote: Also, Python 2.5 is frightfully old. [...] Frightfully??? I'm sure plenty of people are still using Python 2.3 in production environments (certainly my last job did as of 1.5 years ago, and I would be mildly surprised if they upgraded by now). -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ [on old computer technologies and programmers] Fancy tail fins on a brand new '59 Cadillac didn't mean throwing out a whole generation of mechanics who started with model As. --Andrew Dalke -- http://mail.python.org/mailman/listinfo/python-list
Re: Speed-up for loops
In article o4oho.85508$za5.26...@newsfe16.ams2, BartC ba...@freeuk.com wrote: Steven D'Aprano steve-remove-t...@cybersource.com.au wrote in message news:4c85adfe$0$5$c3e8...@news.astraweb.com... xrange = range There, that wasn't hard, was it? I think I just learned more about Python than from months of reading this group. So 'range' is just a class like any other. And that a class is something you can blithely copy from one variable to another. And whenever you see 'range' anywhere, you can't always be certain that someone hasn't done: range = 42 at some point. That explains a lot about the difficulties of implementing Python efficiently. (And the xrange=range trick works well thanks.) Actually, range() is a function. But the same point applies, squared -- you really can never know what kind of object is hiding behind a name in the general case. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ ...if I were on life-support, I'd rather have it run by a Gameboy than a Windows box. --Cliff Wells -- http://mail.python.org/mailman/listinfo/python-list
Re: Speed-up for loops
In article roy-0ec6f2.08091107092...@news.panix.com, Roy Smith r...@panix.com wrote: Imagine that you're looking at some code which was written years ago, by people who are no longer around to answer questions. In one place, you see: for i in range(n): blah and in another, you see: for j in xrange(n): blah If you are truly a Python expert, you'll say to yourself, range and xrange are synonyms, and move on to other things. If, however, you're not really an expert, you'll look at this and say, Hmmm, in one place they used range(), and in another they used xrange(). Clearly, there's some reason for the difference, I need to figure out what it is, because that's probably key to my understanding why this code isn't working. So, you spend the next two hours pouring over reference manuals trying to understand the subtle difference, until your friend comes over and says, You dolt, you just wasted half the afternoon. They're the same thing. Move on, this is not the bug you're looking for. ...and if you're a Python guru, you might spend a little bit of time trying to figure out if the range() is causing the problem due to allocating a large chunk of memory -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ ...if I were on life-support, I'd rather have it run by a Gameboy than a Windows box. --Cliff Wells -- http://mail.python.org/mailman/listinfo/python-list
Re: Iterative vs. Recursive coding
In article 4c6e9de9$0$23142$426a7...@news.free.fr, Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: Steven D'Aprano a écrit : On Thu, 19 Aug 2010 22:00:16 +, Martin Gregorie wrote: Recursion can be quite a trick to get your mind round at first Really? Do people actually find the *concept* of recursion to be tricky? I onced worked in a shop (Win32 desktop / accouting applications mainly) where I was the only guy that could actually understand recursion. FWIW, I also was the only guy around that understood hairy (lol) concepts like callback functions, FSM, polymorphism, hashtables, linked lists, ADTs, algorithm complexity etc... To some extent, the question here is the definition of understand being used. It probably would be reasonable to say that I have only a cookbook level understanding of recursion, and the same would apply to callback functions, FSM, linked lists, and so on. (I mostly think I do really understand polymorphism and hashtables.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ ...if I were on life-support, I'd rather have it run by a Gameboy than a Windows box. --Cliff Wells -- http://mail.python.org/mailman/listinfo/python-list
Re: Iterative vs. Recursive coding
In article 4c70344a$0$1659$742ec...@news.sonic.net, John Nagle na...@animats.com wrote: Realistically, recursion isn't that important in Python. It's there if you need it, and sometimes useful, but generally not used much without good reason. In some functional languages, recursion is routinely used in place of iteration, but Python isn't built for that. In Python, most of the use cases for trivial recursion are better handled with iteration or generators. Depends how you define important. It's certainly a critical feature for Python that you *can* use recursion; it's usually the simplest way of walking a tree structure (such as a directory tree). Python would be an extraordinarily limited language if recursion were not available. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ ...if I were on life-support, I'd rather have it run by a Gameboy than a Windows box. --Cliff Wells -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue cleanup
[gc] In article 7x7hj2kyd6@ruckus.brouhaha.com, Paul Rubin no.em...@nospam.invalid wrote: A minimal naive implementation indeed doubles the memory requirements, but from a Python perspective where every integer takes something like 24 bytes already, even that doesn't seem so terrible. Many people still use 32-bit Python -- an int is twelve bytes there. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ ...if I were on life-support, I'd rather have it run by a Gameboy than a Windows box. --Cliff Wells -- http://mail.python.org/mailman/listinfo/python-list
Re: String substitution VS proper mysql escaping
In article bc70e108-f2ca-47b5-93d4-6911dfc3b...@q22g2000yqm.googlegroups.com, =?UTF-8?B?zp3Or866zr/Pgg==?= nikos.the.gr...@gmail.com wrote: After all () used to define tuples and [] usedd to define lists. Why commas? No, () does *not* define tuples, except for the empty tuple. The comma defines tuples, with parentheses simply used for visual effect: 1, 2, 3 (1, 2, 3) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ ...if I were on life-support, I'd rather have it run by a Gameboy than a Windows box. --Cliff Wells -- http://mail.python.org/mailman/listinfo/python-list