Re: OAuth 2.0 implementation

2012-03-27 Thread Roy Smith
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, unfortunately every single server available at this point have > varying degrees of separation from the actua

Re: tabs/spaces (was: Re: unittest: assertRaises() with an instance instead of a type)

2012-03-29 Thread Roy Smith
In article <0ved49-hie@satorlaser.homedns.org>, Ulrich Eckhardt wrote: > I didn't consciously use tabs, actually I would rather avoid them. That > said, my posting looks correctly indented in my "sent" folder and also > in the copy received from my newsserver. What could also have an > in

Re: Best way to structure data for efficient searching

2012-04-03 Thread Roy Smith
> On 3/28/2012 11:39 AM, larry.mart...@gmail.com wrote: > > I have a set of data that is contains 3 fields, K1, K2 and a > > timestamp. There are duplicates in the data set, and they all have to > > processed. > > > > Then I have another set of data with 4 fields: K3, K4, K5, and a > > timestamp. T

Re: No os.copy()? Why not?

2012-04-04 Thread Roy Smith
On Tue, 03 Apr 2012 15:46:31 -0400, D'Arcy Cain wrote: > > cp is not a system command, it's a shell command. Why not just use the > > incredibly simple and portable > > > >>>>open("outfile", "w").write(open("infile").read()) In article <4f7be1e8$0$2$c3e8da3$54964...@news.astraweb.com>,

Re: No os.copy()? Why not?

2012-04-04 Thread Roy Smith
In article <87fwcj4zru@dpt-info.u-strasbg.fr>, Alain Ketterlin wrote: > And sparse files are really hard to reproduce, at least on Unix: on > Linux even the system's cp doesn't guarantee sparseness of the copy (the > manual mentions a "crude heuristic"). I imagine the heuristic is to look f

Re: Python Gotcha's?

2012-04-05 Thread Roy Smith
In article <4f7d896f$0$29983$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > > You mean JSON expects a string with valid JSON? Quelle surprise. > > No. The surprise is that there exists a tool invented in the 21st century > that makes a distinction between strings quoted with " a

Re: Python Gotcha's?

2012-04-05 Thread Roy Smith
In article , Grzegorz Staniak wrote: > On 05.04.2012, Roy Smith wroted: > > > There's absolutely no reason why JSON should follow Python syntax > > rules. Making it support either kind of quotes would have > > complicated every JSON library in the world, for no ad

Re: Python Gotcha's?

2012-04-05 Thread Roy Smith
In article , John Gordon wrote: > In <7367295.815.1333578860181.JavaMail.geo-discussion-forums@ynpp8> Miki > Tebeka writes: > > > Greetings, > > > I'm going to give a "Python Gotcha's" talk at work. > > If you have an interesting/common "Gotcha" (warts/dark corners ...) > > please share. >

Re: Python Gotcha's?

2012-04-05 Thread Roy Smith
In article <4f7de152$0$29983$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I'm not the only one who has had trouble with JSON's poor design choice: This is getting a bit off-topic. If you wish to argue that JSON is designed poorly, you should do that in some appropriate JSON f

Re: Python Gotcha's?

2012-04-06 Thread Roy Smith
In article , mwil...@the-wire.com wrote: > rusi wrote: > > > Are there languages (other than python) in which single and double > > quotes are equivalent? > > Kernighan and Plauger's RATFOR (a pre-processor that added some C-like > syntax to FORTRAN) did that. Published in their book _Softwar

Re: Python Gotcha's?

2012-04-08 Thread Roy Smith
In article , John Nagle wrote: > 1. Nobody is really in charge of third party packages. In the > Perl world, there's a central repository, CPAN, and quality > control. Python's "pypi" is just a collection of links. Many > major packages are maintained by one person, and if they lose > intere

Re: f python?

2012-04-09 Thread Roy Smith
In article <4f82d3e2$1$fuzhry+tra$mr2...@news.patriot.net>, Shmuel (Seymour J.) Metz wrote: > >Null terminated strings have simplified all kids of text > >manipulation, lexical scanning, and data storage/communication > >code resulting in immeasurable savings over the years. > > Yeah, especial

Re: [newbie] help with pygame-tutorial

