Inconsistent site.py behavior between venv and system

2018-04-30 Thread Demian Brecht
I recently ran into an issue using the site package and I wanted to confirm that I'm not doing something wrong here before creating an issue: I have a need to `git subtree` modules into a Django project and then add the dependencies such that they're discoverable in code. I also need to have co

Unified async/sync interface

2018-03-31 Thread Demian Brecht
I might be entirely off my face, but figured I'd ask anyways given I haven't figured out a clean solution to this problem myself yet: I'm trying to write a REST API client that supports both async and synchronous HTTP transports (initially requests and aiohttp). So far, I've tried a few approaches

From git to hg

2014-08-02 Thread Demian Brecht
with potentially more interested people making the same transition) -- Demian Brecht http://demianbrecht.github.com -- https://mail.python.org/mailman/listinfo/python-list

Re: PEP8 and 4 spaces

2014-07-03 Thread Demian Brecht
On Jul 3, 2014 10:31 AM, "Tobiah" wrote: > Just need ammo for when the hammer of code unification comes down. One issue that I've encountered in the past (one of the reasons outside of pep8) that I switched to spaces is when working with libraries other than your own. If you want to stick print s

Token-based authentication (was http.server.BaseHTTPRequestHandler basic auth logout? Django authentication system for REST interface?)

2014-06-07 Thread Demian Brecht
On Jun 6, 2014 6:30 PM, "Roy Smith" wrote: > We would have to keep state on the server side about every extant valid > token (but then again, we need to do that now, for each session). If you didn't want to have to manage such state server side, you could opt to use JWTs (http://datatracker.ietf.

Re: How to use SQLite (sqlite3) more efficiently

2014-06-04 Thread Demian Brecht
> > On Thu, Jun 5, 2014 at 6:27 AM, ps16thypresence wrote: > > > > I'm completely new to SQL, and recently started using SQLite in > > > one of my Python programs. Unrelated to Python but as you're new to SQL I figured I'd ask: Do you have an index on the name field? If you don't, you'll incur a f

[ANN] JOSE

2014-04-16 Thread Demian Brecht
by the JOSE framework. Code: https://github.com/Demonware/jose Docs: http://jose.readthedocs.org/en/latest PyPI: https://pypi.python.org/pypi/jose -- Demian Brecht http://demianbrecht.github.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Using a subclass for __dict__

2014-02-13 Thread Demian Brecht
__setattr__() in the class becomes easy once you > remember that a class is just > an instance of its metaclass *Throws keyboard across the office* FFS. I could have SWORN I tried that (because I /know/ that a class is an instance of its metaclass :/). An instance of looking at somethin

Using a subclass for __dict__

2014-02-13 Thread Demian Brecht
>>> f.foo = 'bar' Bar.__setattr__ # expected >>> test.Foo.foo = 'bar' # I'm expecting Dict.__setattr__ here, but... *crickets* Am I missing something here, or do I just have to live with what I currently have in my gist? Thanks, -- Demian Brecht http://demianbrecht.github.com -- https://mail.python.org/mailman/listinfo/python-list

ABC hackery

2013-12-12 Thread Demian Brecht
recommended for anything outside of POC :) -- Demian Brecht http://demianbrecht.github.com -- https://mail.python.org/mailman/listinfo/python-list

ANN: stepford 0.1 release

2013-11-20 Thread Demian Brecht
possible for apps requiring integration with the Facebook Graph API. Stepford is a Python implementation of the Facebook test user API as defined at https://developers.facebook.com/docs/test_users. Documentation can be found at: http://pythonhosted.org/stepford/ -- Demian Brecht http

Re: Conditional breakpoints in ceval.c

2013-11-12 Thread Demian Brecht
an aside, this has definitely been one of the more interesting digs that I've taken at Python and has been quite enjoyable and fulfilling (my /god/ I'm a nerd ;)). You never /can/ really push the boundaries with your tools without wholly understanding them. -- Demian Brecht http://demianbrecht.github.com -- https://mail.python.org/mailman/listinfo/python-list

Conditional breakpoints in ceval.c

2013-11-08 Thread Demian Brecht
ing that? b ceval.c:1368 if [?] Thanks, -- Demian Brecht http://demianbrecht.github.com -- https://mail.python.org/mailman/listinfo/python-list

Class construction

2013-10-21 Thread Demian Brecht
this point so expert insight would help :) Thanks, -- Demian Brecht http://demianbrecht.github.com -- https://mail.python.org/mailman/listinfo/python-list

