How to install easy_install on windows ?

2011-08-16 Thread smith jack
it needs read registry, but the python i used is extracted from .zip, so there is no record in the registry, what should i do in order to install easy_install for my python environment? -- http://mail.python.org/mailman/listinfo/python-list

Re: testing if a list contains a sublist

2011-08-16 Thread Roy Smith
In article <8739h18rzj@dpt-info.u-strasbg.fr>, Alain Ketterlin wrote: > Roy Smith writes: > > >> what is the best way to check if a given list (lets call it l1) is > >> totally contained in a second list (l2)? > > [...] > > import re > > &

Failed to create virtual environment when using --relocatable option, what's wrong?

2011-08-16 Thread smith jack
all things works well without --relocatable option, the error info when using --relocatable option is as follows : F:\PythonEnv\djangoEnv>virtualenv f:\PythonEnv\djangoEnv2 --relocatable PYTHONHOME is set. You *must* activate the virtualenv before using it The environment doesn't have a file f:\P

why i cannot import djang?

2011-08-16 Thread smith jack
this package is already in the site-packages directory, but i cannot import it , it's really confusing ... -- http://mail.python.org/mailman/listinfo/python-list

Some warning appears when installing virtualenv, does it matters?

2011-08-17 Thread smith jack
the warning is just as follows E:\Tools>pip install virtualenv Downloading/unpacking virtualenv Downloading virtualenv-1.6.4.tar.gz (1.9Mb): 1.9Mb downloaded Running setup.py egg_info for package virtualenv warning: no previously-included files matching '*.*' found under directory ' do

How to build python using visual studio 2005?

2011-08-17 Thread smith jack
anybody here have build it correctly? how to make a msi file just as the official site did? is there any detailed tutorial online? -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntactic sugar for assignment statements: one value to multiple targets?

2011-08-18 Thread Roy Smith
In article <16ea4848-db0c-489a-968c-ca40700f5...@m5g2000prh.googlegroups.com>, gc wrote: > I frequently need to initialize several variables to the same > value, as I'm sure many do. Sometimes the value is a constant, often > zero; sometimes it's more particular, such as defaultdict(list). I us

Re: How to convert a list of strings into a list of variables

2011-08-19 Thread Roy Smith
In article <2ab25f69-6017-42a6-a7ef-c71bc2ee8...@l2g2000vbn.googlegroups.com>, noydb wrote: > How would you convert a list of strings into a list of variables using > the same name of the strings? > > So, ["red", "one", "maple"] into [red, one, maple] > > Thanks for any help! I'm not sure wh

Re: relative speed of incremention syntaxes (or "i=i+1" VS "i+=1")

2011-08-21 Thread Roy Smith
In article , Christian Heimes wrote: > Am 21.08.2011 19:27, schrieb Andreas Löscher: > > As for using Integers, the first case (line 1319 and 1535) are true and > > there is no difference in Code. However, Python uses a huge switch-case > > construct to execute it's opcodes and INPLACE_ADD cames

Re: try... except with unknown error types

2011-08-21 Thread Roy Smith
In article <7xty9ahb84@ruckus.brouhaha.com>, Paul Rubin wrote: > It's a retail application that would cause some business disruption and > a pissed off customer if the program went down. Also it's in an > embedded box on a customer site. It's not in Antarctica or anything > like that, but

Re: try... except with unknown error types

2011-08-21 Thread Roy Smith
In article <4e51a205$0$29974$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > http://www.codinghorror.com/blog/2011/04/working-with-the-chaos-monkey.html I *love* being the Chaos Monkey! A few jobs ago, I had already turned in my resignation and was a short-timer, counting down t

Re: Order of addresses returned by socket.gethostbyname_ex()

2011-08-22 Thread Roy Smith
In article <356978ef-e9c1-48fd-bb87-849fe8e27...@p5g2000vbl.googlegroups.com>, Tomas Lidén wrote: > In what order are the addresses returned by socket.gethostbyname_ex()? > > We know that gethostbyname() is indeterministic but hope that > gethostbyname_ex() has a specified order. Why would yo

Re: Order of addresses returned by socket.gethostbyname_ex()