2012-04-09 Thread Roy Smith
In article <1a558398-3984-4b20-8d67-a0807871b...@v1g2000yqm.googlegroups.com>, aapeetnootjes wrote: > I'm trying out the pygame tutorial at > http://www.pygame.org/docs/tut/intro/intro.html > If I try out the code I'm facing an error: > ./game.py: line 4: syntax error at unexpected symbol 'si

Deep merge two dicts?

2012-04-12 Thread Roy Smith
Is there a simple way to deep merge two dicts? I'm looking for Perl's Hash::Merge (http://search.cpan.org/~dmuey/Hash-Merge-0.12/Merge.pm) in Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: Framework for a beginner

2012-04-17 Thread Roy Smith
In article , Bryan wrote: > Django has emphasized backwards compatibility with the > down-side that, last I heard, there was no plan to move to Python 3. Hardly. See https://www.djangoproject.com/weblog/2012/mar/13/py3k/ I agree that Django is probably what the OP should be looking at, for

Re: Framework for a beginner

2012-04-19 Thread Roy Smith
In article <4f8ff38c$0$1381$4fafb...@reader1.news.tin.it>, Kiuhnm wrote: > I don't like when a community imposes style on a programmer. For > instance, many told me that I shouldn't use camelCase and I should > adhere to PEP8. > Well, that's not me. I write my code the way I like it and if tha

How do you refer to an iterator in docs?

2012-04-19 Thread Roy Smith
Let's say I have a function which takes a list of words. I might write the docstring for it something like: def foo(words): "Foo-ify words (which must be a list)" What if I want words to be the more general case of something you can iterate over? How do people talk about that in docstrings

Re: How do you refer to an iterator in docs?

2012-04-20 Thread Roy Smith
In article <4f910c3d$0$29965$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I refer you to your subject line: > > "How do you refer to an iterator in docs?" > > In documentation, I refer to an iterator as an iterator, just as I would > refer to a list as a list, a dict as a dic

Re: why () is () and [] is [] work in other way?

2012-04-20 Thread Roy Smith
In article <877gxajit0@dpt-info.u-strasbg.fr>, Alain Ketterlin wrote: > Tuples are immutable, while lists are not. If you really want to have fun, consider this classic paradox: >>> [] is [] False >>> id([]) == id([]) True -- http://mail.python.org/mailman/listinfo/python-list

Re: How do you refer to an iterator in docs?

2012-04-20 Thread Roy Smith
In article <4f921a2d$0$29965$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Fri, 20 Apr 2012 09:41:25 -0400, Roy Smith wrote: > > > In article <4f910c3d$0$29965$c3e8da3$54964...@news.astraweb.com>, > > Steven D'Aprano wrote: &g

Re: Newbie, homework help, please.

2012-04-21 Thread Roy Smith
In article <32945367.2045.1335029313436.JavaMail.geo-discussion-forums@ynjn4>, someone wrote: I'm not going to do your homework for you (nor do I expect anybody else will), but I'll give you a hint about one sticky part. > 6) Display the SHI data read from the file in the interpreter with a b

Re: Newbie, homework help, please.

2012-04-21 Thread Roy Smith
On 04/21/12 14:44, Roy Smith wrote: > print "* %-*s *" % (max_length, data) On Apr 21, 2012, at 4:12 PM, Tim Chase wrote: > Sounds like a lot more work and less flexible than using the (underemployed) > .ljust() or .center() methods of a string. :-) > > print "

Re: Newbie, homework help, please.

2012-04-21 Thread duncan smith
On 21/04/12 23:48, BartC wrote: "someone" wrote in message news:9533449.630.1335042672358.JavaMail.geo-discussion-forums@ynmf4... On Saturday, April 21, 2012 3:44:49 PM UTC-5, BartC wrote: Hi, Bart: Thank you, your post is working now, maybe, I did something wrong, unfortunately, you are rig

Re: global vars across modules

2012-04-22 Thread Roy Smith
In article <2652842.660.1335123578432.JavaMail.geo-discussion-forums@pbckz3>, mambokn...@gmail.com wrote: > I need to use global var across files/modules: [...] > Question: > How can I access to the global 'a' in file_2 without resorting to the whole > name 'file_1.a' ? Answer 1: You can't. A

Re: global vars across modules