Metaclass/abc hackery

2013-10-11 Thread Demian Brecht
'd be able to get rid of the late_bind function if something like that's available... Not likely something that would be used very often, but would likely sometimes be useful. Thanks, -- *Demian Brecht *http://demianbrecht.github.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Digging into multiprocessing

2013-08-14 Thread Demian Brecht
Awesome, thanks for the detailed response Chris. On Tue, Aug 13, 2013 at 8:03 AM, Chris Angelico wrote: > On Tue, Aug 13, 2013 at 12:17 AM, Demian Brecht > wrote: >> Hi all, >> >> Some work that I'm doing atm is in some serious need of >> parallelization.

Digging into multiprocessing

2013-08-12 Thread Demian Brecht
ect, or am I just off my rocker? Thanks, -- Demian Brecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: What was the project that made you feel skilled in Python?

2013-05-20 Thread Demian Brecht
eel independent and skilled? What program first felt like your > own work rather than an exercise the teacher had assigned? > > I don't want anything too large, but big enough that there's room for > design, and multiple approaches, etc. > > Thanks in advance

[ANN] flask-canvas

2013-05-09 Thread Demian Brecht
A Flask extension for Facebook canvas-based applications. https://github.com/demianbrecht/flask-canvas Docs available on RTD: https://flask-canvas.readthedocs.org/en/latest/ -- Demian Brecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: im.py: a python communications tool

2013-04-08 Thread Demian Brecht
> the point of view of a judge, rather than a lawyer. Like the sheriff > says: "I make the law around here!" lol. > > Mark > -- > http://mail.python.org/mailman/listinfo/python-list -- Demian Brecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: im.py: a python communications tool

2013-04-05 Thread Demian Brecht
Thanks for sharing some of your work with the community. However... Speaking to the sharing aspect: Why would you post a block of code in an email? If you're looking for people to contribute, it would likely be a much better idea to post it on github (which was built for collaborative work). As f

Re: Tkinter

2013-04-02 Thread Demian Brecht
do you not understand? Questions with that kind of information and showing that you've done /some/ work will likely get you helpful answers. -- Demian Brecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Breaking into descriptors

2013-02-28 Thread Demian Brecht
rying it in a newly created term, cannot repro it. Gremlins. -- Demian Brecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows

