Re: Subprocess puzzle and two questions

2012-11-14 Thread Roy Smith
In article , Chris Angelico wrote: > I'm slightly surprised that there's no way with the Python stdlib to > point a DNS query at a specific server Me too, including the "only slightly" part. The normal high-level C resolver routines (getaddrinfo/getnameinfo, or even the old gethostbyname se

Re: Subprocess puzzle and two questions

2012-11-14 Thread Roy Smith
In article , Chris Angelico wrote: > Indeed. But Python boasts that the batteries are included, and given > the wealth of other networking facilities that are available, it is a > bit of a hole that you can't run DNS queries in this way. Think of the socket and struct modules as a pile of carbo

Re: debugging in eclipse

2012-11-15 Thread Roy Smith
In article , chip9m...@gmail.com wrote: > Now I would like to debug it in eclipse.. Heh. It took me a while to realize that the subject line was not referring to http://en.wikipedia.org/wiki/Solar_eclipse_of_November_13,_2012 -- http://mail.python.org/mailman/listinfo/python-list

Re: debugging in eclipse

2012-11-15 Thread Roy Smith
In article , Dave Angel 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". To be fair, I usually start by adding a print statement, as Dave suggests. If I see the output, I know it ran. But if

Re: Subprocess puzzle and two questions

2012-11-15 Thread Roy Smith
In article , Nobody wrote: > That's because the high-level routines aren't tied to DNS. This is true. >> gethostbyname() and getaddrinfo() use the NSS (name-service switch) > mechanism, which is configured via /etc/nsswitch.conf. Depending upon > configuration, hostnames can be looked up via a

Re: editing conf file

2012-11-16 Thread Roy Smith
Ulrich Eckhardt wrote: > in general importing configuration data by loading and > executing code is a questionable approach. The problem is in particular > that the code parser is always more strict with the syntax than a > configuration file should be. Also, it presents the danger of code >

Re: Python Script for Colorizing Traceroute Output (apologies for top-post)

2012-11-17 Thread Roy Smith
In article , w...@mac.com wrote: > On Nov 17, 2012, at 10:04 AM, Jordan Bylsma wrote: > > > I'm looking into writing a python script that colorizes particular hops > > when using traceroute. Anyone run across something like this? I don't think > > it would be extremely difficult to write but

Re: Python Interview Questions

2012-11-18 Thread Roy Smith
In article <50a8acdc$0$29978$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Use a list when you want a list of items that should all be treated the > same way [...] or when you need a collection of items where the order they > are in is > important: > > Use a tuple when you wan

Re: Python Interview Questions

2012-11-18 Thread Roy Smith
In article <50a911ec$0$29978$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Oh I'm sorry, did something I say suggest that the couple of examples I > gave are the *only* acceptable uses? My apologies for not giving an > exhaustive list of every possible use of lists and tuples,

Re: Python Interview Questions

2012-11-18 Thread Roy Smith
In article <50a97de0$0$29983$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > > The stack that's returned is a list. It's inherently a list, per the > > classic definition: > > Er, no, it's inherently a blob of multiple text lines. No, it's a list that looks like (taken from the

Re: Python Interview Questions

2012-11-19 Thread Roy Smith
In article <50a9e5cf$0$21863$c3e8da3$76491...@news.astraweb.com>, Steven D'Aprano wrote: > I see. It wasn't clear from your earlier description that the items had > been post-processed from collections of raw log lines to fixed records. Well, I did provide the code that does this. > But it d

Re: Python Interview Questions

2012-11-19 Thread Roy Smith
OK, I've just read back over the whole thread. I'm really struggling to understand what point you're trying to make. I started out by saying: > Use a list when you need an ordered collection which is mutable (i.e. > can be altered after being created). Use a tuple when you need an > immutabl

Re: Python Interview Questions

2012-11-19 Thread Roy Smith
In article <50aac3d8$0$29983$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > By the way, your news client seems to be mangling long URLs, by splitting > them when they exceed the maximum line length. Hmmm. So it did. My bad. -- http://mail.python.org/mailman/listinfo/python-li

Re: Python Interview Questions

2012-11-19 Thread Roy Smith
In article <50aac66c$0$29983$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I'm asking about the case where one might want the key to remain mutable > even after it is used as a key, but can't because Python won't let you. Ah. Now I see what you're getting at. Thank you. Well

Re: Printing time in "at" format?

2012-11-20 Thread Roy Smith
as 'at' does" > > If it's the former, it's pretty easy--'at' accepts a wide variety of > formats. Fortunately, it's the former. Since posting my original query, I have discovered by experimentation that the API also accepts a string of digit

Re: Is it bad style to override the built-in function `type`?

2012-11-23 Thread Roy Smith
In article , Michael Herrmann wrote: > do you think it's bad style to override the built-in function `type`? I'm > co-developing a GUI automation library called Automa > (http://www.getautoma.com) and 'type' would be a very fitting name for a > function that generates artificial key strokes.

argparse -- mutually exclusive sets of arguments?

2012-11-23 Thread Roy Smith
My command either takes two positional arguments (in which case, both are required): $ command foo bar or the name of a config file (in which case, the positional arguments are forbidden): $ command --config file How can I represent this with argparse; add_mutually_exclusive_group() isn't qu

Re: How to pass class instance to a method?

2012-11-26 Thread Roy Smith
Steven D'Aprano wrote: > Given the practical reality that documentation is often neglected, there > is a school of thought that says that *code* is the One True source of > information about what the code does, that documentation is at best a > hint or at worst completely redundant. Yes, there

Re: "non central" package management

2012-11-27 Thread Roy Smith
In article <8ea52e1b-2e02-40b2-8ce0-fcce7fc2e...@googlegroups.com>, Miki Tebeka wrote: > Greetings, > > The usual package mangers (easy_install, pip ...) install packages in one > central location. > > I'm looking for a solution that will allow every project (which run on the > same machine)

Re: "non central" package management

2012-11-27 Thread Roy Smith
In article , Miki Tebeka wrote: > > When we deploy, we create a new virtualenv, then do > > "pip install -r requirements.txt". > 1. Do you do that for every run? Well, sort of. We are currently using a single virtualenv per deployment host. Each time we deploy new code, we checkout all th

Weird import failure with "nosetests --processes=1"

2012-11-28 Thread Roy Smith
I've got a minimal test script: - $ cat test_foo.py import pyza.models print pyza.models def test_foo(): pass - pyza.models is a package. Under normal conditions, I can import it fine: $ python Python 2.7.3 (default, Aug 1 2012, 05:1

Re: Weird import failure with "nosetests --processes=1"

2012-11-29 Thread Roy Smith
In article <50b78e26$0$6945$e4fe5...@news2.news.xs4all.nl>, Hans Mulder wrote: > That is baffling indeed. It looks like nose is adding some > directory to sys.path, which contains a module pyza.py instead > of a package. We finally figured it out. As it turns out, that's pretty close. > Anot

Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Roy Smith
This is kind of weird (Python 2.7.3): try: print "hello" except foo: print "foo" prints "hello". The problem (IMHO) is that apparently the except clause doesn't get evaluated until after some exception is caught. Which means it never notices that foo is not defined until it's too late

Re: How to determine if printing is being a bottleneck in my code?

2012-12-04 Thread Roy Smith
In article <29c74a30-f017-44b5-8a3d-a3c0d6592...@googlegroups.com>, SherjilOzair wrote: > Hello list, > > When it comes to printing things while some computation is being done, there > are 2 extremes. > > 1. printing speed is slower than data-to-print generation speed. In this > case, printi

Re: A question about readability

2012-12-07 Thread Roy Smith
In article , Marco wrote: > Hi all, do you think this code: > > $ more myscript.py > for line in open('data.txt'): > result = sum(int(data) for data in line.split(';')) > print(result) That sum() line is a bit of a mouthful. I would refactor it into something like this: > for line

Re: TypeError: 'in ' requires string as left operand, not Element

2012-12-09 Thread Roy Smith
In article <8c78344a-8019-450a-bfdf-13508bf75...@googlegroups.com>, Victor Hooi wrote: > Hi, > > I'm getting a strange error when I try to run the following: > > for root, dirs, files in os.walk('./'): > for file in files: > if file.startswith('ml') and file.endswith('.

Re: What are the minimum requirements to get a job in?

2012-12-14 Thread Roy Smith
In article , Stefan Behnel wrote: > suresh.pinn...@gmail.com, 14.12.2012 03:49: > > My aim is to get a job into google or cisco or facebok. > > Why? > > There are lots of attractive places to work at. Choosing a less visible one > means that you have a higher chance of getting hired in the fir

Re: What are the minimum requirements to get a job in?

2012-12-14 Thread Roy Smith
In article <50cbaf19$0$29991$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Fri, 14 Dec 2012 09:48:54 -0500, Roy Smith wrote: > > > On the other hand, as somebody who's looking to hire software engineers, > > I can tell you that we loo

Re: What are the minimum requirements to get a job in?

2012-12-14 Thread Roy Smith
In article , Chris Angelico wrote: > If the boss's vision is anything to go by, we're going to be bigger > than Microsoft, eBay, Facebook, and Google combined, and all by early > 2013. That's the kind of attitude you need to be at a startup. -- http://mail.python.org/mailman/listinfo/python-l

Re: where to view open() function's C implementation source code ��

2012-12-17 Thread Roy Smith
In article , iMath wrote: > where to view open() function's C implementation source code ? http://www.python.org/download/releases/ Download the source for the version you're interested in. -- http://mail.python.org/mailman/listinfo/python-list

Re: where to view open() function's C implementation source code ?

2012-12-18 Thread Roy Smith
In article , iMath wrote: > � 2012”N12ŒŽ18“��Š�“�UTC+8‰�Œ�1时35分58秒,Roy > Smith写道: > > In article , > > > > iMath wrote: > > > > > > > > > where to view open() function's C implementation

Re: help with making my code more efficient

2012-12-20 Thread Roy Smith
In article , "larry.mart...@gmail.com" wrote: > On Thursday, December 20, 2012 5:38:03 PM UTC-7, Chris Angelico wrote: > > On Fri, Dec 21, 2012 at 11:19 AM, larry.mart...@gmail.com > > > > wrote: > > > > > This code works, but it takes way too long to run - e.g. when cdata has > > > 600,000

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Roy Smith
In article , prilisa...@googlemail.com wrote: > Thanks to all your answers, I have read a lot about namespaces, but still > there's something I do not understood. I have tried your example but as I > expected: > > line 13, in HandoverSQLCursor > curs.execute("SELECT * FROM lager") > Attrib

Integer as raw hex string?

2012-12-24 Thread Roy Smith
I have an integer that I want to encode as a hex string, but I don't want "0x" at the beginning, nor do I want "L" at the end if it happened to be a long. The result needs to be something I can pass to int(h, 16) to get back my original integer. The brute force way works: h = hex(i) ass

Re: Custom alphabetical sort

2012-12-24 Thread Roy Smith
In article <40d108ec-b019-4829-a969-c8ef51386...@googlegroups.com>, Pander Musubi wrote: > Hi all, > > I would like to sort according to this order: > > (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', > 'A', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', 'b', 'B',

Re: Integer as raw hex string?

2012-12-24 Thread Roy Smith
In article , Tim Chase wrote: > On 12/24/12 09:36, Roy Smith wrote: > > I have an integer that I want to encode as a hex string, but I don't > > want "0x" at the beginning, nor do I want "L" at the end if it happened > > to be a long. The result

Re: how to detect the character encoding in a web page ?

2012-12-24 Thread Roy Smith
In article , Alister wrote: > Indeed due to the poor quality of most websites it is not possible to be > 100% accurate for all sites. > > personally I would start by checking the doc type & then the meta data as > these should be quick & correct, I then use chardectect only if these > fail t

Re: Custom alphabetical sort

2012-12-24 Thread Roy Smith
In article <46db479a-d16f-4f64-aaf2-76de65418...@googlegroups.com>, Pander Musubi wrote: > > I'm assuming that doesn't correspond to some standard locale's collating > > order, so we really do need to roll our own encoding (and that you have > > a good reason for wanting to do this). > > It i

Re: Finding the name of a function while defining it

2012-12-25 Thread Roy Smith
In article , Abhas Bhattacharya wrote: > While I am defining a function, how can I access the name (separately as > string as well as object) of the function without explicitly naming > it(hard-coding the name)? > For eg. I am writing like: > def abc(): > #how do i access the function abc

Re: How to get time.strptime()?

2012-12-26 Thread Roy Smith
In article <0e36e143-5103-4b4b-aaa9-b7b1b7686...@googlegroups.com>, Gnarlodious wrote: > This is problem that has unduly vexed me. When you start learning Python they > don't tell you about these sharp edges. Someone needs to explain. The same thing happens when you're born. You spend your en

Re: Finding the name of a function while defining it

2012-12-27 Thread Roy Smith
In article <50dc29e9$0$29967$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Wed, 26 Dec 2012 23:46:31 -0800, Abhas Bhattacharya wrote: > > >> > two = lamba : "one" > >> > one = two > >> > >> > Which one of these is the "name" of the function? > [...] > > If i call one() and t

Re: New to python, do I need an IDE or is vim still good enough?

2012-12-27 Thread Roy Smith
In article <50dcf145$0$24782$607ed...@cv.net>, "TommyVee" wrote: > Do I really need a real IDE, as the windows guys around me say I do, or will > vim, git, make and other standalone tools make it the next 20 years too for > me? You'll do fine with vim (or emacs, or whatever). You may find an

Re: Python lists

2012-12-28 Thread Roy Smith
In article <8f5cfb99-d1d7-42d7-858a-89dd23cd5...@googlegroups.com>, Manatee wrote: > I read in this: > ['C100, C117', 'X7R 0.033uF 10% 25V 0603', '0603-C_L, 0603-C_N', '10', '2', > '', '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D', 'Digi-Key', > '490-1521-1-ND', ''] > > Then I need to co

Re: Confused about logger config from within Python (3)

2012-12-29 Thread Roy Smith
In article <50de7a0a$0$29967$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > In Python 3.2 and 3.3, the message about no handlers is not printed, > which is an interesting difference. (Somebody who knows more about the > logging package than I do might be able to state why that d

Re: New to python, do I need an IDE or is vim still good enough?

2012-12-29 Thread Roy Smith
Monte Milanuk wrote: > > Maybe its because I'm still just a hobbyist when it comes to coding, but I > > spend far more time 'thinking' about what I'm doing than typing things in... If more "professional" programmers spent more time thinking and less type typing, the world would be a better place

Re: dict comprehension question.

2012-12-29 Thread Roy Smith
In article <724d4fea-606a-4503-b538-87442f6bc...@ci3g2000vbb.googlegroups.com>, Quint Rankid wrote: > Newbie question. I've googled a little and haven't found the answer. > > Given a list like: > w = [1, 2, 3, 1, 2, 4, 4, 5, 6, 1] > I would like to be able to do the following as a dict compre

Re: Facing issue with Python loggin logger for printing object value

2012-12-29 Thread Roy Smith
In article , Morten Engvoldsen wrote: > It is able to log the message with: > logger.debug("value of payment_line is " +repr(payment_line)) As a side note, a better way to write that is logger.debug("value of payment_line is %r", payment_line) The difference is that the first way, repr(paymen

Re: New to python, do I need an IDE or is vim still good enough?

2012-12-29 Thread Roy Smith
In article , Chris Angelico wrote: > Auto-complete is handy, but not critical. You just wait until your finger joints get to be my age and tell me that auto-complete isn't critical :-) > It's extremely handy; not only errors from > compilation/execution, but things like a 'git grep -n' fit to

Re: Confused about logger config from within Python (3)

2012-12-29 Thread Roy Smith
In article , Terry Reedy wrote: > On 12/29/2012 8:48 AM, Roy Smith wrote: > > In article <50de7a0a$0$29967$c3e8da3$54964...@news.astraweb.com>, > > Steven D'Aprano wrote: > > > >> In Python 3.2 and 3.3, the message about no handlers is not printed

Re: ignore case only for a part of the regex?

2012-12-30 Thread Roy Smith
Helmut Jarausch wrote: > is there a means to specify that 'ignore-case' should only apply to a part > of a regex? Not that I'm aware of. > the regex should match Msg-id:, Msg-Id, ... but not msg-id: and so on. What's the use-case for this? The way I would typically do something like this

Re: ignore case only for a part of the regex?

2012-12-30 Thread Roy Smith
In article , Vlastimil Brom wrote: > you may check the new regex implementation for python > http://pypi.python.org/pypi/regex Wow, I wasn't aware of such an effort. At first reading, I'm amused by the concept of "strict fuzzy matching". Those of us with long memories will be confused by the

Re: father class name

2012-12-30 Thread Roy Smith
In article , contro opinion wrote: > here is my haha class > class haha(object): > def theprint(self): > print "i am here" > > >>> haha().theprint() > i am here > >>> haha(object).theprint() > Traceback (most recent call last): > File "", line 1, in > TypeError: object.__new__() tak

Python is awesome (Project Euler)

2012-12-31 Thread Roy Smith
If you haven't heard of it, you should check out Project Euler (http://projecteuler.net/). It's a series of (currently) 408 math-oriented programming problems, of varying degrees of difficulty. The tie-in to this group is just how many of them are trivial in Python. There's a whole slew of th

Re: Python is awesome (Project Euler)

2012-12-31 Thread Roy Smith
In article , "Alex" wrote: > Yes. Although sometimes I fear that we are becoming a society of > end-users who rely too much on the capability of our tools and fail to > take the time to understand the fundamentals upon which those tools are > based or cultivate the problem-solving skills that Pr

Re: got stuck in equation

2013-01-01 Thread Roy Smith
In article , Usama Khan wrote: > am just a begginer bro. That's fine, we were all beginners once. You will discover that people here are willing to invest a lot of time and effort helping beginners get started. > now can u give me the coding of this equation as i need to save my time. . .i

Re: New to python, do I need an IDE or is vim still good enough?

2013-01-01 Thread Roy Smith
In article , Mitya Sirenef wrote: > Clunky is the last word I'd use to describe it (ok maybe for Emacs :-) > I probably remember about 200 commands, plus or minus, but a lot of them > fit into a consistent scheme which makes them much easier to remember At some point, it becomes muscle memory,

Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple?

2013-01-02 Thread Roy Smith
In article , Victor Hooi wrote: > Hi, > > I'm using pysvn to checkout a specific revision based on date - pysvn will > only accept a date in terms of seconds since the epoch. > > I'm attempting to use time.mktime() to convert a date (e.g. "2012-02-01) to > seconds since epoch. In what timez

Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple?

2013-01-02 Thread Roy Smith
In article , Chris Angelico wrote: >> I assume you mean timestamps. A date doesn't need to worry about UTC >> the way a timestamp does. I'm not sure how a date and a timestamp differ in any significant way. A date is just a very low-precision time. >> 3) Run all your servers with their timezo

Re: Python is awesome (Project Euler)

2013-01-02 Thread Roy Smith
In article , Neil Cerutti wrote: > On 2012-12-31, Roy Smith wrote: > > There's a problem I just worked where you need to find the last > > 10 digits of some million-digit prime. Python's long ints > > don't help you there. What does help you is figurin

Re: New to python, do I need an IDE or is vim still good enough?

2013-01-04 Thread Roy Smith
In article , Cameron Simpson wrote: > On 01/04/13 01:34, Anssi Saari wrote: > | Just curious since I read the same thing in a programming book recently > | (21st century C). So what's the greatness that terminal multiplexors > | offer over tabbed terminals? Especially for software development?

Re: Need a specific sort of string modification. Can someone help?

2013-01-05 Thread Roy Smith
In article , Sia wrote: > I have strings such as: > > tA.-2AG.-2AG,-2ag > or > .+3ACG.+5CAACG.+3ACG.+3ACG Some kind of DNA binding site? A couple of questions. Are the numbers always single digits? How much data is there? Are we talking a few hundred 20-character strings, or all of Genba

Re: Need a specific sort of string modification. Can someone help?

2013-01-05 Thread Roy Smith
In article , Chris Angelico wrote: > result = "".join([x[int(x[0])+1:] for x in > ("0"+s).replace("-","+").split("+")]) That's exceedingly clever. But bordering on line noise. At the very least, I would break it up into a couple of lines to make it easier to understand (plus you can print

Re: Need a specific sort of string modification. Can someone help?

2013-01-05 Thread Roy Smith
In article , Chris Angelico wrote: > On Sun, Jan 6, 2013 at 1:30 AM, Roy Smith wrote: > > In article , > > Chris Angelico wrote: > > > >> result = "".join([x[int(x[0])+1:] for x in > >> ("0"+s).replace("-","+"

Re: Need a specific sort of string modification. Can someone help?

2013-01-05 Thread Roy Smith
In article , Chris Angelico wrote: > it may or may not run faster than the explicit state machine, Hmmm, hard to say. Both are O(n), but yours makes several more copies of the data than mine (the string addition, the replace(), the split(), the string slicing). We both make copies as we put

Re: Couting the number of lines of code of a python program

2013-01-05 Thread Roy Smith
In article , Dave Angel wrote: > On 01/05/2013 10:17 AM, chaouche yacine wrote: > > > > > > > > Here is my implementation : > > > > defcount_loc(lines):nb_lines =0docstring =Falseforline inlines:line > > =line.strip()ifline ==""\ orline.startswith("#")\ ordocstring > > andnot(line.startswit

Re: Random List Loop?!

2013-01-05 Thread Roy Smith
In article , Christian Gabriel wrote: > Hi > > I have tried now for ages to make a loop that does the following: > > Makes a new list with 9 random values, from 9 different lists, with 9 > elements. > > And makes sure that none of the elements repeat! > > Is there anyone that can help, wit

Re: Need a specific sort of string modification. Can someone help?

2013-01-05 Thread Roy Smith
In article , Chris Angelico wrote: > On Sun, Jan 6, 2013 at 7:04 AM, Ian Kelly wrote: > > On Sat, Jan 5, 2013 at 8:57 AM, Chris Angelico wrote: > >> You miss my point, though. I went for simple Pythonic code, and never > >> measured its performance, on the expectation that it's "good enough".

Re: Newbie problem with Python pandas

2013-01-06 Thread Roy Smith
In article <_dudnttyxduonxtnnz2dnuvz_ocdn...@giganews.com>, RueTheDay wrote: > On Sun, 06 Jan 2013 08:05:59 -0800, Miki Tebeka wrote: > > > On Sunday, January 6, 2013 5:57:17 AM UTC-8, RueTheDay wrote: > >> I am getting the following error when running on Python 2.7 on Ubuntu > >> 12.04: > >> >

Re: Need a specific sort of string modification. Can someone help?

2013-01-06 Thread Roy Smith
In article , Roy Smith wrote: > It's rare to find applications these days that are truly CPU bound. > Once you've used some reasonable algorithm, i.e. not done anything in > O(n^2) that could have been done in O(n) or O(n log n), you will more > often run up again

Re: Newbie problem with Python pandas

2013-01-06 Thread Roy Smith
In article <_dudntfyxdvclhtnnz2dnuvz_ocdn...@giganews.com>, RueTheDay wrote: > On Sun, 06 Jan 2013 11:45:34 -0500, Roy Smith wrote: > > > In article <_dudnttyxduonxtnnz2dnuvz_ocdn...@giganews.com>, > > RueTheDay wrote: > > > >> On Sun,

Re: Difference between these two lists?

2013-01-07 Thread Roy Smith
In article <700d2bd9-e1df-4d38-81c7-77029a36c...@googlegroups.com>, andydtay...@gmail.com wrote: > Hi, > > Python newbie here again - this is probably a quick one. What's the > difference between the lines I've numbered 1. and 2. below, which produce the > following results: > > Results: > 1

Re: Calculate Big Number

2013-01-07 Thread Roy Smith
In article , Nac Temha wrote: > Thanks for reply. I wonder how quickly calculate big numbers. Can you > explain me as theoretical? Because this numbers overflow size of integer > and double. Now, that's a good question. The answer is that Python implements multiple-precision arithmetic. This

Re: how to download internet files by python ?

2013-01-07 Thread Roy Smith
In article , Cameron Simpson wrote: > On 07Jan2013 20:19, iMath wrote: > | for example ,if I want to download this file ,how to implement the download > | functionality by python ? > | > | http://down.51voa.com/201208/se-ed-foreign-students-friends-16aug12.mp3 > | > | as for download speed

How to tell how many weeks apart two datetimes are?

2013-01-08 Thread Roy Smith
How do you tell how many weeks apart two datetimes (t1 and t2) are? The "obvious" solution would be: weeks = (t2 - t1) / timedelta(days=7) but that doesn't appear to be allowed. Is there some fundamental reason why timedelta division not supported? -- http://mail.python.org/mailman/listinfo/pyt

Why BOM in logging message?

2013-01-09 Thread Roy Smith
We've got 10 (supposedly) identical servers, all running Ubuntu 12.04, Python 2.7, Django 1.3. We log to syslog using the logging module and a custom fomatter. 'formatters': { 'verbose': { 'format': '%(asctime)s [%(process)d]: %(program)s %(session_id)s %(requ

Re: Why BOM in logging message?

2013-01-09 Thread Roy Smith
In article , John Gordon wrote: > In r...@panix.com (Roy Smith) writes: > > > What's weird is that two of the servers, and only those two, stick a > > BOM (Byte Order Mark) in front of the message they log. It shows up > > in syslog as: > > > 2013-01-

Re: Why BOM in logging message?

2013-01-09 Thread Roy Smith
In article , Chris Angelico wrote: > On Thu, Jan 10, 2013 at 9:54 AM, Roy Smith wrote: > > What's weird is that two of the servers, and only those two, stick a > > BOM (Byte Order Mark) in front of the message they log. > > Could it be this issue you're looking

Re: Why BOM in logging message?

2013-01-10 Thread Roy Smith
In article , Roy Smith wrote: >In article , > Chris Angelico wrote: > >> On Thu, Jan 10, 2013 at 9:54 AM, Roy Smith wrote: >> > What's weird is that two of the servers, and only those two, stick a >> > BOM (Byte Order Mark) in front of the message they log

Re: Why BOM in logging message?

2013-01-10 Thread Roy Smith
>On Fri, Jan 11, 2013 at 3:06 AM, Roy Smith wrote: >> -rw-r--r-- 1 root root 45076 Aug 1 05:39 >> /usr/lib/python2.7/logging/handlers.py >> -rw-r--r-- 1 root root 45143 Apr 20 2012 >> /usr/lib/python2.7/logging/handlers.py Chris Angelico wrote: >$ dpkg

Re: Probabilistic unit tests?

2013-01-10 Thread Roy Smith
In article , Nick Mellor wrote: > Hi, > > I've got a unit test that will usually succeed but sometimes fails. An > occasional failure is expected and fine. It's failing all the time I want to > test for. > > What I want to test is "on average, there are the same number of males and > female

Multiple disjoint sample sets?

2013-01-11 Thread Roy Smith
I have a list of items. I need to generate n samples of k unique items each. I not only want each sample set to have no repeats, but I also want to make sure the sets are disjoint (i.e. no item repeated between sets). random.sample(items, k) will satisfy the first constraint, but not the sec

Re: Probabilistic unit tests?

2013-01-12 Thread Roy Smith
In article <693d4bb1-8e1e-4de0-9d4d-8a136ea70...@pp8g2000pbb.googlegroups.com>, alex23 wrote: > On 11 Jan, 13:34, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: > > Well, that's not really a task for unit testing. Unit tests, like most > > tests, are well suited to deterministic tests

Re: please solve my problem

2013-01-13 Thread Roy Smith
In article <72e8aec3-4fa3-44af-aad7-8b32196da...@googlegroups.com>, Divya Thakur wrote: > "i want to show image by the help of MEDIA_URL and this is my template file > code for this > not working This is a django-specific question. You would do better to ask on the django-users mailing li

Re: Forcing Python to detect DocumentRoot

2013-01-17 Thread Roy Smith
In article <339d9d6d-b000-4cf3-8534-375e0c44b...@googlegroups.com>, Ferrous Cranus wrote: > When trying to open an html template within Python script i use a relative > path to say go one folder back and open index.html > > f = open( '../' + page ) > > How to say the same thing in an absolute

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

2013-01-18 Thread Roy Smith
Can whoever manages the mailing list block this bozo? In article , kalvinmanual1 wrote: > I have solutions manuals to all problems and exercises in these textbooks. To > get one in an electronic format contact me at: kalvinmanual(at)gmail(dot)com > and let me know its title, author and editio

Re: Safely add a key to a dict only if it does not already exist?

2013-01-19 Thread Roy Smith
In article <50fa1bf1$0$30003$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I wish to add a key to a dict only if it doesn't already exist, but do it > in a thread-safe manner. > > The naive code is: > > if key not in dict: > dict[key] = value > > > but of course there is

Re: Else statement executing when it shouldnt

2013-01-20 Thread Roy Smith
In article <2cc6791f-ba56-406c-a5b0-b23023caf...@googlegroups.com>, eli m wrote: > an else statement is running when it shouldnt be. It is on the last line. > Whenever i am in the math or game function, when i type in main, it goes back > to the start of the program, but it also says not a val

Re: Arent these snippets equivalent?

2013-01-23 Thread Roy Smith
In article , Chris Angelico wrote: > Personally, I'd much rather have a 'while' condition that does > assignment, but that's something Python's unlikely ever to do. > There've been various proposals to make that possible, but ultimately > the only way to make that work is for assignment to be an

Comparing offset-aware and offset-naive datetimes?

2013-01-26 Thread Roy Smith
I have two datetimes. One is offset-naive. The other is offset-aware, but I happen to know its offset is 0 (i.e. GMT). How can I compare these? May the flies of a thousand Norwegian Blue parrots infest the armpits of whoever invented timezones. -- http://mail.python.org/mailman/listinfo/pyt

Re: The utter mess of current timezone definitions (was: Comparing offset-aware and offset-naive datetimes?)

2013-01-27 Thread Roy Smith
In article , Ben Finney wrote: > Roy Smith writes: > > > but I happen to know its offset is 0 (i.e. GMT). > > As further fuel for your hatred: GMT is not the same thing as UTC+0, and > never has been. (See the definitions of those two separate timezones for > more;

Re: Comparing offset-aware and offset-naive datetimes?

2013-01-27 Thread Roy Smith
In article , Ben Finney wrote: > Roy Smith writes: > > > I have two datetimes. One is offset-naive. The other is offset-aware, > > but I happen to know its offset is 0 (i.e. GMT). > > Do you know the timezone of the offset-naive value? > > Or is the above mi

Re: looping versus comprehension

2013-01-31 Thread Roy Smith
In article <5109fe6b$0$11104$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: > On Thu, 31 Jan 2013 02:49:31 +1100, Chris Angelico wrote: > > > it's worth > > noting that list appending is not going to be O(N*N), because it's going > > to allow room for expansion. > > This is true for list.a

Re: Anyway to reduce size of pdf using python script.

2013-02-01 Thread Roy Smith
In article , accessnew...@gmail.com wrote: > I have a batch file that exports ArcGIS pdf maps to a directory. I would like > to include a step in the script where the pdf file is reduced in size instead > of manually opening each file in Acrobat X Pro after the script has run and > doing it th

Re: Distributing methods of a class across multiple files

2012-01-24 Thread Roy Smith
In article <569a94a3-cd84-449b-b0c1-80348014a...@i10g2000pbl.googlegroups.com>, lh wrote: > Is this possible please? I have done some searching but it is hard to > narrow down Google searches to this question. What I would like to do > is, for example: > 1) define a class Foo in file test.py..

Re: Distributing methods of a class across multiple files

2012-01-26 Thread Roy Smith
In article , Dennis Lee Bieber wrote: > The old convention I'd learned was to keep functions down to a > (printer) page (classical 6 lines per inch, 11" high, tractor feed -- so > about 60 lines per function -- possibly extend to a second page if > really needed. The generalization of tha

Disable use of pyc file with no matching py file

2012-01-30 Thread Roy Smith
Every so often (typically when refactoring), I'll remove a .py file and forget to remove the corresponding .pyc file. If I then import the module, python finds the orphaned .pyc and happily imports it. Usually leading to confusing and hard to debug failures. Is there some way to globally tell

Re: speaking at PyCon

2012-01-30 Thread Roy Smith
Wow. As somebody who has given plenty of talks, I can tell you this is an awesome checklist (and most of it not specific to PyCon). Let me add one suggestion -- never, ever, ever, type a URL into a browser connected to the internet in front of a live audience. You never know when you're going

Re: Disable use of pyc file with no matching py file

2012-01-31 Thread Roy Smith
In article , Terry Reedy wrote: > But I am sure that 95% of readers here will be using 3.x withing 10 > years. The only question for them is "When?". This not-well-known new > feature is one straw that some will put on the 'sooner' side of the balance. We would love to move to 3.x, for the be

Re: how to read serial stream of data [newbie]

2012-02-06 Thread Roy Smith
In article , Jean Dupont wrote: > I'd like to read in a stream of data which looks like this: > the device sends out a byte-string of 11 bytes roughly every second: > > B0B0B0B0B03131B0B50D8A > B0B0B0B0B03131B0B50D8A > B0B0B031B63131B0310D8A > B0B034B3323432B3310D8A > B0B03

Re: turbogears 1

2012-02-07 Thread Roy Smith
In article , anon hung wrote: > Hey guys, someone asked me to maintain his old website, trouble is, > it's in python, more trouble is it's in turbogears 1. I'm not fluent > in python but all right, I can learn, but this turbogears > thing.. > > First of all, is it still alive? Looks lik

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