2012-04-22 Thread Roy Smith
In article <11146533.5.1335125285850.JavaMail.geo-discussion-forums@pboo1>, mambokn...@gmail.com wrote: > On Sunday, April 22, 2012 12:48:23 PM UTC-7, Roy Smith wrote: > > > Answer 1: You can't. > > > > Answer 2: You might want to look at thread local s

Re: why () is () and [] is [] work in other way?

2012-04-25 Thread Roy Smith
In article <4f9833ff$0$29965$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Wed, 25 Apr 2012 13:42:31 +0200, Thomas Rachel wrote: > > > Two objects can be equal (=) without being identical (≡), but not the > > other way. > > > >>> x = float('nan') > >>> y = x > >>> x is y

Half-baked idea: list comprehensions with "while"

2012-04-26 Thread Roy Smith
I'm not seriously suggesting this as a language addition, just an interesting idea to simplify some code I'm writing now: x = [a for a in iterable while a] which equates to: x = [] for a in iterable: if not a: break x.append(a) It does has a few things going for it. It doesn't

Re: CPython thread starvation

2012-04-28 Thread Roy Smith
In article <7xy5pgqwto@ruckus.brouhaha.com>, Paul Rubin wrote: > John Nagle writes: > >I may do that to prevent the stall. But the real problem was all > > those DNS requests. Parallizing them wouldn't help much when it took > > hours to grind through them all. > > True dat. But bui

Re: Communication between C++ server and Python app

2012-04-28 Thread Roy Smith
In article <108cb846-6bb9-4600-a984-2fded0c91...@er9g2000vbb.googlegroups.com>, kenk wrote: > Hi, > > I've got a server process written in C++ running on Unix machine. > On the same box I'd like to run multiple Python scripts that will > communicate with this server. > > Can you please sugges

Re: CPython thread starvation

2012-04-29 Thread Roy Smith
In article <7xipgj8vxh@ruckus.brouhaha.com>, Paul Rubin wrote: > Roy Smith writes: > > I agree that application-level name cacheing is "wrong", but sometimes > > doing it the wrong way just makes sense. I could whip up a simple > > cacheing wrap

Expand RFC-2445 (iCalendar) recurrence rule?

2012-05-08 Thread Roy Smith
Does there exist a stand-alone module to expand RFC-2445 recurrence rule? The idea is to start with a string like: "RRULE:FREQ=WEEKLY;COUNT=6;INTERVAL=2;BYDAY=FR" and derive a list of dates on which that event occurs. I'm aware of http://codespeak.net/icalendar/, but that solves a much larger

Re: Expand RFC-2445 (iCalendar) recurrence rule?

2012-05-08 Thread Roy Smith
O.B. Murithi suggested I look at http://labix.org/python-dateutil, which turns out to have exactly what I'm looking for. Thanks! from dateutil.rrule import rrulestr from dateutil.parser import parse rule = rrulestr("FREQ=WEEKLY;COUNT=6;INTERVAL=2;BYDAY=FR", dtstart=parse("2012-0

A question of style (finding item in list of tuples)

2012-05-21 Thread Roy Smith
I've got this code in a django app: CHOICES = [ ('NONE', 'No experience required'), ('SAIL', 'Sailing experience, new to racing'), ('RACE', 'General racing experience'), ('GOOD', 'Experienced racer'), ('ROCK', 'Rock star'), ] def experience_

Re: A question of style (finding item in list of tuples)

2012-05-21 Thread Roy Smith
On Monday, May 21, 2012 9:39:59 AM UTC-4, Jon Clements wrote: > > def experience_text(self): > > return dict(CHOICES).get("self.level", "???") > Haven't used django in a while, but doesn't the model provide a > get_experience_display() method which you could use... Duh, I totally mi

Re: usenet reading

2012-05-26 Thread duncan smith
On 25/05/12 23:38, Jon Clements wrote: Hi All, Normally use Google Groups but it's becoming absolutely frustrating - not only has the interface changed to be frankly impractical, the posts are somewhat random of what appears, is posted and whatnot. (Ironically posted from GG) Is there a serve

Smallest/cheapest possible Python platform?

2012-05-26 Thread Roy Smith
What's the smallest/cheapest/lowest-power hardware platform I can run Python on today? I'm looking for something to use as a hardware controller in a battery-powered device and want to avoid writing in C for this project. Performance requirements are minimal. I need to monitor a few switches,