2011-08-22 Thread Roy Smith
In article , Tomas Lidén wrote: > In this particular case we have a host with several connections (LAN, > WIFI, VmWare adapters etc). When using gethostbyname() we got a VmWare > adapter but we wanted to get the LAN (or the "best" connection to our > server). Figuring out which is the best con

Re: Order of addresses returned by socket.gethostbyname_ex()

2011-08-22 Thread Roy Smith
In article <034ff4bf-e3e4-47ff-9a6c-195412431...@s20g2000yql.googlegroups.com>, Tomas Lidén wrote: > Basically I was asking about the contract for this method.. hoping > that it is deterministic. The contract for socket.gethostbyname_ex() is described at http://docs.python.org/library/socket.

is there any principle when writing python function

2011-08-23 Thread smith jack
i have heard that function invocation in python is expensive, but make lots of functions are a good design habit in many other languages, so is there any principle when writing python function? for example, how many lines should form a function? -- http://mail.python.org/mailman/listinfo/python-li

Re: is there any principle when writing python function

2011-08-23 Thread Roy Smith
In article , smith jack wrote: > i have heard that function invocation in python is expensive, but make > lots of functions are a good design habit in many other languages, so > is there any principle when writing python function? > for example, how many lines should form a funct

Re: is there any principle when writing python function

2011-08-23 Thread Roy Smith
In article , Peter Otten <__pete...@web.de> wrote: > smith jack wrote: > > > i have heard that function invocation in python is expensive, but make > > lots of functions are a good design habit in many other languages, so > > is there any principle when writing py

why i cannot invoke python script using command line?

2011-08-23 Thread smith jack
but i can invoke it in eclipse, what's wrong? the script refered to another python script in eclipse project. f:\project\src\a.py f:\project\src\lib\b.py there is such lines in a.py from lib import b i can invoke a.py very well in eclipse but failed when using python f:\project\src\a.py, what's

truncating strings

2011-08-23 Thread Roy Smith
I want to log a string but only the first bunch of it, and add "..." to the end if it got truncated. This certainly works: log_message = message if len(log_message) >= 50: log_message = log_message[:50] + '...' logger.error("FAILED: '%s', '%s', %s, %s" %

Re: [OT-ish] Design principles: no bool arguments

2011-08-25 Thread Roy Smith
In article <4e55f604$0$29973$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > [1] This is the Internet. There's *always* a certain amount of disagreement. No there's not. -- http://mail.python.org/mailman/listinfo/python-list

Re: is there any principle when writing python function

2011-08-26 Thread Roy Smith
In article , t...@thsu.org wrote: > On Aug 23, 7:59 am, smith jack wrote: > > i have heard that function invocation in python is expensive, but make > > lots of functions are a good design habit in many other languages, so > > is there any principle when writing pyt

Re: Mastering Python... Best Resources?

2011-08-26 Thread Roy Smith
In article <2309ec4b-e9a3-4330-9983-1c621ac16...@ea4g2000vbb.googlegroups.com>, Travis Parks wrote: > I know the Python syntax pretty well. I know a lot of the libraries > and tools. When I see professional Python programmer's code, I am > often blown away with the code. I realized that even th

Re: how to format long if conditions

2011-08-27 Thread Roy Smith
In article , Arnaud Delobelle wrote: > Hi all, > > I'm wondering what advice you have about formatting if statements with > long conditions (I always format my code to <80 colums) > [...] > if (isinstance(left, PyCompare) and isinstance(right, PyCompare) > and left.compl

Re: is there any principle when writing python function

2011-08-27 Thread Roy Smith
Chris Angelico wrote: > the important > considerations are not "will it take two extra nanoseconds to execute" > but "can my successor understand what the code's doing" and "will he, > if he edits my code, have a reasonable expectation that he's not > breaking stuff". These are always important.

Re: Record seperator

2011-08-27 Thread Roy Smith
In article <4e592852$0$29965$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > open("file.txt") # opens the file > .read() # reads the contents of the file > .split("\n\n")# splits the text on double-newlines. The biggest problem with this code is that read() slurp

Re: Record seperator

2011-08-27 Thread Roy Smith
In article , Terry Reedy wrote: > On 8/27/2011 1:45 PM, Roy Smith wrote: > > In article<4e592852$0$29965$c3e8da3$54964...@news.astraweb.com>, > > Steven D'Aprano wrote: > > > >> open("file.txt") # opens the file > >> .read()

Re: is there any principle when writing python function

2011-08-27 Thread Roy Smith
In article <4e595334$0$3$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > and then there are languages with few, or no, design principles to speak of Oh, like PHP? -- http://mail.python.org/mailman/listinfo/python-list

Re: is there any principle when writing python function

2011-08-27 Thread Roy Smith
In article , Emile van Sebille wrote: > code that doesn't execute will need to be read to be understood, and > to be fixed so that it does run. That is certainly true, but it's not the whole story. Even code that works perfectly today will need to be modified in the future. Business requir

Help me understand this logging config

2011-08-29 Thread Roy Smith
I'm using django 1.3 and python 2.6. My logging config is: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format': '%(asctime)s: %(name)s %(levelname)s % (funcName)s %(message)s' } }, 'handlers':