2013-02-24 Thread Demian Brecht
For the record, I completely misread and misunderstood the question. I should stop posting that late at night :P On Sun, Feb 24, 2013 at 1:25 AM, Demian Brecht wrote: > Rather than using a relative path, try using > webbrowser.open('{}/documentation/help.html'.format(os.path.

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows

2013-02-24 Thread Demian Brecht
e web and > does a Google search, returning nothing but useless noise. > > My default browser on Windows is Chrome, so my intention is getting > undermined right from the start. > > How do I get a local html file to open properly from Python in Windows? > -- > http://mail.python.

Re: backporting PEP 3134 "Exception Chaining and Embedded Tracebacks" to Python 2.7

2013-02-19 Thread Demian Brecht
Zero. There are no new features being added to 2.7. Demian Brecht http://demianbrecht.github.com On 2013-02-19 12:54 PM, "Piotr Dobrogost" wrote: >Hi! > >What is a chance of backporting PEP 3134 "Exception Chaining and Embedded >Tracebacks" to Python 2.7

Re: buffers and memoryviews

2013-02-12 Thread Demian Brecht
I guess I /should/ have written it with current releases.. My 3 is current dev source :P Demian Brecht http://demianbrecht.github.com On 2013-02-12 7:42 AM, "MRAB" wrote: >On 2013-02-12 15:25, Demian Brecht wrote: >> I didn't know a whole lot (read: nothing) about

buffers and memoryviews

2013-02-12 Thread Demian Brecht
t. In this post, I hope to give the reader a brief overview of what each is, detail some of the ugliness in 2.7 and provide useful information for those wanting to incorporate them into their work. http://demianbrecht.github.com/posts/2013/02/10/buffer-and-memoryview/ Demian Brecht

Re: memoryview (was "len() on mutables vs. immutables")

2013-02-08 Thread Demian Brecht
This helped clarify, thanks. I also went through PEP 3118 in detail (as I should have in the first place) which also helped. Thanks, Demian Brecht http://demianbrecht.github.com On 2013-02-08 6:50 AM, "Oscar Benjamin" wrote: >This is in keeping with the way that numpy.

memoryview (was "len() on mutables vs. immutables")

2013-02-07 Thread Demian Brecht
On 2013-02-07 8:30 PM, "Terry Reedy" wrote: >So you may assume I've been bitten far too many times by incorrect assumptions about implementations that ended up actually doing something quite silly. Having said that, I felt fairly safe in making that assumption with Python, but figured I'd write s

Re: len() on mutables vs. immutables

2013-02-07 Thread Demian Brecht
t seems to be reporting the shape of the 0th dim at the moment.. Or is there something that I'm missing altogether? Thanks, Demian Brecht http://demianbrecht.github.com On 2012-10-18 5:26 PM, "Terry Reedy" wrote: >On 10/18/2012 2:42 PM, Demian Brecht wrote: > >> Awesom

Re: Curious to see alternate approach on a search/replace via regex

2013-02-07 Thread Demian Brecht
On 2013-02-06 7:04 PM, "Steven D'Aprano" wrote: >I dispute those results. I think you are mostly measuring the time to >print the result, and I/O is quite slow. Good call, hadn't even considered that. >My tests show that using urlparse >is 33% faster than using regexes, and far more understanda

Re: Curious to see alternate approach on a search/replace via regex

2013-02-06 Thread Demian Brecht
python -m cProfile [script_name].py http://docs.python.org/2/library/profile.html#module-cProfile Demian Brecht http://demianbrecht.github.com On 2013-02-06 2:30 PM, "richard_hubbe11" wrote: >I see that urlparse uses split and not re at all and, in my tests, >urlparse &g

Re: Curious to see alternate approach on a search/replace via regex

2013-02-06 Thread Demian Brecht
parts.query.replace('&', '_').replace('=', '_') ) Although with the result of: alongnameofasite1234567_com_q_sports_run_a_1_b_1 1288 function calls in 0.004 seconds Compared to regex method: 498 function calls (480 primitive calls) in

ANN - "bold", a Pelican theme

2013-02-04 Thread Demian Brecht
Looking for a new Pelican theme? Look no further than https://github.com/demianbrecht/pelican-bold Still a little rough around the edges, feel free to fork and contribute. (Using it for my personal blog, and yes, I'm very much aware that the content needs some lovin' :)) Demian B

Re: Thought of the day

2013-01-14 Thread Demian Brecht
Š And I hope you don't mindŠ I may very well "borrow" this as my e-mail sig. Comedic gold imo. Demian Brecht http://demianbrecht.github.com On 2013-01-13 8:16 PM, "Steven D'Aprano" wrote: >A programmer had a problem, and thought Now he has "I know, I&#x

Re: Thought of the day

2013-01-14 Thread Demian Brecht
I love getting that "what's up with this guy" when I start chuckling so hard that I nearly spit out my coffee first thing Monday morning. Thank you sir, this has given my week a bright start :) Demian Brecht http://demianbrecht.github.com On 2013-01-13 8:16 PM, "Steven D

Re: unpacking first few items of iterable

2012-12-13 Thread Demian Brecht
If you're using python3, you can simply do: a, b, c, *rest = myiterable Demian Brecht http://demianbrecht.github.com On 2012-12-13 11:37 AM, "Daniel Fetchinson" wrote: >Hi folks, I swear I used to know this but can't find it anywhere: > >What's the stan

Re: Lazy Attribute

2012-11-16 Thread Demian Brecht
o come up with their own implementations on a bi-weekly > basis, I am seriously wondering how to improve its visibility. Putting it on > PyPI alone does not cut it, apparently. This was a good start ;) Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.

Re: Invalid syntax

2012-11-07 Thread Demian Brecht
], MAT[0], TSD[0], AnnTMin[0], ANNPREC[0], float(collection[i][2]), float(collection[i][1])) Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi-dimensional list initialization

2012-11-06 Thread Demian Brecht
cy. As everything in Python is a reference, it would seem to me to be inconsistent to treat expressions such as [[obj]*4]*4 un-semantically (Pythonically speaking) and making it *less* intuitive. I agree that Python would definitely be worse off. Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi-dimensional list initialization

2012-11-05 Thread Demian Brecht
one is immutable.. *That's* gotta be why"). Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi-dimensional list initialization