Re: usenet reading

2012-05-26 Thread Roy Smith
In article , duncan smith wrote: > On 25/05/12 23:38, Jon Clements wrote: > > Hi All, > > > > Normally use Google Groups but it's becoming absolutely frustrating - not > > only has the interface changed to be frankly impractical, the posts are > > some

Re: Smallest/cheapest possible Python platform?

2012-05-26 Thread Roy Smith
In article <8ic799-gk3@chris.zbmc.eu>, tinn...@isbd.co.uk wrote: > > Rasberry Pi is available, some have arrived, mine will arrive on > Monday or Tuesday (I'm talking about UK here). Interesting. Newark is claiming they'll have 1 piece on June 18th, and no further stock until October. htt

Re: Smallest/cheapest possible Python platform?

2012-05-26 Thread Roy Smith
In article <7x1um6928y@ruckus.brouhaha.com>, Paul Rubin wrote: > The Raspberry Pi is not really appropriate for a low powered portable > application anyway, because of relatively high power requirements > compared to an 8 bitter without all that media playback stuff. It sounds like I can r

Re: setup(**config); rookie

2012-05-28 Thread Roy Smith
In article , cate wrote: > I going thru a 101 and came upon this (http:// > learnpythonthehardway.org/book/ex46.html) > > try: > from setuptools import setup > except ImportError: > from distutils.core import setup > > config = { > 'description': 'My Project', > 'author': 'My

Finding all regex matches by index?

2012-05-29 Thread Roy Smith
I have a long string (possibly 100s of Mbytes) that I want to search for regex matches. re.finditer() is *almost* what I want, but the problem is that it returns matching strings. What I need is a list of offsets in the string where the regex matched. Thus: s = "this is a string" find("is",

Re: Finding all regex matches by index?

2012-05-29 Thread Roy Smith
In article , Roy Smith wrote: > I have a long string (possibly 100s of Mbytes) that I want to search for > regex matches. re.finditer() is *almost* what I want, but the problem > is that it returns matching strings. What I need is a list of offsets > in the string where the r

sqlite INSERT performance

2012-05-30 Thread duncan smith
Hello, I have been attempting to speed up some code by using an sqlite database, but I'm not getting the performance gains I expected. The use case: I have text files containing data which may or may not include a header in the first line. Each line (other than the header) is a record,

Re: sqlite INSERT performance

2012-05-31 Thread duncan smith
On 31/05/12 06:15, John Nagle wrote: On 5/30/2012 6:57 PM, duncan smith wrote: Hello, I have been attempting to speed up some code by using an sqlite database, but I'm not getting the performance gains I expected. SQLite is a "lite" database. It's good for data that&

Re: sqlite INSERT performance

2012-05-31 Thread duncan smith
On 31/05/12 17:06, Jon Clements wrote: On Thursday, 31 May 2012 16:25:10 UTC+1, duncan smith wrote: On 31/05/12 06:15, John Nagle wrote: On 5/30/2012 6:57 PM, duncan smith wrote: Hello, I have been attempting to speed up some code by using an sqlite database, but I'm not gettin

Re: Help needed with nested parsing of file into objects

2012-06-04 Thread Roy Smith
In article <6b296278-fd32-45fb-b5c7-6c0fe5ce4...@q2g2000vbv.googlegroups.com>, richard wrote: > Hi guys i am having a bit of dificulty finding the best approach / > solution to parsing a file into a list of objects / nested objects any > help would be greatly appreciated. The first question is

Finding all loggers?

2012-06-14 Thread Roy Smith
Is there any way to get a list of all the loggers that have been defined? So if somebody has done: from logging import getLogger getLogger("foo") getLogger("foo.bar") getLogger("baz") I want something which will give me back ["foo", "foo.bar", "baz"]. -- http://mail.python.org/mailman/listinfo/

Re: Finding all loggers?

2012-06-14 Thread Roy Smith
ogging.Logger.manager.loggerDict > {'foo': , 'bar': > } > > Enjoy, > Michael > > On Thu, Jun 14, 2012 at 5:03 PM, Roy Smith wrote: >> Is there any way to get a list of all the loggers that have been >> defined? So if somebody has done: >&g

Conditional decoration

2012-06-18 Thread Roy Smith
Is there any way to conditionally apply a decorator to a function? For example, in django, I want to be able to control, via a run-time config flag, if a view gets decorated with @login_required(). @login_required() def my_view(request): pass -- http://mail.python.org/mailman/listinfo/python-

Re: how to avoid leading white spaces

2011-06-02 Thread Roy Smith
In article <94ph22frh...@mid.individual.net>, Neil Cerutti wrote: > On 2011-06-01, ru...@yahoo.com wrote: > > For some odd reason (perhaps because they are used a lot in > > Perl), this groups seems to have a great aversion to regular > > expressions. Too bad because this is a typical problem w

Re: how to avoid leading white spaces

2011-06-02 Thread Roy Smith
In article , Chris Torek wrote: > Python might be penalized by its use of Unicode here, since a > Boyer-Moore table for a full 16-bit Unicode string would need > 65536 entries (one per possible ord() value). I'm not sure what you mean by "full 16-bit Unicode string"? Isn't unicode inherently

Re: how to avoid leading white spaces

2011-06-03 Thread Roy Smith
In article <4de992d7$0$29996$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Of course, if you include both case-sensitive and insensitive tests in > the same calculation, that's a good candidate for a regex... or at least > it would be if regexes supported that :) Of course the

Re: how to avoid leading white spaces

2011-06-04 Thread Roy Smith
I wrote: >> Another nice thing about regexes (as compared to string methods) is >> that they're both portable and serializable. You can use the same >> regex in Perl, Python, Ruby, PHP, etc. In article <4de9bf50$0$29996$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Regexes a

Re: how to avoid leading white spaces

2011-06-07 Thread Roy Smith
On 06/06/2011 08:33 AM, rusi wrote: >> Evidently for syntactic, implementation and cultural reasons, Perl >> programmers are likely to get (and then overuse) regexes faster than >> python programmers. "ru...@yahoo.com" wrote: > I don't see how the different Perl and Python cultures themselves >

Re: Question About Command line arguments

2011-06-10 Thread Kurt Smith
On Fri, Jun 10, 2011 at 12:58 PM, Mark Phillips wrote: > How do I write my script so it picks up argument from the output of commands > that pipe input into my script? def main(): import sys print sys.stdin.read() if __name__ == '__main__': main() $ echo "fred" | python script.py fr

Re: Function within class and in modules

2011-06-15 Thread Roy Smith
In article , TheSaint wrote: > Hello > sorry, I'm bit curious to understand what could be the difference to pack up > a class for some number of functions in it and a simple module which I just > import and use the similar functions? If all you have is a bunch of functions, just sticking them

debugging https connections with urllib2?

2011-06-18 Thread Roy Smith
We've got a REST call that we're making to a service provider over https using urllib2.urlopen(). Is there any way to see exactly what's getting sent and received over the network (i.e. all the HTTP headers) in plain text? Things like tcpdump and strace only have access to the encrypted data.

Re: debugging https connections with urllib2?

2011-06-18 Thread Roy Smith
In article <4dfcff48$0$49184$e4fe5...@news.xs4all.nl>, Irmen de Jong wrote: > On 18-6-2011 20:57, Roy Smith wrote: > > We've got a REST call that we're making to a service provider over https > > using urllib2.urlopen(). Is there any way to see exactly what&#

Re: What is this syntax ?

2011-06-19 Thread Roy Smith
In article <4dfe10d1$0$28053$426a3...@news.free.fr>, candide wrote: > OK, thanks for your explanation, it was just stringisation ! > > > I erroneously focused on > > +x+ > > as a kind of placeholder unknown to me, instead of left and right > concatenations ;) > > It would be more readable

Re: How to iterate on a changing dictionary

2011-06-19 Thread Roy Smith
In article , Chris Angelico wrote: > On Mon, Jun 20, 2011 at 12:32 AM, TheSaint wrote: > > Hello > > > > Trying to pop some key from a dict while is iterating over it will cause an > > exception. > > How I can remove items when the search result is true. > > > > Example: > > > > while len(dict)

Re: What is this syntax ?

2011-06-19 Thread Roy Smith
In article , rusi wrote: > On Jun 19, 8:39 pm, Roy Smith wrote: > > > This is one of the (very) few places PHP wins over Python.  In PHP, I > > would write this as > > > > print "'$x'" > > > You dont find > > >>>

Re: using only the django ORM (DB access model) and nothing else.

2011-06-21 Thread Roy Smith
In article <4e012e8d$0$23682$426a3...@news.free.fr>, News123 wrote: > Hi, > > I have a small application running on a host without web server and > without any need for django except its ORM accessing data bases without > explicitely writing sql queries.) You would do much better to ask this q

Re: web hosting, first hand experiences?

2011-07-03 Thread Roy Smith
In article , Daniel Fetchinson wrote: > Hi folks, I know this comes up regularly but the thing is that the > quality of service changes also quite regularly with many of the > hosting companies. What's currently the best option for shared hosting > of a turbogears application? I'm thinking of dr

Re: Implicit initialization is EVIL!

2011-07-03 Thread Roy Smith
In article , Chris Angelico wrote: > var(0x14205359) x # Don't forget to provide an address where the > object will be located > x=42 > > After all, everyone's gotta learn about segfaults some day! 0x14205359 is more likely to give a bus error (odd address) than a segfault :-) -- http://ma

why the following python program does not face any concurrency problems without synchronize mechanism?

2011-07-09 Thread smith jack
from threading import Thread def calc(start, end): total = 0; for i in range(start, end + 1): total += i; print '--result:', total return total t = Thread(target=calc, args=(1,100)) t.start() I have run this program for many times,and the result is alw

Re: String concatenation vs. string formatting

2011-07-10 Thread Roy Smith
In article , Andrew Berg wrote: > How should I go about switching from concatenation to string formatting > for this? > > avs.write(demux_filter + field_filter + fpsin_filter + i2pfilter + > dn_filter + fpsout_filter + trim_filter + info_filter) > > I can think of a few ways, but none of them

Re: Function docstring as a local variable

2011-07-10 Thread Roy Smith
In article , pyt...@bdurham.com wrote: > I'm not sure how a function can get a generic handle to itself, but if > you're willing to hardcode the function name, then this technique works: > > def test(): > """This is my doc string""" > print test.__doc__ > > test() > > Outputs: > > Thi

Re: Lisp refactoring puzzle

2011-07-12 Thread Roy Smith
In article <4e1cf936.4050...@canterbury.ac.nz>, Gregory Ewing wrote: > Xah Lee wrote: > > they > > don't provide even simple list manipulation functions such as union, > > intersection, and the like. Not in perl, not in python, not in lisps. > > Since 2.5 or so, Python has a built-in set type t

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-17 Thread Roy Smith
In article , Andrew Berg wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: RIPEMD160 > > On 2011.07.17 06:29 PM, Roy Smith wrote: > > We don't have that problem any more. It truly boggles my mind that > > we're still churning out people with 80 column mi

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-18 Thread Roy Smith
In article , Duncan Booth wrote: > Tim Chase wrote: > > > On 07/17/2011 08:01 PM, Steven D'Aprano wrote: > >> Roy Smith wrote: > >>> We don't have that problem any more. It truly boggles my > >>> mind that we're still churning out

Debugging cookielib.CookieJar

2011-07-19 Thread Roy Smith
I've got a unit test suite which instantiates an HTTP client to test our server. We depend on session cookies. To handle this, I've got: def setUp(self): self.cj = cookielib.CookieJar() self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj)) This works fine