Re: Help me understand this logging config

2011-08-30 Thread Roy Smith
In article , Peter Otten <__pete...@web.de> wrote: > Roy Smith wrote: > > > I'm using django 1.3 and python 2.6. > > Isn't dictConfig() new in 2.7? It looks like that is what you are using... Oh, my, it turns out that django includes: # This is a copy of th

Re: Optparse buggy?

2011-09-01 Thread Roy Smith
In article , Terry Reedy wrote: > Do note "The optparse module is deprecated and will not be developed > further; development will continue with the argparse module." One of the unfortunate things about optparse and argparse is the names. I can never remember which is the new one and which i

Why doesn't threading.join() return a value?

2011-09-02 Thread Roy Smith
I have a function I want to run in a thread and return a value. It seems like the most obvious way to do this is to have my target function return the value, the Thread object stash that someplace, and return it as the return value for join(). Yes, I know there's other ways for a thread to return

Re: Why doesn't threading.join() return a value?

2011-09-02 Thread Roy Smith
In article <5da6bf87-9412-46c4-ad32-f8337d56b...@o15g2000vbe.googlegroups.com>, Adam Skutt wrote: > On Sep 2, 10:53 am, Roy Smith wrote: > > I have a function I want to run in a thread and return a value.  It > > seems like the most obvious way to do this is to have m

Re: Why doesn't threading.join() return a value?

2011-09-03 Thread Roy Smith
In article , Chris Torek wrote: > For that matter, you can use the following to get what the OP asked > for. (Change all the instance variables to __-prefixed versions > if you want them to be Mostly Private.) > > import threading > > class ValThread(threading.Thread): > "like threading.T

Re: [Python-ideas] allow line break at operators

2011-09-03 Thread Roy Smith
In article , Matt Joiner wrote: > I guess the issue here is that you can't tell if an expression is > complete without checking the indent of the following line. This is > likely not desirable. I wrote a weird bug the other day. I had a function that returned a 4-tuple and wanted to unpack it

Re: Extracting subsequences composed of the same character

2011-03-31 Thread Roy Smith
In article <4d952008$0$3943$426a7...@news.free.fr>, candide wrote: > Suppose you have a string, for instance > > "pyyythhooonnn ---> " > > and you search for the subquences composed of the same character, here > you get : > > 'yyy', 'hh', 'ooo', 'nnn', '---', '' I got the following.

Re: How to program in Python to run system commands in 1000s of servers

2011-04-05 Thread Roy Smith
In article , geremy condra wrote: > On Tue, Apr 5, 2011 at 7:51 AM, Babu wrote: > > > > Here is my problem:  Want to program in python to run sysadmin > > commands across 1000s of servers and gather the result in one place. > > Many times the commands need to be run as root.  We cannot use ssh

Creating unit tests on the fly

2011-04-08 Thread Roy Smith
I've got a suite of unit tests for a web application. There's an (abstract) base test class from which all test cases derive: class BaseSmokeTest(unittest.TestCase): BaseSmokeTest.setUpClass() fetches a UR (from a class attribute "route", which must be defined in the derived classes), and there'

Re: Creating unit tests on the fly

2011-04-08 Thread Roy Smith
In article <87fwpse4zt@benfinney.id.au>, Ben Finney wrote: > Raymond Hettinger writes: > > > I think you're going to need a queue of tests, with your own test > > runner consuming the queue, and your on-the-fly test creator running > > as a producer thread. > > I have found the ‘testsce

Re: Creating unit tests on the fly