2012-11-05 Thread Demian Brecht
On 2012-11-04, at 10:44 PM, Andrew Robinson wrote: > but I think you meant: > > m = [[None] * 4, [None] * 4, [None] * 4, [None] *4 ] > rather than: > m = [[None] * 4, [None] * 4, [None] * 4, [None * 4]] Yes, I meant the former, thanks for catching the typo. Demian Brecht @de

Re: No more Python support in NetBeans 7.0

2012-11-04 Thread Demian Brecht
On 2012-11-04, at 4:45 PM, bkube...@gmail.com wrote: > However I am not happy about having to use different IDEs as I find myself > coding in both python and php from project to project. One of the many reasons Vim is my editor of choice. Demian Brecht @demianbrech

Multi-dimensional list initialization

2012-11-04 Thread Demian Brecht
None, None], ['m', None, None, None]] Is this expected behaviour and if so, why? In my mind either result makes sense, but the inconsistency is what throws me off. Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: OT Questions

2012-10-28 Thread Demian Brecht
> > You haven't been on lists long enough then to have seen some real > flame warts...no offense. No offense taken, it's why I said it in the first place ;) Having said that, generally engaging in flame wars solves nothing and sheds a negative light on the individuals who take part in it. > It

Re: Shipping python modules - best practices?

2012-10-27 Thread Demian Brecht
ticular project requirements. On 2012-10-27, at 2:39 PM, Demian Brecht wrote: > 1) IMHO, these should be two distinct steps. You will definitely want to run > unit tests without sdist and likewise, I'm sure you'll want to sdist without > unit tests. Personally, if I wanted to comb

Re: Shipping python modules - best practices?

2012-10-27 Thread Demian Brecht
on with pydoc. How shall I distribute it > with the module? > > Thank you very much in advance. > > Regards > rambius > -- > http://mail.python.org/mailman/listinfo/python-list Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: SSH Connection with Python

2012-10-25 Thread Demian Brecht
I've heard nothing but good things about it. Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: turn list of letters into an array of integers

2012-10-24 Thread Demian Brecht
On 2012-10-24, at 10:27 AM, wxjmfa...@gmail.com wrote: > Not so sure what you mean by an "array of integers". I wasn't entirely sure about that either. I assumed given the subject that it was just a 1-D array and could then be accessed by arr[(y * width) + x]. Demian Brecht

Re: Appending a list using list obtained from a class

2012-10-24 Thread Demian Brecht
t if i print the same in the same > loop its showing me numbers which i want. Why I dont know ?? If you can, please post the relevant blocks of code. That'll be a tremendous help in figuring out your problem. Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mai

Re: Appending a list using list obtained from a class

2012-10-24 Thread Demian Brecht
u're asking how to do.. Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Appending a list using list obtained from a class

2012-10-24 Thread Demian Brecht
patibility (see the docs: http://docs.python.org/release/2.3/lib/module-UserList.html) Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: turn list of letters into an array of integers

2012-10-23 Thread Demian Brecht
nd list iteration. K, I'm going to sleep now. :P Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: turn list of letters into an array of integers

2012-10-23 Thread Demian Brecht
On 2012-10-23, at 10:45 PM, Demian Brecht wrote: >>>> list_ = [d[c] for c in s.strip('\n').split()] >>>> list_ > ['1', '2', '1', '2', '2', '1'] Of course, if you want these to be ints, then you

Re: turn list of letters into an array of integers

2012-10-23 Thread Demian Brecht
#x27;b b a\n'] >>> s = ' '.join(L) >>> d = dict(zip(alpha, numeric)) >>> list_ = [d[c] for c in s.strip('\n').split()] >>> list_ ['1', '2', '1', '2', '2', '1'] Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Demian Brecht
nt), > 'w') Use with: with open('file path', 'w') as f: f.write('data') Not only is it shorter, but it automatically closes the file once you've come out of the inner block, whether successfully or erroneously. Demian Brecht @demianbrecht htt

Re: Fast forward-backward (write-read)

2012-10-23 Thread Demian Brecht
r* need more than 640k… Right? Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: A desperate lunge for on-topic-ness

2012-10-19 Thread Demian Brecht
On 2012-10-18, at 6:34 PM, Steven D'Aprano wrote: > Flame away :) This post made my Friday, even though I'm sitting on a nearly two hour bus ride into work because I missed my commuter train. Just wanted you to know ;) You noted *every* reason (and them some) why my own code never passed 79

Re: len() on mutables vs. immutables