Re: Debugging cookielib.CookieJar

2011-07-19 Thread Roy Smith
Ah, never mind. I found "cookielib.debug = True", which told me exactly what I needed to know. I did indeed have a hostname problem. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get number of bytes written to nonblocking FIFO when EAGAIN is raised?

2011-07-19 Thread Roy Smith
In article <40996f2a-4ed8-4388-ae1a-6f81f57a4...@f17g2000prf.googlegroups.com>, Aaron Staley wrote: > Scenario. I have a fifo named 'fifo' on my computer (ubuntu linux) > operating in nonblocking mode for both read and write. Under normal > operation all is good: > > Interpreter 1 (writer) >

Re: PEP 8 and extraneous whitespace

2011-07-21 Thread Roy Smith
In article , Terry Reedy wrote: > Whether or not they are intended, the rationale is that lining up does > not work with proportional fonts. There are very few things I am absolutely religious about, but programming in a fixed width font is one of them. -- http://mail.python.org/mailman/list

Any suggestion to start more threads at the same time?

2011-07-28 Thread smith jack
I start many threads in order to make the work done, when the concurrent number is set to 300, all thing just works fine, but when the number is set to 350 or higher, error just comes out? what's wrong ? the error info is just as follows: failed to start . I am confused, does this have something

Another win for profiling.