2011-04-10 Thread Roy Smith
In article , Raymond Hettinger wrote: > I think you're going to need a queue of tests, with your own test > runner consuming the queue, and your on-the-fly test creator running > as a producer thread. > > Writing your own test runner isn't difficult. 1) wait on the queue > for a new test case

Re: [OT] Free software versus software idea patents

2011-04-14 Thread Roy Smith
In article <4da7a8f5$0$29986$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Thu, 14 Apr 2011 13:50:24 -0700, Westley Martínez wrote: > > > Also, why aren't Opera and Google criticized for their proprietary > > browsers (Chrome is essentially a proprietary front-end)? Is it be

Re: [OT] Free software versus software idea patents

2011-04-14 Thread Roy Smith
In article <4da7abad$0$29986$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > What they give is ubiquity, which is a point in their favour. But just > because something is common doesn't make it useful: for the most part > both are used for style over substance, of sizzle without

Re: Pythonic infinite for loop?

2011-04-15 Thread Roy Smith
In article <4da83f8f$0$29986$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > for key in dct: > if key.startswith("Keyword"): > maxkey = max(maxkey, int(key[7:])) I would make that a little easier to read, and less prone to "Did I count correctly?" bugs with something

Re: Problem receiving UDP broadcast packets.

2011-04-19 Thread Roy Smith
In article , Grant Edwards wrote: > I'm trying to implement a device discovery/configuration protocol that > uses UDP broadcast packets to discover specific types of devices on > the local Ethernet segment. The management program broadcasts a > discovery command to a particular UDP port. All d

Re: dictionary size changed during iteration

2011-04-22 Thread Roy Smith
In article , Peter Otten <__pete...@web.de> wrote: > You now have to create the list explicitly to avoid the error: > > >>> d = dict(a=1) > >>> keys = list(d.keys()) > >>> for k in keys: > ... d["b"] = 42 > ... That works, but if d is large, it won't be very efficient because it has to gen

Re: learnpython.org - an online interactive Python tutorial

2011-04-22 Thread Roy Smith
In article , Mel wrote: > > Strings should auto-type-promote to numbers if appropriate. > > "Appropriate" is the problem. This is why Perl needs two completely > different kinds of comparison -- one that works as though its operands are > numbers, and one that works as though they're strings

Re: Changing baud rate doesn't allow second command

2011-04-25 Thread Roy Smith
In article <224f6621-2fc4-4827-8a19-3a12371f3...@l14g2000pre.googlegroups.com>, rjmccorkle wrote: > hi - I need to open a serial port in 9600 and send a command followed > by closing it, open serial port again and send a second command at > 115200. I have both commands working separately from

Re: Development tools and practices for Pythonistas

2011-04-29 Thread Roy Smith
In article , CM wrote: > While we're on the topic, when should a lone developer bother to start > using a VCS? No need to use VCS at the very beginning of a project. You can easily wait until you've written 10 or 20 lines of code :-) > Should I bother to try a VCS? Absolutely. Even if you

skipping one unittest assertion?

2011-05-01 Thread Roy Smith
Is there any way to skip a single assertion in a unittest test method? I know I can @skip or @expectedFailure the method, but I'm looking for something finer-grain than that. There's one particular assertion in a test method which depends on production code that hasn't been written yet. I cou

Re: skipping one unittest assertion?

2011-05-01 Thread Roy Smith
In article <87wriah4qg@benfinney.id.au>, Ben Finney wrote: > Roy Smith writes: > > > There's one particular assertion in a test method which depends on > > production code that hasn't been written yet. I could factor that out > > into its own t

Re: skipping one unittest assertion?

2011-05-01 Thread Roy Smith
In article , "OKB (not okblacke)" wrote: > Roy Smith wrote: > > > Is there any way to skip a single assertion in a unittest test > > method? I know I can @skip or @expectedFailure the method, but I'm > > looking for something finer-grain than that. >

Re: vertical ordering of functions

2011-05-03 Thread Roy Smith
In article , Jabba Laci wrote: > I'm just reading Robert M. Martin's book entitled "Clean Code". In Ch. > 5 he says that a function that is called should be below a function > that does the calling. This creates a nice flow down from top to > bottom. There may have been some logic to this when

Re: What other languages use the same data model as Python?