2012-10-18 Thread Demian Brecht
On Thu, Oct 18, 2012 at 12:43 PM, Daniel Urban wrote: > The source is usually in Objects/*object.c (e.g., the source for list > is in Objects/listobject.c, dict is in dictobject.c and so on). The > implementation of __len__ is usually in a method called > whatever_length (e.g., dict.__len__ is cal

Re: len() on mutables vs. immutables

2012-10-18 Thread Demian Brecht
On 10/18/2012 11:29 AM, Terry Reedy wrote:> Or the length could be the difference of two pointers -- address of the > first empty slot minus address of first item. That would assume contiguous blocks of memory, which I would find to be rather dangerous (of an assumption that is) in most dynamic

Re: len() on mutables vs. immutables

2012-10-18 Thread Demian Brecht
On 10/18/2012 11:28 AM, Nick Cash wrote: It appears that list has len() complexity of O(1) source: http://wiki.python.org/moin/TimeComplexity It may be worth mentioning that lists in Python are implemented using arrays instead of linked lists. It's reasonable to assume that other built-in colle

len() on mutables vs. immutables

2012-10-18 Thread Demian Brecht
I'm curious as to the implementation (I'd be happy to dig through the source, just don't have the time right now). I've seen various implementations across interpreters in the past (some which have been rather shocking) and I'd like to get some insight into Python (well, CPython at this point a

Re: A desperate lunge for on-topic-ness

2012-10-17 Thread Demian Brecht
> 3. Say "well, at least it's not a backslash" and break the line using > parentheses. This. More times than not, there's a function call in that line, which makes sense to me when reading it if the args are on the next line. > 4. Spend 45 minutes trying to think up shorter [but still sensible] >

Re: OT Questions

2012-10-16 Thread Demian Brecht
> This is my prototype portfolio for freelancing. If you have an honest > critique, then what, in your opinion, am I good at? > > https://www.odesk.com/users/~01710ac049863018eb I can't ascertain what your strengths are as I don't work with you on a daily basis (one of the many benefits of worki

Re: Fastest web framework

2012-10-16 Thread Demian Brecht
On 10/16/2012 7:47 AM, Andriy Kornatskyy wrote: I think that my first batch of questions were slightly out of context, mostly due to a lack of caffeine first thing in the morning. My understanding at the time was that your "an answer to effectivity" was, in fact, a list of highlights for wheezy

Re: OT Questions

2012-10-16 Thread Demian Brecht
On 10/16/2012 8:13 AM, Jean-Michel Pichavant wrote: Search deep inside your heart, and you'll realize you already know the answer to that question :o) JM There's a small light somewhere deep down that says maybe this is just someone quite misdirected. A brief search shows that he has multipl

Re: Which book is the best?

2012-10-16 Thread Demian Brecht
On 10/15/2012 9:27 PM, 老爷 wrote: I have strong c++ development experience. But now I want to study the python to do some windows setting task, such as editing file, changing the system setting, doing some network processing. Please help me which book is the best? Thanks. If you're already a

Re: OT Questions

2012-10-16 Thread Demian Brecht
On 10/15/2012 9:05 PM, Dwight Hutto wrote: Like a lot of people here, I'm trying to build a web development business. I'm starting off by building a profile on a freelance site. I would like some honest opinions(don't be too harsh), about my approach. I'm looking for a team effort to analyze my

Re: Fastest web framework

2012-10-16 Thread Demian Brecht
Let me say right off the bat that I've taken a brief look through the code and documentation and found that I wouldn't mind trying it out for personal projects. So, the intention here is not to slag the framework. > Performance and effectivity are related metrics. Longer feature list can not > ex

Re: MySQL with Python

2012-10-15 Thread Demian Brecht
-python.sourceforge.net/MySQLdb.html. Another solution is to use SQLAlchemy (http://www.sqlalchemy.org/). The ORM abstracts a lot of the tedious SQL queries out for you and allows you to concentrate more on your application's logic. -- Demian Brecht @demianbrecht http://demianbrecht.github.com --

Re: Private methods

2012-10-09 Thread Demian Brecht
On 12-10-09 04:51 PM, Steven D'Aprano wrote: Really? I tend to view name mangling as a waste of time, and complex inheritance structures as something to avoid. Yep, I've been coming around to this as of late. -- Demian Brecht @demianbrecht http://demianbrecht.github.c

Re: Private methods

2012-10-09 Thread Demian Brecht
e the function such that it's only accessible strictly by name through the class that it's define in. Note that you *can* still access it if you understand how name mangling works. Nothing in Python is truly private. -- Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://

Re: Are ABCs an anti-pattern?

2012-10-06 Thread Demian Brecht
rt getting back to un-Pythonic code (pretty subjective statement, I know :)). Again, please don't misunderstand my intentions here. I'm not arguing the need for abstract base classes in a strict OOP world. I'm arguing them as not genuinely being Pythonic. Tha

Re: How to create a login screen using core python language without using any framework

2012-10-05 Thread Demian Brecht
L injection As well as others. For a comprehensive list of protection that Django offers, check out https://docs.djangoproject.com/en/dev/topics/security/. -- Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Are ABCs an anti-pattern?

2012-10-03 Thread Demian Brecht
> > > ABCs were added (fairly recently) in 3.0 for the reasons given in > http://python.org/dev/peps/**pep-3119/ > It was expected that it would take awhile for them to see good, pythonic > uses. We obviously did okay without them up to 2.7. > I read the PEP b

Re: local variable 'a' referenced b

2012-10-03 Thread Demian Brecht
> > One problem with short examples is they mask the reason for the code to > be structured that way. > > Couldn't agree more (I don't think I've ever written a nested function outside a closure). I made the assumption that the OP wasn't asking about closures based on his code samples. In hindsight

Re: local variable 'a' referenced b

2012-10-02 Thread Demian Brecht
to another module, then you don't have to worry about documenting the side effects on 'a' so users (including yourself) aren't confused later: >>> def foo(): ... a = 1 ... def bar(n): ... b = 2 ... return n + b ... a = bar(a) ...

Re: unit testing class hierarchies

2012-10-02 Thread Demian Brecht
Am I missing something? Is there something that wasn't answered by my reply about using mixins? from unittest import TestCase class SharedTestMixin(object): def test_shared(self): self.assertNotEquals('foo', 'bar') class TestA(TestCase, SharedTestMixin): def test_a(self):

Re: unit testing class hierarchies

2012-10-02 Thread Demian Brecht
Am I missing something? Is there something that wasn't answered by my reply about using mixins? from unittest import TestCase class SharedTestMixin(object): def test_shared(self): self.assertNotEquals('foo', 'bar') class TestA(TestCase, SharedTestMixin): def test_a(self):

Are ABCs an anti-pattern?

2012-10-02 Thread Demian Brecht
anti-pattern in the Python world. The concept is obviously essential in non-duck-typed language using strict OOP, but does it *really* belong in Python? -- Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: unit testing class hierarchies

2012-10-02 Thread Demian Brecht
[1] in C++ I would call that a "mixin" Mixins are perfectly valid Python constructs as well and are perfectly valid (imho) for this use case. On a side note, I usually append a "Mixin" suffix to my mixin classes in order to make it obvious to the reader. -- Demian

Re: creating an artificial "last element" in sort list

2012-09-28 Thread Demian Brecht
On Fri, Sep 28, 2012 at 8:29 PM, Ian Kelly wrote: > The slicing operation in the second line assumes that they're all > collected at the end of the list anyway. > True enough. Hadn't considered otherwise when I first whipped that off with the first example (thinking/trying it out *before* posti

Re: creating an artificial "last element" in sort list

2012-09-28 Thread Demian Brecht
> f = filter(lambda s: s == a[-1], a) That line's assuming that the last element may also be found in arbitrary locations in the list. If it's guaranteed that they're all contiguous at the upper bounds, I'd just walk the list backwards until I found one that wasn't matching rather than filterin

Re: creating an artificial "last element" in sort list

2012-09-28 Thread Demian Brecht
f Now, not 100% sure about efficiency over large sizes of a, but that's a naive stab at it anyway. -- Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: creating an artificial "last element" in sort list

2012-09-28 Thread Demian Brecht
Maybe l = filter(a, lambda v: v == a[-1]) sorted(a[:-len(l)]) + l ? On Fri, Sep 28, 2012 at 4:51 PM, dave wrote: > more clearer, this is a more realistic use case: > > ['awefawef', 'awefawfsf', 'awefsdf', 'zz', 'zz', > 'zz'] > > and the quantity of ''zzz

Re: [fcgi.py] Force cache upgrade?

2012-09-28 Thread Demian Brecht
If you don't have access to restart Apache (or `x` server), then touch fcgi.py *should* work. On Fri, Sep 28, 2012 at 2:57 PM, Gilles wrote: > Hello > > Does someone know if something must be done after editing a FastCGI + > WSGI script so that the changes will show in the browser immediately >

Re: REST code-golf: How concisely can you expose and consume services?

2012-09-28 Thread Demian Brecht
e. One liner. I win ;) I much prefer code golf that tests algorithmic/core language feature knowledge. Of course, that's entirely only my opinion. -- Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: "#!/usr/bin/env python" vs. "#!/usr/bin/python"?

2012-09-28 Thread Demian Brecht
Cygwin, even if Python is installed via Windows installers (as long as it's on system PATH). Tremendously useful if you're bouncing between *nix and Windows regularly. -- Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list

Re: google api and oauth2

2012-09-26 Thread Demian Brecht
Yes, dealing with the embedded web server is out of the scope of the library and not something that I'd want to introduce. Having said that, there wouldn't be any harm in a sanction-embedded library that would add that capability. Thanks for the info. -- http://mail.python.org/mailman/listinfo/pyt

Re: google api and oauth2

2012-09-25 Thread Demian Brecht
> > > If you are writing a desktop application, read this: > https://developers.google.com/accounts/docs/OAuth2#clientside You mean https://developers.google.com/accounts/docs/OAuth2#installed? Your link discusses client side browser implementations. I'd be curious to know the shortcomings of sa

Re: google api and oauth2

2012-09-25 Thread Demian Brecht
This is a shameless plug, but if you want a much easier to understand method of accessing protected resources via OAuth2, I have a 55 LOC client implementation with docs and examples here: https://github.com/demianbrecht/sanction (Google is one of the tested providers with an access example). Are

Re: Python 2.6 and Sqlite3 - Slow

2012-08-27 Thread Demian Brecht
Is there a reason that you're using SQLite in a network environment rather than a database server? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Interview Questions

2012-07-10 Thread Demian Brecht
I also judge candidates on their beards (http://www.wired.com/wiredenterprise/2012/06/beard-gallery/). If the beard's awesome enough, no questions needed. They're pro. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Interview Questions

2012-07-09 Thread Demian Brecht
On Monday, 9 July 2012 10:40:59 UTC-7, Tim Chase wrote: > On 07/09/12 08:25, Roy Smith wrote: > >> On Tuesday, 30 October 2007 21:24:04 UTC+2, Tim Chase wrote: > > > >>> - more detailed questions about the std. libraries (such as > >>>datetime/email/csv/zipfile/networking/optparse/unittest)

RE: OAuth 2.0 implementation

2012-07-06 Thread Demian Brecht
.tayl...@gmail.com] Sent: Friday, July 06, 2012 11:42 AM To: Demian Brecht Cc: comp.lang.pyt...@googlegroups.com; python-list@python.org Subject: Re: OAuth 2.0 implementation On Sat, Jul 7, 2012 at 1:38 AM, Demian Brecht wrote: > Supported provider list (with example code) is now: > * Facebook

Re: OAuth 2.0 implementation

2012-07-06 Thread Demian Brecht
Supported provider list (with example code) is now: * Facebook * Google * Foursquare * bitly * GitHub * StackExchange * Instagram Other providers may also be supported out of the box, but have been untested thus far. -- http://mail.python.org/mailman/listinfo/python-list

Re: OAuth 2.0 implementation

2012-07-05 Thread Demian Brecht
On Thursday, 5 July 2012 08:19:41 UTC-7, Alec Taylor wrote: > On Fri, Jul 6, 2012 at 12:06 AM, Demian Brecht wrote: > > FWIW, this package has undergone a major overhaul (474 LOC down to much > > happier 66) and is available at https://github.com/demianbrecht/sanction. > >

Re: OAuth 2.0 implementation

2012-07-05 Thread Demian Brecht
FWIW, this package has undergone a major overhaul (474 LOC down to much happier 66) and is available at https://github.com/demianbrecht/sanction. Also available from PyPI. -- http://mail.python.org/mailman/listinfo/python-list

Re: OAuth 2.0 implementation

2012-03-27 Thread Demian Brecht
On Tuesday, 27 March 2012 07:18:26 UTC-7, Roy Smith wrote: > In article > <7909491.0.1332826232743.JavaMail.geo-discussion-forums@pbim5>, > Demian Brecht wrote: > > > OAuth 2.0 is still in draft status (draft 25 is the current one I believe) > > and yes, unf

  1   2   >