2011-07-29 Thread Roy Smith
It's often said that you shouldn't try to guess what's slow, but use profiling tools to measure what's slow. I had a great example of that yesterday. We have some web server code that does a big database (MongoDB) query and some post-processing of the data in python. It worked fine in testin

Re: Wondering in the Python Forrest

2011-07-30 Thread duncan smith
Ken Watford wrote: On Sat, Jul 30, 2011 at 7:13 AM, ray wrote: I found that structured data could be presented in Python using a module in wxPython. Where am I? I do not know the relationships between the Pythons. I feel that I am missing something. I started with Python as it has so much f

python import error, what's wrong?

2011-08-02 Thread smith jack
I am using pydev plugin in eclipse, all things works just as well but now i have confronted with a confusing problem, that is i can import a module write by myself successfully, but when i try to run this program, error just shows up, what's wrong? the directory structure is as follows: src org

How to define repeated string when using the re module?

2011-08-02 Thread smith jack
if it's for a single character, this should be very easy, such as c{m,n} the occurrence of c is between m and n, if i want to define the occurrence of (.*?) how should make it done? ((.*?)){1,3} seems not work, any method to define repeat string using python regex? -- http://mail.python.org/

how to sort a hash list without generating a new object?

2011-08-02 Thread smith jack
the source code is as follows x={} x['a'] = 11 x['c'] = 19 x['b'] = 13 print x tmp = sorted(x.items(), key = lambda x:x[0])# increase order by default, if i want to have a descending order, what should i do? # after sorted is called, a list will be generated, and the hash list x is not chang

