Re: First python program, syntax error in while loop

2013-05-06 Thread Roy Smith
In article , Mark Lawrence wrote: > > while (number != guess) and (tries < 5): > > One of these days I'll work out why some people insist on using > superfluous parentheses in Python code. Could it be that they enjoy > exercising their fingers by reaching for the shift key in conjunction >

Re: First python program, syntax error in while loop

2013-05-06 Thread Roy Smith
In article , Chris Angelico wrote: >On Mon, May 6, 2013 at 11:08 PM, Roy Smith wrote: >> On the other hand, I've long since given up trying to remember operator >> precedence in various languages. If I ever have even the slightest >> doubt, I just go ahead and put in

Re: First python program, syntax error in while loop

2013-05-06 Thread Roy Smith
In article , alex23 wrote: > On May 6, 10:37 pm, Mark Lawrence wrote: > > One of these days I'll work out why some people insist on using > > superfluous parentheses in Python code.  Could it be that they enjoy > > exercising their fingers by reaching for the shift key in conjunction > > with

Re: formatted output

2013-05-07 Thread Roy Smith
In article , Sudheer Joseph wrote: > Dear members, > I need to print few arrays in a tabular form for example below > array IL has 25 elements, is there an easy way to print this as > 5x5 comma separated table? in python > > IL=[] > for i in np.arange(1,bno

Re: multiple versions of python

2013-05-07 Thread Roy Smith
In article <72f93710-9812-441e-8d3d-f221d5698...@googlegroups.com>, sokovic.anamar...@gmail.com wrote: > Hi, > > what is the generally recommended structure when we have into play this type > of problem: > multiple versions of python (both in the sense of main versions and sub > versions, e.g.

Re: Making safe file names

2013-05-07 Thread Roy Smith
In article , Dave Angel wrote: > On 05/07/2013 03:58 PM, Andrew Berg wrote: > > Currently, I keep Last.fm artist data caches to avoid unnecessary API calls > > and have been naming the files using the artist name. However, > > artist names can have characters that are not allowed in file names

Re: multiple versions of python

2013-05-07 Thread Roy Smith
In article , "Colin J. Williams" wrote: > Do you really need more than 2.7.3 and 3.3.1. It's often useful to have older versions around, so you can test your code against them. Lots of projects try to stay compatible with older releases. -- http://mail.python.org/mailman/listinfo/python-li

Re: Making safe file names

2013-05-07 Thread Roy Smith
In article , Dave Angel wrote: > While we're looking for trouble, there's also case insensitivity. > Unclear if the user cares, but tom and TOM are the same file in most > configurations of NT. OSX, too. -- http://mail.python.org/mailman/listinfo/python-list

Re: object.enable() anti-pattern

2013-05-08 Thread Roy Smith
In article <518a123c$0$11094$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: > I'm looking for some help in finding a term, it's not Python-specific but > does apply to some Python code. > > This is an anti-pattern to avoid. The idea is that creating a resource > ought to be the same as "t

Unicode humor

2013-05-08 Thread Roy Smith
Apropos to any of the myriad unicode threads that have been going on recently: http://xkcd.com/1209/ -- http://mail.python.org/mailman/listinfo/python-list

Style question -- plural of class name?

2013-05-08 Thread Roy Smith
FooEntry is a class. How would you describe a list of these in a docstring? "A list of FooEntries" "A list of FooEntrys" "A list of FooEntry's" "A list of FooEntry instances" The first one certainly sounds the best, but it seems wierd to change the spelling of the class name to make it plural

Re: Making safe file names

2013-05-08 Thread Roy Smith
In article , Dennis Lee Bieber wrote: > On Tue, 07 May 2013 18:10:25 -0500, Andrew Berg > declaimed the following in > gmane.comp.python.general: > > > None of these would work because I would have no idea which file stores > > data for which artist without writing code to figure it out. If I

Re: Making safe file names

2013-05-08 Thread Roy Smith
In article <518b00a2$0$29997$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > > When somebody types in > > "Blue Oyster Cult", they really mean "Blue Oyster Cult", > > Surely they really mean Blue Öyster Cult. Yes. The oomlaut was there when I typed it. Who knows what happened

Re: Making safe file names

2013-05-09 Thread Roy Smith
In article <518b133b$0$29997$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I suspect that the only way to be completely ungoogleable would be to > name yourself something common, not something obscure. http://en.wikipedia.org/wiki/The_band -- http://mail.python.org/mailman/lis

Re: object.enable() anti-pattern

2013-05-09 Thread Roy Smith
In article <518b32ef$0$11120$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: > There is no sensible use-case for creating a file without opening it. Sure there is. Sometimes just creating the name in the file system is all you want to do. That's why, for example, the unix "touch" command

Re: object.enable() anti-pattern

2013-05-09 Thread Roy Smith
In article <518be931$0$29997$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > There is no sensible use-case for creating a file OBJECT unless it > initially wraps an open file pointer. OK, I guess that's a fair statement. But mostly because a python file object only exposes those

Re: object.enable() anti-pattern

2013-05-09 Thread Roy Smith
In article , Michael Speer wrote: > By his reasoning it simply shouldn't exist. Instead you would access the > information only like this: > > with open("myfile.dat") as f: > data = f.read() The problem with things like file objects is they model external real-world entities, which have ext

Re: object.enable() anti-pattern

2013-05-09 Thread Roy Smith
In article <518c5bbc$0$29997$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I must admit I am astonished at how controversial the opinion "if your > object is useless until you call 'start', you should automatically call > 'start' when the object is created" has turned out to be

Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread Roy Smith
In article , Chris Angelico wrote: > The first hard disk I ever worked with stored 20MB in the space of a > 5.25" slot (plus its associated ISA controller card). Heh. The first hard disk I ever worked with stored 2.4 MB in 6U of rack space (plus 4 Unibus cards worth of controller). That's no

Re: object.enable() anti-pattern

2013-05-09 Thread Roy Smith
In article <518c7f05$0$29997$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > there is no way to create a C file descriptor in a closed state. Such > a thing does not exist. If you have a file descriptor, the file is > open. Once you close it, the file descriptor is no longer vali

Re: Message passing syntax for objects | OOPv2

2013-05-10 Thread Roy Smith
On May 10, 2013, at 7:49 AM, William Ray Wing wrote: > On May 10, 2013, at 12:55 AM, Roy Smith wrote: > >> In article , >> Chris Angelico wrote: >> >>> The first hard disk I ever worked with stored 20MB in the space of a >>> 5.25" slot (plus

Re: object.enable() anti-pattern

2013-05-10 Thread Roy Smith
In article <518cc239$0$29997$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > > int fd = 37; > > > > I've just created a file descriptor. There is not enough information > > given to know if it corresponds to an open file or not. > > No, you haven't created a file descriptor. You

Re: object.enable() anti-pattern

2013-05-10 Thread Roy Smith
In article , Robert Kern wrote: > I'd be curious to see in-the-wild instances of the anti-pattern that > you are talking about, then. I think everyone agrees that entirely > unmotivated "enable" methods should be avoided, but I have my doubts > that they come up very often. As I mentioned e

Re: object.enable() anti-pattern

2013-05-10 Thread Roy Smith
In article , Oscar Benjamin wrote: > It's not just because of exceptions. In C++ virtual method calls in a > constructor for a class A will always call the methods of class A even > if the object being constructed is actually of a subclass B because > the B part of the object isn't initialised w

Re: object.enable() anti-pattern

2013-05-10 Thread Roy Smith
In article , Chris Angelico wrote: > On Sat, May 11, 2013 at 12:37 AM, Roy Smith wrote: > > I suppose, if I had a class like this, I would write a factory function > > which called the constructor and post-construction initializer. And > > then I would make the

Re: object.enable() anti-pattern

2013-05-10 Thread Roy Smith
In article , Chris Angelico wrote: > > Each language has its own set of best practices. Trying to write C++ > > code using Python patterns is as bad as trying to write Python code > > using C++ patterns. > > Agreed, in generality. But what is actually gained by hiding data from > yourself? Y

Re: object.enable() anti-pattern

2013-05-10 Thread Roy Smith
In article , Nobody wrote: > However: there are situations where it is useful to be able to separate > the simple task of creating an object from more invasive actions such as > system calls. Particularly in multi-threaded or real-time code (although > the latter is a non-starter in Python for m

Re: object.enable() anti-pattern

2013-05-11 Thread Roy Smith
In article <518df898$0$29997$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I never intended to give the impression that *any* use of a separate > "enable" method call was bad. I certainly didn't intend to be bogged > down into a long discussion about the minutia of file descrip

Re: Illegal seek error with seek() and os.lseek()

2013-05-14 Thread Roy Smith
In article <50bf9366-46e0-4a7f-865b-3f7c7b0f6...@googlegroups.com>, krishna2pra...@gmail.com wrote: > I am trying to use os.open() and os.lseek() methods to operate on a device > file in Linux. My code goes something like this - > > # first, open the file as a plain binary > try: > self.

Re: Determine actually given command line arguments

2013-05-15 Thread Roy Smith
In article , Henry Leyh wrote: > Is there a simple way to determine which > command line arguments were actually given on the commandline, i.e. does > argparse.ArgumentParser() know which of its namespace members were > actually hit during parse_args(). I think what you're looking for is sys

Re: Determine actually given command line arguments

2013-05-15 Thread Roy Smith
In article , Henry Leyh wrote: >On 15.05.2013 14:24, Roy Smith wrote: >> In article , >> Henry Leyh wrote: >> >>> Is there a simple way to determine which >>> command line arguments were actually given on the commandline, i.e. does >>> argpa

Re: Two Dictionaries and a Sum!

2013-05-18 Thread Roy Smith
In article <6012d69f-b65e-4d65-90c4-f04876853...@googlegroups.com>, Bradley Wright wrote: > Confusing subject for a confusing problem (to a novice like me of course!) > Thx for the help in advance folks > > I have (2) dictionaries: > > prices = { > "banana": 4, > "apple": 2, > "ora

Re: python script is not running

2013-05-18 Thread Roy Smith
In article , Chris Angelico wrote: > On Sat, May 18, 2013 at 8:12 PM, Avnesh Shakya wrote: > > avin@hp:~$ crontab -e > > then type - > > */2 * * * * python /home/avin/data/try.py > > > > You may need to put an explicit path to your Python interpreter. Type: > > $ which python > > and put tha

Re: How to write fast into a file in python?

2013-05-18 Thread Roy Smith
In article , Dennis Lee Bieber wrote: > tOn Sat, 18 May 2013 08:49:55 +0100, Fábio Santos > declaimed the following in > gmane.comp.python.general: > > > > You mentioned "\n" translating to two lines, but this won't happen. Windows > > will not mess with what you write to your file. It's just

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

2013-05-19 Thread Roy Smith
In article , Ned Batchelder wrote: > So here's a question for people who remember coming up from beginner: as > you moved from exercises like those in Learn Python the Hard Way, up to > your own self-guided work on small projects, what project were you > working on that made you feel independ

Re: subclassing from unittest

2013-05-23 Thread Roy Smith
In article , Ulrich Eckhardt wrote: > if you have an intermediate class derived > from unittest.TestCase, that class on its own will be considered as test > case! If this is not what you want but you still want common > functionality in a baseclass, create a mixin and then derive from both >

Debugging parallel nose tests?

2013-05-23 Thread Roy Smith
I've got a suite of about 150 tests written using unittest. It takes 5-10 minutes to run, so I'd really like to use nose to run things in parallel. The problem is, when I do that, I get lots of test failures. Obviously, we've got some kind of inter-test dependency that I haven't been able to

Re: Debugging parallel nose tests?

2013-05-23 Thread Roy Smith
In article , Dave Angel wrote: > On 05/23/2013 09:09 AM, Roy Smith wrote: > > > > > > > > nosetests --process-timeout=60 --processes=40 test_api.py > > > > Do you have a 40-processor system? No, but many of the tests are I/O bound. > And

Re: Debugging parallel nose tests?

2013-05-24 Thread Roy Smith
On May 24, 2013, at 5:05 AM, Jean-Michel Pichavant wrote: > - Original Message - >> In article , >> Dave Angel wrote: >> >>> On 05/23/2013 09:09 AM, Roy Smith wrote: >>>> >>>> >>>> >>>> nosetests -

Re: Utility to locate errors in regular expressions

2013-05-24 Thread Roy Smith
In article , Malte Forkel wrote: > Finding out why a regular expression does not match a given string can > very tedious. I would like to write a utility that identifies the > sub-expression causing the non-match. My idea is to use a parser to > create a tree representing the complete regular ex

Re: Utility to locate errors in regular expressions

2013-05-24 Thread Roy Smith
In article , Devin Jeanpierre wrote: > On Fri, May 24, 2013 at 8:58 AM, Malte Forkel wrote: > > As a first step, I am looking for a parser for Python regular > > expressions, or a Python regex grammar to create a parser from. > > the sre_parse module is undocumented, but very usable. > > > Bu

Re: Debugging parallel nose tests?

2013-05-24 Thread Roy Smith
In article , Roy Smith wrote: > Is there some way to make nose print a report of how it partitioned the > tests across the various processes? I never found such a feature, but I did figure out a way to do what I needed. We use a system of unique id's to track HTTP requests t

Preventing nose from finding setup.py

2013-05-24 Thread Roy Smith
We've got a package (with an empty __init__.py), which contains a setup.py file. When I run nosetests, the test discovery code finds setup.py, thinks it's a test, and tries to run it (with predictably poor results). Is there some way to mark this file as not a test? If it was a method in a fi

Re: Preventing nose from finding setup.py

2013-05-24 Thread Roy Smith
In article , Roy Smith wrote: > We've got a package (with an empty __init__.py), which contains a > setup.py file. When I run nosetests, the test discovery code finds > setup.py, thinks it's a test, and tries to run it (with predictably poor > results). Ugh, I descri

Re: Python Magazine

2013-05-24 Thread Roy Smith
In article <27969350-4dd8-4afa-881a-b4a2364b3...@googlegroups.com>, DRJ Reddy wrote: > Planning to start a python online chronicle.What you want to see in it. :) Issue 1: "Whitespace as syntax: mistake or magic?" "Python 3 vs. IPv6: who will win the race for early adoption?" "Did Python 3 br

Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Roy Smith
In article <78192328-b31b-49d9-9cd6-ec742c092...@googlegroups.com>, lokeshkopp...@gmail.com wrote: > On Friday, May 24, 2013 1:34:51 PM UTC+5:30, lokesh...@gmail.com wrote: > > i need to write a code which can sort the list in order of 'n' without use > > builtin functions > > > > can anyone h

Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Roy Smith
In article <74e33270-a79a-4878-a400-8a6cda663...@googlegroups.com>, lokeshkopp...@gmail.com wrote: > ya steven i had done the similar logic but thats not satisfying my professor > he had given the following constrains > 1. No in-built functions should be used > 2. we are expecting a O(n) solut

Re: Python Magazine

2013-05-25 Thread Roy Smith
In article , Chris Angelico wrote: > > Also, comparison of Python flavors (CPython, PyPy, Cython, Stackles, etc.) Stackles? That sounds like breakfast cereal. "New all-natural stackles, with 12 essential vitamins, plus fiber!" -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Magazine

2013-05-25 Thread Roy Smith
In article <51a0caac$0$30002$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Sat, 25 May 2013 16:41:58 +1000, Chris Angelico wrote: > > > On Sat, May 25, 2013 at 4:38 PM, zoom wrote: > >> But why would anyone want to use IPv6? > > > > I hope you're not serious :) > > He's pl

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-25 Thread Roy Smith
In article <15a1bb3a-514c-454e-a966-243c84123...@googlegroups.com>, John Ladasky wrote: > Because someone's got to say it... "The generation of random numbers is too > important to be left to chance." ‹ Robert R. Coveyou Absolutely. I know just enough about random number generation to unders

Re: Python Magazine

2013-05-25 Thread Roy Smith
In article <7cd17be8-d455-4db8-b8d0-ccc757db5...@googlegroups.com>, John Ladasky wrote: > On Saturday, May 25, 2013 8:30:19 AM UTC-7, Roy Smith wrote: > > From my phone, I > > can call any other phone anywhere in the world. But I can't talk > > directly to

Re: Python Magazine

2013-05-25 Thread Roy Smith
In article <8f19e20c-4f77-43dc-a732-4169e482d...@googlegroups.com>, John Ladasky wrote: > A perfectly fair point, Roy. It's just when you started suggesting > connecting to your neighbor's file server -- well, that's not something that > many people would ordinarily do. So, my mind leaped to

Re: Short-circuit Logic

2013-05-26 Thread Roy Smith
In article <5f101d70-e51f-4531-9153-c92ee2486...@googlegroups.com>, Ahmed Abdulshafy wrote: > Hi, > I'm having a hard time wrapping my head around short-circuit logic that's > used by Python, coming from a C/C++ background; so I don't understand why the > following condition is written this wa

Re: Solving the problem of mutual recursion

2013-05-26 Thread Roy Smith
In article , Jussi Piitulainen wrote: > A light-weighter way is to have each task end by assigning the next > task and returning, instead of calling the next task directly. When a > task returns, a driver loop will call the assigned task, which again > does a bounded amount of work, assigns the

Re: Future standard GUI library

2013-05-26 Thread Roy Smith
In article <20130526194310.9cdb1be80b42c7fdf0ba5...@gmx.net>, Wolfgang Keller wrote: > HTTP will never be a suitable transport layer for a RPC protocol. What, in particular, is wrong with HTTP for doing RPC? RPC is pretty straight-forward. Take this method, run it over there, with these arg

Re: Cutting a deck of cards

2013-05-26 Thread Roy Smith
In article <4d02f46f-8264-41bf-a254-d1c204696...@googlegroups.com>, RVic wrote: > Suppose I have a deck of cards, and I shuffle them > > import random > cards = [] > decks = 6 > cards = list(range(13 * 4 * decks)) > random.shuffle(cards) > > So now I have an array of cards. I would like to cut

Re: Future standard GUI library

2013-05-26 Thread Roy Smith
In article , Michael Torrie wrote: > On good thing web development has brought us is the knowledge that > modularization and layers are a brilliant idea. Modularization and layers were a brilliant idea long before the web came around. -- http://mail.python.org/mailman/listinfo/python-list

Re: Short-circuit Logic

2013-05-26 Thread Roy Smith
In article , Terry Jan Reedy wrote: > On 5/26/2013 7:11 AM, Ahmed Abdulshafy wrote: > > > if not allow_zero and abs(x) < sys.float_info.epsilon: > > print("zero is not allowed") > > The reason for the order is to do the easy calculation first and the > harder one only i

Re: serialize a class to XML and back

2013-05-26 Thread Roy Smith
In article , Chris Rebert wrote: > On May 23, 2013 3:42 AM, "Schneider" wrote: > > > > Hi list, > > > > how can I serialize a python class to XML? Plus a way to get the class > back from the XML? > > There's pyxser: http://pythonhosted.org/pyxser/ > > > My aim is to store instances of this cl

Re: serialize a class to XML and back

2013-05-26 Thread Roy Smith
In article <51a28f42$0$15870$e4fe5...@news.xs4all.nl>, Irmen de Jong wrote: > On 26-5-2013 22:48, Roy Smith wrote: > > > The advantage of pickle over json is that pickle can serialize many > > types of objects that json can't. The other side of the coin is that

Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-27 Thread Roy Smith
In article <10be5c62-4c58-4b4f-b00a-82d85ee4e...@googlegroups.com>, Bryan Britten wrote: > If I use the following code: > > > import urllib > > urlStr = "https://stream.twitter.com/1/statuses/sample.json"; > > fileHandle = urllib.urlopen(urlStr) > > twtrText = fileHandle.readlines() > > >

Re: Future standard GUI library

2013-05-27 Thread Roy Smith
In article , Chris Angelico wrote: > I'll use XML when I have to, but if I'm inventing my own protocol, > nope. There are just too many quirks with it. How do you represent an > empty string named Foo? > > > > or equivalently > > > > How do you represent an empty list named Foo? The same w

Re: detect key conflict in a JSON file

2013-05-29 Thread Roy Smith
In article , Jabba Laci wrote: > I have a growing JSON file that I edit manually and it might happen > that I repeat a key. If this happens, I would like to get notified. The real answer here is that JSON is probably not the best choice for large files that get hand-edited. For data that you

Re: detect key conflict in a JSON file

2013-05-29 Thread Roy Smith
hey both have the same GIGO issue. > How to process (read) YAML files in Python? Take a look at http://pyyaml.org/ --- Roy Smith r...@panix.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Short-circuit Logic

2013-05-30 Thread Roy Smith
In article , Chris Angelico wrote: > On Thu, May 30, 2013 at 3:10 PM, Steven D'Aprano > wrote: > > # Wrong, don't do this! > > x = 0.1 > > while x != 17.3: > > print(x) > > x += 0.1 > > > > Actually, I wouldn't do that with integers either. There are too many > ways that a subsequent e

Re: Short-circuit Logic

2013-05-30 Thread Roy Smith
In article , Jussi Piitulainen wrote: > I wonder why floating-point errors are not routinely discussed in > terms of ulps (units in last position). Analysis of error is a complicated topic (and is much older than digital computers). These sorts of things come up in the real world, too. For

Re: Short-circuit Logic

2013-05-30 Thread Roy Smith
In article , Nobody wrote: > On Thu, 30 May 2013 19:38:31 -0400, Dennis Lee Bieber wrote: > > > Measuring 1 foot from the 1000 foot stake leaves you with any error > > from datum to the 1000 foot, plus any error from the 1000 foot, PLUS any > > azimuth error which would contribute to shorte

Re: Short-circuit Logic

2013-05-31 Thread Roy Smith
In article <51a86319$0$29966$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > In an early talk Ken was explaining the advantages of tolerant > comparison. A member of the audience asked incredulously, > “Surely you don’t mean that when A=B and B=C, A may not equal C

Re: Python #ifdef

2013-06-02 Thread Roy Smith
In article , Erik Max Francis wrote: > On 05/29/2013 08:05 AM, Chris Angelico wrote: > > It's not a bad tool. I used it as a sort of PHP preprocessor, because > > requirements at work had me wanting to have a source file defining a > > PHP class and having an autogenerated section in the middle

Re: Beginner question

2013-06-04 Thread Roy Smith
In article , Larry Hudson wrote: > def partdeux(): > print('A man lunges at you with a knife!') > option = input('Do you DUCK or PARRY? ').lower() > success = random.randint(0, 1) > if success: > if option == 'duck': > print('He tumbles over you') >

Re: [ANNOUNCE] greenlet 0.4.1

2013-06-07 Thread Roy Smith
In article , Ralf Schmitt wrote: > Hi, > > I have uploaded greenlet 0.4.1 to PyPI: > https://pypi.python.org/pypi/greenlet > > What is it? > --- > The greenlet module provides coroutines for python. coroutines allow > suspending and resuming execution at certain locations. > > concurr

Re: Redirecting to a third party site with injected HTML

2013-06-09 Thread Roy Smith
On Sunday, June 9, 2013 8:22:17 PM UTC+3, Fábio Santos wrote: >> This does not seem like a python question, instead a HTML/JavaScript one. In article <0021fabe-78ed-4e79-8cdf-468b4ccc7...@googlegroups.com>, guytam...@gmail.com wrote: > its a python question since the request is received on a py

Re: [newbie] problem with if then

2013-06-09 Thread Roy Smith
In article , Jean Dubois wrote: > I'm writing some code to check whether an url is available or not, > therefore I make use of a wget-command in Linux and then check whether > this is successful In general, "shelling out" to run a command-line utility should be the last resort. It's slower,

Re: problem with if then

2013-06-09 Thread Roy Smith
In article <20165c85-4cc3-4b79-943b-82443e4a9...@w7g2000vbw.googlegroups.com>, Jean Dubois wrote: > But, really, > > once you've done all that (and it's worth doing as an exercise), rewrite > > your code to use urllib2 or requests.  It'll be a lot easier. > > Could you show me how to code the

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Roy Smith
In article , Rui Maciel wrote: > Essentially, a Model object stores lists of Point objects and Line objects, > and Line objects include references to Point objects which represent the > starting and ending point of a line. > > class Point: > position = [] > > def __init__(sel

Split a list into two parts based on a filter?

2013-06-10 Thread Roy Smith
I have a list, songs, which I want to divide into two groups. Essentially, I want: new_songs = [s for s in songs if s.is_new()] old_songs = [s for s in songs if not s.is_new()] but I don't want to make two passes over the list. I could do: new_songs = [] old_songs = [] for s in songs: if s.

Re: Split a list into two parts based on a filter?

2013-06-10 Thread Roy Smith
In article , Roel Schroeven wrote: > new_songs, old_songs = [], [] > [(new_songs if s.is_new() else old_songs).append(s) for s in songs] Thanks kind of neat, thanks. I'm trying to figure out what list gets created and discarded. I think it's [None] * len(songs). -- http://mail.python.org/ma

Re: Split a list into two parts based on a filter?

2013-06-11 Thread Roy Smith
In article , Chris Angelico wrote: > On Wed, Jun 12, 2013 at 1:28 AM, Serhiy Storchaka wrote: > > 11.06.13 01:50, Chris Angelico написав(ла): > > > >> On Tue, Jun 11, 2013 at 6:34 AM, Roy Smith wrote: > >>> > >>> new_songs = [s for s in

Re: Split a list into two parts based on a filter?

2013-06-11 Thread Roy Smith
In article , Serhiy Storchaka wrote: > 11.06.13 07:11, Roy Smith написав(ла): > > In article , > > Roel Schroeven wrote: > > > >> new_songs, old_songs = [], [] > >> [(new_songs if s.is_new() else old_songs).append(s) for s in songs] > >

Why doesn't nose see my plugin?

2013-06-11 Thread Roy Smith
I'm attempting to write a nose plugin. Nosetests (version 1.3.0) is not seeing it. I'm running python 2.7.3. The plugin itself is: mongo_reporter.py: import nose.plugins import logging log = logging.getLogger('nose.plugins.mongoreporter') clas

Re: Why doesn't nose see my plugin?

2013-06-11 Thread Roy Smith
In article <69d4486b-d2ff-4830-b16e-f3f6ea73d...@kt20g2000pbb.googlegroups.com>, alex23 wrote: > On Jun 12, 10:54 am, Roy Smith wrote: > > I'm attempting to write a nose plugin.  Nosetests (version 1.3.0) is not > > seeing it. > > &g

Re: Why doesn't nose see my plugin?

2013-06-11 Thread Roy Smith
In article <0d704515-46c9-486a-993c-ff5add3c9...@rh15g2000pbb.googlegroups.com>, alex23 wrote: > On Jun 12, 11:43 am, Roy Smith wrote: > > Just to see what would happen, I tried changing it to: > > > >     entry_points = { > >         

Re: Split a list into two parts based on a filter?

2013-06-12 Thread Roy Smith
In article , Phil Connell wrote: > > Well, continuing down this somewhat bizarre path: > > > > new_songs, old_songs = [], [] > > itertools.takewhile( > > lambda x: True, > > (new_songs if s.is_new() else old_songs).append(s) for s in songs) > > ) > > > > I'm not sure I got the syntax

Re: Why doesn't nose see my plugin? (FIXED)

2013-06-12 Thread Roy Smith
In article , Roy Smith wrote: >setup( >name = "Mongo Reporter", >version = "0.0", >entry_points = { >'nose.plugins.1.10': ['mongoreporter = mongo_reporter.MongoReporter'], >}, >) The problem turned ou

Re: Version Control Software

2013-06-12 Thread Roy Smith
In article <98c13a55-dbf2-46a7-a2aa-8c5f052ff...@googlegroups.com>, cutems93 wrote: > I am looking for an appropriate version control software for python > development, and need professionals' help to make a good decision. Currently > I am considering four software: git, SVN, CVS, and Mercuria

Re: Version Control Software

2013-06-13 Thread Roy Smith
In article <2644d0de-9a81-41aa-b27a-cb4535964...@googlegroups.com>, cutems93 wrote: > Thank you everyone for such helpful responses! Actually, I have one more > question. Does anybody have experience with closed source version control > software? If so, why did you buy it instead of downloadin

Re: Version Control Software

2013-06-13 Thread Roy Smith
In article , Tim Chase wrote: > On 2013-06-13 10:20, Serhiy Storchaka wrote: > > 13.06.13 05:41, Tim Chase написав(ла): > > > -hg: last I checked, can't do octopus merges (merges with more > > > than two parents) > > > > > > +git: can do octopus merges > > > > Actually it is possible i

Re: A certainl part of an if() structure never gets executed.

2013-06-13 Thread Roy Smith
In article <8a75b1e4-41e8-45b5-ac9e-6611a4698...@g9g2000pbd.googlegroups.com>, rusi wrote: > On Jun 12, 8:20 pm, Zero Piraeus wrote: > > : > > > > On 12 June 2013 10:55, Neil Cerutti wrote: > > > > > > > > > He's definitely trolling. I can't think of any other reason to > > > make it so hard

Re: My son wants me to teach him Python

2013-06-13 Thread Roy Smith
In article <545a441b-0c2d-4b1e-82ae-024b011a4...@e1g2000pbo.googlegroups.com>, rusi wrote: > Python is at least two things, a language and a culture. This is true of all languages. Hang out on the PHP, Ruby, Python, etc, forums and you quickly learn that the cultures are as different (or mor

Re: RFD: rename comp.lang.python to comp.support.superhost

2013-06-14 Thread Roy Smith
In article <8a333cd0-c1cf-4f41-ac49-65f0b23ed...@ow4g2000pbc.googlegroups.com>, alex23 wrote: > On Jun 14, 2:24 am, Íéêüëáïò Êïýñáò wrote: > > iam researchign a solution to this as we speak. > > Spamming endless "ZOMG HELP ME I'M INCOMPETENT" posts isn't "research". But it could be an argume

Re: Version Control Software

2013-06-14 Thread Roy Smith
In article , Anssi Saari wrote: > I have some experience with ClearCase. I don't know why anyone would buy > it since it's bloated and slow and hard to use and likes to take over > your computer. ClearCase was the right solution to certain specific problems which existed 20 years ago. It does

Re: Version Control Software

2013-06-15 Thread Roy Smith
In article , Chris Angelico wrote: > On Sat, Jun 15, 2013 at 3:39 PM, Tim Delaney > wrote: > > I can absolutely confirm how much ClearCase slows things down. I completely > > refused to use dynamic views for several reasons - #1 being that if you lost > > your network connection you couldn't wo

Re: A few questiosn about encoding

2013-06-15 Thread Roy Smith
In article , Grant Edwards wrote: > There is some ambiguity in the term "byte". It used to mean the > smallest addressable unit of memory (which varied in the past -- at > one point, both 20 and 60 bit "bytes" were common). I would have defined it more like, "some arbitrary collection of adja

Re: Version Control Software

2013-06-16 Thread Roy Smith
In article , Chris メKwpolskaモ Warrick wrote: > (I’m using wc -c to count the bytes in all files there are. du is > unaccurate with files smaller than 4096 bytes.) It's not that du is not accurate, it's that it's measuring something different. It's measuring how much disk space the file

Why is regex so slow?

2013-06-18 Thread Roy Smith
I've got a 170 MB file I want to search for lines that look like: [2010-10-20 16:47:50.339229 -04:00] INFO (6): songza.amie.history - ENQUEUEING: /listen/the-station-one This code runs in 1.3 seconds: -- import re pattern = re.compile(r'ENQUEUEING: /listen/(.*)') co

Re: Why is regex so slow?

2013-06-18 Thread Roy Smith
t; pattern, you could just as easily split the line yourself instead of > creating a group. At this point, I'm not so much interested in making this faster as understanding why it's so slow. I'm tempted to open this up as a performance bug against the regex module (which I assume

Re: Why is regex so slow?

2013-06-18 Thread Roy Smith
In article , Mark Lawrence wrote: > Out of curiousity have the tried the new regex module from pypi rather > than the stdlib version? A heck of a lot of work has gone into it see > http://bugs.python.org/issue2636 I just installed that and gave it a shot. It's *slower* (and, much higher var

Re: Why is regex so slow?

2013-06-18 Thread Roy Smith
On Tuesday, June 18, 2013 2:10:16 PM UTC-4, Johannes Bauer wrote: > Resulting file has a size of 91530018 and md5 of > > 2d20c3447a0b51a37d28126b8348f6c5 (just to make sure we're on the same > > page because I'm not sure the PRNG is stable across Python versions). If people want to test against m

Re: Why is regex so slow?

2013-06-18 Thread Roy Smith
On Tuesday, June 18, 2013 4:05:25 PM UTC-4, Antoine Pitrou wrote: > One invokes a fast special-purpose substring searching routine (the > str.__contains__ operator), the other a generic matching engine able to > process complex patterns. It's hardly a surprise for the specialized routine > to be f

Re: Why is regex so slow?

2013-06-19 Thread Roy Smith
On Wednesday, June 19, 2013 9:21:43 AM UTC-4, Duncan Booth wrote: > I'd just like to point out that your simple loop is looking at every > character of the input string. The simple "'ENQ' not in line" test can look > at the third character of the string and if it's none of 'E', 'N' or 'Q' > ski

  1   2   3   4   5   6   7   8   9   10   >