2011-05-05 Thread Roy Smith
In article , Grant Edwards wrote: > That's what I was trying to say, but probably not as clearly. The "&" > operatore returnas a _value_ that the OP passes _by_value_ to a > function. That function then uses the "*" operator to use that value > to access some data. Then, of course, there's re

Re: What other languages use the same data model as Python?

2011-05-05 Thread Roy Smith
In article <4dc29cdd$0$29991$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > C is better described as a high-level assembler, or a low-level language. > It is too close to the hardware to describe it as high-level, it has no > memory management, few data abstractions, and little

Re: What other languages use the same data model as Python?

2011-05-05 Thread Roy Smith
In article <92fsvjfkg...@mid.individual.net>, Neil Cerutti wrote: > On 2011-05-05, Roy Smith wrote: > > Of course, C++ lets you go off the deep end with abominations > > like references to pointers. Come to think of it, C++ let's > > you go off the deep end in

Re: What other languages use the same data model as Python?

2011-05-07 Thread Roy Smith
In article <87aaeymfww@benfinney.id.au>, Ben Finney wrote: > No, I think not. The term “variable” usually comes with a strong > expectation that every variable has exactly one name. Heh. You've never used common blocks in Fortran? Or, for that matter, references in C++? I would call

Re: dictionary size changed during iteration

2011-05-07 Thread Roy Smith
In article <7xd3jukyn9@ruckus.brouhaha.com>, Paul Rubin wrote: > Roy Smith writes: > > changes = [ ] > > for key in d.iterkeys(): > > if is_bad(key): > > changes.append(key) > > changes = list(k for k in d if is_bad(k)) > > is a li

Re: Development tools and practices for Pythonistas

2011-05-08 Thread Roy Smith
In article <58a6bb1b-a98e-4c4a-86ea-09e040cb2...@r35g2000prj.googlegroups.com>, snorble wrote: > [standard tale of chaotic software development elided] > > I am aware of tools like version control systems, bug trackers, and > things like these, but I'm not really sure if I need them, or how to

Re: Proper way to handle errors in a module

2011-05-11 Thread Roy Smith
In article , Andrew Berg wrote: > I'm a bit new to programming outside of shell scripts (and I'm no expert > there), so I was wondering what is considered the best way to handle > errors when writing a module. Do I just let exceptions go and raise > custom exceptions for errors that don't trigge

Re: checking if a list is empty

2011-05-12 Thread Roy Smith
In article <931adaf9g...@mid.individual.net>, Gregory Ewing wrote: > Roy Smith wrote: > >>If both are numbers, they are converted to a common type. Otherwise, > >>objects of different types always compare unequal > > That's just the default treatment

list equal to subclass of list?

2011-05-12 Thread Roy Smith
I have a vague feeling this may have been discussed a long time ago, but I can't find the thread, so I'll bring it up again. I recently observed in the "checking if a list is empty" thread that a list and a subclass of list can compare equal: class MyList(list):

Re: list equal to subclass of list?