what is the advantage of Django when comparing with LAMP and J2EE platform?

2011-08-02 Thread smith jack
There are so many choice to do the same thing, so is there any special advantage Django brings to user? -- http://mail.python.org/mailman/listinfo/python-list

Re: Complex sort on big files

2011-08-05 Thread Roy Smith
Wow. I was going to suggest using the unix command-line sort utility via popen() or subprocess. My arguments were that it's written in C, has 30 years of optimizing in it, etc, etc, etc. It almost certainly has to be faster than anything you could do in Python. Then I tried the experiment.

can virtualenv run without the main installation?

2011-08-06 Thread smith jack
At first i have a python environment, after using virtualenv test command, a new environment named test is created, in that directory have some of the executable commands such as python.exe, so can i program without the main installation of python? -- http://mail.python.org/mailman/listinfo/python

Re: can virtualenv run without the main installation?

2011-08-06 Thread smith jack
env create by virtualenv will refer to the main env, how did it find the main env, is there any configuration files, if yes, where is it? 2011/8/6 smith jack : > At first i have a python environment, after using virtualenv test > command, a new environment named test is created, in that dir

How to make the program support communication behind NAT device?

2011-08-06 Thread smith jack
The subnet behind my router is 192.168.1.0/24, my pc ip is 192.168.1.9, the server written with python is hosted on 192.168.1.3 on port 1033, i can connect to this server from my pc But cannot connect to this server when outside of this subnet? why? I have made port translate on router, that is 1

how to separate a list into two lists?

2011-08-06 Thread smith jack
if a list L is composed with tuple consists of two elements, that is L = [(a1, b1), (a2, b2) ... (an, bn)] is there any simple way to divide this list into two separate lists , such that L1 = [a1, a2... an] L2=[b1,b2 ... bn] i do not want to use loop, any methods to make this done? -- http://mai

Re: Restricted attribute writing

2011-08-07 Thread Roy Smith
In article , John O'Hagan wrote: > I'm looking for good ways to ensure that attributes are only writable such > that they retain the characteristics the class requires. Sounds like you're trying to do http://en.wikipedia.org/wiki/Design_by_contract. Which is not a bad thing. But, I think

module import error, what's wrong?

2011-08-07 Thread smith jack
from common.URLTool import URLTool tool = URLTool() Traceback (most recent call last): File "E:\workspace\url\test.py", line 7, in ? from common.URLTool import URLTool ImportError: No module named common.URLTool URLTools is a class write by myself, it works well ,but cannot be imported in t

Re: How do I convert String into Date object

2011-08-13 Thread Roy Smith
In article <83822ecb-3643-42c6-a2bf-0187c07d3...@a10g2000yqn.googlegroups.com>, MrPink wrote: > Is this the correct way to convert a String into a Date? > I only have dates and no time. You have already received a number of good replies, but let me throw out one more idea. If you ever need t

Re: allow line break at operators

2011-08-14 Thread Roy Smith
In article <4e47db26$0$30002$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Er, most URLs are case insensitive, at least the most common ones, including > HTTP and HTTPS. So I don't quite see why you think this was a Whoops. URLs are most certainly not case insensitive. Parts of

Re: allow line break at operators

2011-08-14 Thread Roy Smith
In article , Dave Angel wrote: > > URLs are most certainly not case insensitive. Parts of them may be > > (i.e. the scheme and host parts), but not the stuff after the hostname. > > > The thing that confuses people is that not only is the part up to and > through the domain name is case-insens

Re: allow line break at operators

2011-08-15 Thread Roy Smith
In article , Chris Angelico wrote: > Python uses the + and - symbols to mean addition > and subtraction for good reason. Let's not alienate the mathematical > mind by violating this rule. Computer programming languages follow math conventions only in the most vague ways. For example, standard

Re: allow line break at operators

2011-08-15 Thread Roy Smith
In article , Chris Angelico wrote: > Or: "Blasted PHP, which > operators have precedence between || and or?" which is easy to forget. > > And you're right about the details changing from language to language, > hence the operators table *for each language*. But most languages > follow fairly sa

Re: allow line break at operators

2011-08-15 Thread Roy Smith
In article <4e492d08$0$30003$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I'm reminded of this quote from John Baez: > > "The real numbers are the dependable breadwinner of the family, the complete > ordered field we all rely on. The complex numbers are a slightly flashier > bu

Re: testing if a list contains a sublist

2011-08-15 Thread Roy Smith
In article , Johannes wrote: > hi list, > what is the best way to check if a given list (lets call it l1) is > totally contained in a second list (l2)? > > for example: > l1 = [1,2], l2 = [1,2,3,4,5] -> l1 is contained in l2 > l1 = [1,2,2,], l2 = [1,2,3,4,5] -> l1 is not contained in l2 > l1 =

Re: Ten rules to becoming a Python community member.

2011-08-15 Thread Roy Smith
In article <9att2bf71...@mid.individual.net>, Gregory Ewing wrote: > rantingrick wrote: > > "Used to" and "supposed to" is the verbiage of children > > and idiots. > > So when we reach a certain age we're meant to abandon > short, concise and idomatic ways of speaking, and substitute > long wor

Re: Ten rules to becoming a Python community member.

2011-08-15 Thread Roy Smith
In article <9att9mf71...@mid.individual.net>, Gregory Ewing wrote: > I don't mind people using e.g. and i.e. as long > as they use them *correctly*. The only correct way to use i.e. is to use it to download a better browser. -- http://mail.python.org/mailman/listinfo/python-list

How to use python environment created using virtualenv?

2011-08-15 Thread smith jack
I have created a python environment using virtualenv, but when i want to import such environment to PyDev, error just appears, it tells there should be a Libs dir, but there is no Libs DIr in the virtual envronment created using virtualenv, what should i do if i want to use this virtual environment

Anyone here can do a comparation between Djang and RoR

2011-08-16 Thread smith jack
what is the advantage of Django over RoR:) -- http://mail.python.org/mailman/listinfo/python-list

Re: regular expression

2011-08-16 Thread Roy Smith
In article , Chris Rebert wrote: > pat = re.compile("^ *(\\([^)]+\\))", re.MULTILINE) First rule of regexes in Python is to always use raw strings, to eliminate the doubled backslashes: > pat = re.compile(r"^ *(\([^)]+\))", re.MULTILINE) Is easier to read. -- http://mail.python.org/mailman/

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