2011-05-12 Thread Roy Smith
On May 12, 2011, at 11:30 AM, Eric Snow wrote: > On Thu, May 12, 2011 at 6:23 AM, Roy Smith wrote: > The docs say: > > [http://docs.python.org/library/stdtypes.html] > Objects of different types, except different numeric types and different > string types, never compar

Re: list equal to subclass of list?

2011-05-12 Thread Roy Smith
On May 12, 2:29 pm, Ethan Furman wrote: > While it is wrong (it should have 'built-in' precede the word 'types'), > it is not wrong in the way you think -- a subclass *is* a type of its > superclass. Well, consider this: class List_A(list): "A list subclass" class List_B(list): "Anothe

Re: list equal to subclass of list?

2011-05-12 Thread Roy Smith
In article , Ethan Furman wrote: > > [http://docs.python.org/library/stdtypes.html] > > Objects of different types, except different numeric types and different > > string types, never compare equal > > This part of the documentation is talking about built-in types, which > your MyList is not

Re: checking if a list is empty

2011-05-14 Thread Roy Smith
In article , David Robinow wrote: > On Fri, May 13, 2011 at 10:34 PM, Gregory Ewing > wrote: > > rusi wrote: > > > >> Dijkstra's problem (paraphrased) is that python, by choosing the > >> FORTRAN alternative of having a non-first-class boolean type, hinders > >> scientific/mathematical thinking

Re: Converting a set into list

2011-05-15 Thread Roy Smith
In article <34fc571c-f382-405d-94b1-0a673da5f...@t16g2000vbi.googlegroups.com>, SigmundV wrote: > I think the OP wants to find the intersection of two lists. > list(set(list1) & set(list2)) is indeed one way to achieve this. [i > for i in list1 if i in list2] is another one. Both ways work, bu

Re: count strangeness

2011-05-22 Thread Roy Smith
In article , James Stroud wrote: > tal 65% python2.7 > Python 2.7.1 (r271:86832, May 21 2011, 22:52:14) > [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > py> class C(object): > ... def __init__(self): > ... se

Re: Unit testing beginner question

2011-05-23 Thread Roy Smith
In article , Ian Kelly wrote: > This would work: > > self.assertRaises(TypeError, lambda: self.testListNone[:1]) If you're using the version of unittest from python 2.7, there's an even nicer way to write this: with self.assertRaises(TypeError): self.testListNone[:1] -- http://mail.pyth

Re: Why did Quora choose Python for its development?

2011-05-25 Thread Roy Smith
In article , Dennis Lee Bieber wrote: > On Tue, 24 May 2011 13:39:02 -0400, "D'Arcy J.M. Cain" > declaimed the following in gmane.comp.python.general: > > > > My point was that even proponents of the language can make a > > significant error based on the way the variable is named. It's like

Re: Why did Quora choose Python for its development?

2011-05-25 Thread Roy Smith
In article , Chris Angelico wrote: > On Wed, May 25, 2011 at 9:36 PM, Roy Smith wrote: > > Remembering that I, J, K, L, M, and N were integer was trivial if you > > came from a math background.  And, of course, Fortran was all about > > math, so that was natural.  Those

Re: Why did Quora choose Python for its development?

2011-05-26 Thread Roy Smith
In article <94709uf99...@mid.individual.net>, Neil Cerutti wrote: > On 2011-05-25, Matty Sarro wrote: > > General readability is a farce. If it was true we would only > > have one section to the library. Different people enjoy > > reading, and can comprehend better in different ways. THat's > >

Re: bug in str.startswith() and str.endswith()

2011-05-26 Thread Roy Smith
In article , Ethan Furman wrote: > --> 'this is a test'.startswith('this') > True > --> 'this is a test'.startswith('this', None, None) > Traceback (most recent call last): >File "", line 1, in > TypeError: slice indices must be integers or None or have an __index__ > method [...] > Any re

Re: The worth of comments

2011-05-26 Thread Roy Smith
In article , Richard Parker wrote: > On May 26, 2011, at 4:28 AM, python-list-requ...@python.org wrote: > > > My experience is that comments in Python are of relatively low > > usefulness. (For avoidance of doubt: not *zero* usefulness, merely low.) > > I can name variables, functions and cla

Re: The worth of comments

2011-05-27 Thread Roy Smith
In article , Chris Angelico wrote: > (Did I *really* write that code? It has my name on it.) Most version control systems have an annotate command which lets you see who wrote a given line of code. Some of them are even honest enough to call the command "blame" instead of "annotate" :-)

Re: Why did Quora choose Python for its development?

2011-05-27 Thread Roy Smith
In article <948l8nf33...@mid.individual.net>, Gregory Ewing wrote: > John Bokma wrote: > > > A Perl programmer will call this line noise: > > > > double_word_re = re.compile(r"\b(?P\w+)\s+(?P=word)(?!\w)", > > re.IGNORECASE) One of the truly awesome things about th

Re: bug in str.startswith() and str.endswith()

2011-05-27 Thread Roy Smith
In article , Stefan Behnel wrote: > Roy Smith, 27.05.2011 03:13: > > Ethan Furman wrote: > > > >> --> 'this is a test'.startswith('this') > >> True > >> --> 'this is a test'.startswith('this', None, N

Re: Why did Quora choose Python for its development?

2011-05-28 Thread Roy Smith
In article , Carl Banks wrote: > On Friday, May 27, 2011 6:47:21 AM UTC-7, Roy Smith wrote: > > One of the truly awesome things about the Python re library is that it > > lets you write complex regexes like this: > > > > pattern = r"""

Re: The worth of comments

2011-05-28 Thread Roy Smith
In article , Grant Edwards wrote: > When trying to find a bug in code written by sombody else, I often > first go through and delete all of the comments so as not to be > mislead. I've heard people say that before. While I get the concept, I don't like doing things that way myself. >> The co

Re: Weird problem matching with REs

2011-05-29 Thread Roy Smith
In article , Andrew Berg wrote: > Kodos is written in Python and uses Python's regex engine. In fact, it > is specifically intended to debug Python regexes. Named after the governor of Tarsus IV? -- http://mail.python.org/mailman/listinfo/python-list

Re: The worth of comments

2011-05-29 Thread Roy Smith
In article , Grant Edwards wrote: > On 2011-05-29, Gregory Ewing wrote: > > Ben Finney wrote: > > > >> You omit the common third possibility: *both* the comment and the code > >> are wrong. > > > > In that case, the correct response is to fix both of them. :-) > > Only as a last resort. IMO, t

Re: float("nan") in set or as key

2011-05-31 Thread Roy Smith
In article Carl Banks wrote: > pretty much everyone uses IEEE format Is there *any* hardware in use today which supports floating point using a format other than IEEE? -- http://mail.python.org/mailman/listinfo/python-list

Re: The syntax of replacement fields in format strings

2017-10-31 Thread John Smith
If we keep the current implementation as is, perhaps the documentation should at least be altered ? -- https://mail.python.org/mailman/listinfo/python-list

Re: General Purpose Pipeline library?

2017-11-20 Thread duncan smith
On 20/11/17 15:48, Jason wrote: > a pipeline can be described as a sequence of functions that are applied to an > input with each subsequent function getting the output of the preceding > function: > > out = f6(f5(f4(f3(f2(f1(in)) > > However this isn't very readable and does not support co

Re: Problem with assignment. Python error or mine?

2017-12-21 Thread duncan smith
On 21/12/17 19:06, John Ladasky wrote: > On Thursday, December 21, 2017 at 7:37:39 AM UTC-8, MRAB wrote: > >> Python never makes a copy unless you ask it to. >> >> What x1=X does is make the name x1 refer to the same object that X >> refers to. No copying. > > Well, except with very simple, muta

Re: Speeding up the implementation of Stochastic Gradient Ascent in Python

2018-01-18 Thread duncan smith
On 17/01/18 14:29, leutrim.kal...@gmail.com wrote: > > Hello everyone, > > I am implementing a time-dependent Recommender System which applies BPR > (Bayesian Personalized Ranking), where Stochastic Gradient Ascent is used to > learn the parameters of the model. Such that, one iteration involv

Re: plot / graph connecting re ordered lists

2018-01-23 Thread duncan smith
On 23/01/18 23:42, Vincent Davis wrote: > On Tue, Jan 23, 2018 at 4:15 PM Dennis Lee Bieber > wrote: > >> On Tue, 23 Jan 2018 13:51:55 -0700, Vincent Davis >> declaimed the following: >> >>> Looking for suggestions. I have an ordered list of names these names will >>> be reordered. I am looking

Re: Python3.6 tkinter bug?

2022-09-22 Thread Peter Smith
On Wednesday, February 1, 2017 at 11:55:35 AM UTC, Terry Reedy wrote: > On 2/1/2017 1:37 AM, Christian Gollwitzer wrote: > > Am 01.02.17 um 00:02 schrieb MRAB: > >> On 2017-01-31 22:34, Christian Gollwitzer wrote: > .!frame.!checkbutton > .!frame.!checkbutton2 > .!frame2.!checkb

Re: Python3.6 tkinter bug?

2022-09-22 Thread Peter Smith
On Wednesday, February 1, 2017 at 11:55:35 AM UTC, Terry Reedy wrote: > On 2/1/2017 1:37 AM, Christian Gollwitzer wrote: > > Am 01.02.17 um 00:02 schrieb MRAB: > >> On 2017-01-31 22:34, Christian Gollwitzer wrote: > .!frame.!checkbutton > .!frame.!checkbutton2 > .!frame2.!checkb

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Julian Smith
On Fri, 7 Oct 2022 18:28:06 +0100 Barry wrote: > > On 7 Oct 2022, at 18:16, MRAB wrote: > > > > On 2022-10-07 16:45, Skip Montanaro wrote: > >>> On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames > >>> > >>> wrote: > >>> 1. The culprit was me. As lazy as I am, I have used f-strings all over the >

Strange UnicodeEncodeError in Windows image on Azure DevOps and Github

2022-11-11 Thread Jessica Smith
Hello, Weird issue I've found on Windows images in Azure Devops Pipelines and Github actions. Printing Unicode characters fails on these images because, for some reason, the encoding is mapped to cp1252. What is particularly weird about the code page being set to 1252 is that if you execute "chcp"

Python 3.7+ cannot print unicode characters when output is redirected to file - is this a bug?

2022-11-13 Thread Jessica Smith
Consider the following code ran in Powershell or cmd.exe: $ python -c "print('└')" └ $ python -c "print('└')" > test_file.txt Traceback (most recent call last): File "", line 1, in File "C:\Program Files\Python38\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(i

Re: Strange UnicodeEncodeError in Windows image on Azure DevOps and Github

2022-11-13 Thread Jessica Smith
On Fri, Nov 11, 2022 at 8:16 PM Eryk Sun wrote: > If sys.std* are console files, then in Python 3.6+, sys.std*.buffer.raw will > be _io._WindowsConsoleIO > io.TextIOWrapper uses locale.getpreferredencoding(False) as the default > encoding Thank you for your replies - checking the sys.stdout.buf

Re: How do you debug in Python? Coming from a Matlab and R user. I'm already aware of pdb.

2021-01-27 Thread duncan smith
On 27/01/2021 22:41, C W wrote: > Great tutorial Irv, very simple with if-else example, gets the point > across. > > My main takeaway from the discussion so far is that: you can't troubleshoot > Python without some kind of breakpoint or debugger. > [snip] Really? Duncan -- https://mail.python

mutating a deque whilst iterating over it

2021-02-11 Thread duncan smith
Hello, It seems that I can mutate a deque while iterating over it if I assign to an index, but not if I append to it. Is this the intended behaviour? It seems a bit inconsistent. Cheers. Duncan >>> from collections import deque >>> d = deque(range(8)) >>> it = iter(d) >>> next(it) 0 >>> d[1

Re: mutating a deque whilst iterating over it

2021-02-13 Thread duncan smith
On 12/02/2021 03:04, Terry Reedy wrote: > On 2/11/2021 3:22 PM, duncan smith wrote: > >>    It seems that I can mutate a deque while iterating over it if I >> assign to an index, but not if I append to it. Is this the intended >> behaviour? > > Does the deque d

Re: mutating a deque whilst iterating over it

2021-02-14 Thread duncan smith
On 13/02/2021 19:12, Dan Stromberg wrote: > On Sat, Feb 13, 2021 at 10:25 AM duncan smith > wrote: > >> On 12/02/2021 03:04, Terry Reedy wrote: >>> On 2/11/2021 3:22 PM, duncan smith wrote: >>> >>>>It seems that I can mutate a deque while i

Importing modules with arguments

2021-07-30 Thread Charles Smith
I have found myself wanting to import module and provide arguments to them. There's two main reason I could think of for this. First is to prevent a circular import, though most of circular imports can be prevented by changing the design. The second reason is to invert dependencies between two m

Re: Importing modules with arguments

2021-07-30 Thread Charles Smith
First off, thanks for the answer. I don't see the cached module as a problem here. If you provide arguments to a module, the goal is "most likely" to alter/parameterize the behavior of the first import. Now, I agree that behavior becomes unpredictable because passing different parameters on subs

empty stdout (subprocess.run)

2022-01-19 Thread James Smith
I'm trying to run a shell command but the stdout is empty: import subprocess torrentno=8 cmd="/usr/bin/transmission-remote --torrent %s --info", str(torrentno) res=subprocess.run(cmd, shell=True, check=True, universal_newlines=True, capture_output=True) print(res) CompletedProcess(args=('/usr/b

Re: empty stdout (subprocess.run)

2022-01-20 Thread James Smith
On Wednesday, January 19, 2022 at 11:08:58 PM UTC-5, Dennis Lee Bieber wrote: > Don't you need to provide for that %s? Perhaps > > cmd="/usr/bin/transmission-remote --torrent %s --info" % torrentno That works, thanks. -- https://mail.python.org/mailman/listinfo/python-list

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