Re: Negative array indicies and slice()

2012-10-29 Thread Chris Angelico
On Mon, Oct 29, 2012 at 5:01 PM, Andrew Robinson wrote: > Looking at some of the online programming notes -- a slice apparently > doesn't use an integer storage variable that is capable of arbitrary > expansion. =-O -- and hence, won't work for very large sized lists. That > actually explains so

Re: Immutability and Python

2012-10-29 Thread Chris Angelico
On Tue, Oct 30, 2012 at 2:55 AM, Paul Rubin wrote: > andrea crotti writes: >> and we want to change its state incrementing the number ... >> the immutability purists would instead suggest to do this: >> def increment(self): >> return NumWrapper(self.number + 1) > > Immutability puris

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Chris Angelico
On Tue, Oct 30, 2012 at 3:33 AM, Johannes Bauer wrote: > Hi there, > > I'm currently looking for a good solution to the following problem: I > have two classes A and B, which interact with each other and which > interact with the user. Instances of B are always created by A. > > Now I want A to ca

Re: Immutability and Python

2012-10-29 Thread Chris Angelico
On Tue, Oct 30, 2012 at 6:23 AM, Ian Kelly wrote: > _MyImmutableClass = namedtuple('MyImmutableClass', 'field1 field2 > field3 field4') > > class MyImmutableClass(_MyImmutableClass): Question: Is it clearer to take advantage of the fact that the base class can be an arbitrary expression? class M

Re: Immutability and Python

2012-10-29 Thread Chris Kaynor
On Mon, Oct 29, 2012 at 3:30 PM, Steven D'Aprano wrote: > On Mon, 29 Oct 2012 17:05:07 +, andrea crotti wrote: > >> I meant how do I create new immutables classes myself, I guess that's >> possible writing C extensions but I don't see in pure Python.. > > Well, you can't *quite* make a truly i

Re: Negative array indicies and slice()

2012-10-29 Thread Chris Angelico
On Tue, Oct 30, 2012 at 2:42 AM, Andrew Robinson wrote: > No, there was no error at all. Pthon just crashed & exited; not even an > exception that I can recall. It was if it exited normally! Can you create a reproducible test case? There's usually a cause to these sorts of things. ChrisA --

Re: Negative array indicies and slice()

2012-10-29 Thread Chris Kaynor
On Mon, Oct 29, 2012 at 11:00 AM, Andrew Robinson wrote: > > Let's look at the source code rather than the web notes -- the source must > be the true answer anyhow. > > I downloaded the source code for python 3.3.0, as the tbz; > In the directory "Python-3.3.0/Python", look at Python-ast.c, line 2

Re: date and time comparison how to

2012-10-29 Thread Chris Angelico
On Tue, Oct 30, 2012 at 3:20 PM, noydb wrote: > But for the user supplied date... I'm not sure of the format just yet... > testing with a string for now (actual date-date might be possible, tbd > later), so like '10292012213000' (oct 29, 2012 9:30pm). How would you get > that input into a form

Re: exec with partial globals

2012-10-30 Thread Chris Angelico
On Tue, Oct 30, 2012 at 11:00 PM, Helmut Jarausch wrote: > Hi, > > I'd like to give the user the ability to enter code which may only rebind > a given set of names but not all ones. > > How can 'filter' the gobal namespace such that modifying 'A' is allowed > but any attempt to modify 'B' should g

Re: exec with partial globals

2012-10-30 Thread Chris Angelico
On Tue, Oct 30, 2012 at 11:57 PM, Helmut Jarausch wrote: > Given spreadsheet S (Source) and D (Destination) as objects (wrapping a > dictionary) a possible (legal) input would be > > D.price= D.price-S.discount > > No other fields of 'D' should be modifiable. That's a bit harder. What you're des

Re: Negative array indicies and slice()

2012-10-30 Thread Chris Angelico
On Wed, Oct 31, 2012 at 8:47 AM, Ian Kelly wrote: > On Tue, Oct 30, 2012 at 3:33 PM, Mark Lawrence > wrote: >> On 30/10/2012 18:02, Ian Kelly wrote: >>> >>> On Tue, Oct 30, 2012 at 10:14 AM, Ethan Furman wrote: File a bug report? >>> >>> >>> Looks like it's already been wontfixed back

Re: sort order for strings of digits

2012-10-31 Thread Chris Angelico
On Thu, Nov 1, 2012 at 10:44 AM, Steven D'Aprano wrote: > On the contrary. If you are using cmp with sort, your sorts are slow, and > you should upgrade to using a key function as soon as possible. > But cmp_to_key doesn't actually improve anything. So I'm not sure how Py3 has achieved anything;

Re: Negative array indicies and slice()

2012-11-01 Thread Chris Angelico
On Fri, Nov 2, 2012 at 1:12 AM, Ethan Furman wrote: > In other words, the slice contains the strings, and my code calculates > the offsets -- Python doesn't do it for me. That's correct, but you're still translating those strings into numeric indices. You can slice a database record based on colu

Re: Negative array indicies and slice()

2012-11-01 Thread Chris Angelico
On Thu, Nov 1, 2012 at 10:32 PM, Andrew Robinson wrote: > presently slice() allows memory leaks through GC loops. Forgive me if I've missed something here, but isn't it only possible to make a refloop by decidedly abnormal behaviour? Stuff like: a=[]; a.append(slice(a)) Seriously, who does this

Re: Obnoxious postings from Google Groups

2012-11-01 Thread Chris Angelico
On Fri, Nov 2, 2012 at 9:08 AM, wrote: > On 11/01/2012 03:55 AM, Jamie Paul Griffin wrote: >> Anybody serious about programming should be using a form of >> UNIX/Linux if you ask me. It's inconceivable that these systems >> should be avoided if you're serious about Software Engineering and >> Com

Re: Avoiding defunct processes

2012-11-01 Thread Chris Angelico
On Fri, Nov 2, 2012 at 1:16 PM, Richard wrote: > Hello, > > I create child processes with subprocess.Popen(). > Then I either wait for them to finish or kill them. > Either way these processes end up as defunct until the parent process > completes: > $ ps e > 6851 pts/5Z+ 1:29 [python] >

Re: pythonic way

2012-11-02 Thread Chris Angelico
On Fri, Nov 2, 2012 at 6:14 PM, jack wrote: > Sometimes, I need to alter the element as traverse a list like this (it's a > sample): > c = range(10) > i = 0 > for ele in c: > # do something > # branch: > c[i] = # value > i += 1 > > How to be pythonic

Re: python-forum

2012-11-02 Thread Chris Rebert
27;re already here, so why not stay a while? Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: pythonic way

2012-11-02 Thread Chris Angelico
On Fri, Nov 2, 2012 at 7:58 PM, jack wrote: > thanks,but I don't think enumerate() is my want > Have some ways to operate the reference of element,not a copy when I tried > to traverse a list? > > I'm so sorry about my poor English, hope you don't mind it. No probs, I'll be a little less vague an

Re: Organisation of python classes and their methods

2012-11-02 Thread Chris Angelico
On Fri, Nov 2, 2012 at 7:08 PM, Martin Hewitson wrote: > > On 2, Nov, 2012, at 08:38 AM, Paul Rubin wrote: > >> Martin Hewitson writes: >>> So, is there a way to put these methods in their own files and have >>> them 'included' in the class somehow? ... Is there an official python >>> way to do

Re: What the diferences : web.py Tornado Twisted ?!

2012-11-02 Thread Chris Angelico
On Sat, Nov 3, 2012 at 12:04 PM, Mark Lawrence wrote: > On 02/11/2012 15:50, nepaul wrote: >> >> What the diferences : web.py Tornado Twisted ?! >> > > Web.py is spelt w e b . p y. Tornado is spelt T o r n a d o. Twisted is > spelt T w i s t e d. Wow! That's profound! Oh, the insights made avai

Re: Obnoxious postings from Google Groups

2012-11-03 Thread Chris Angelico
On Sun, Nov 4, 2012 at 1:24 AM, Dave Angel wrote: > For the DOS world, real programmers have written a "complete" *.com > program using only echo. Only as an exercise. It was satisfying to prove to myself that I could do it, but pretty useless. Normally I used DEBUG.EXE to build my code - it has

Re: is implemented with id ?

2012-11-03 Thread Chris Angelico
On Sun, Nov 4, 2012 at 9:18 AM, Steven D'Aprano wrote: > On Sat, 03 Nov 2012 22:49:07 +0100, Hans Mulder wrote: > Actually, for many applications, the space "savings" may actually be > *costs*, since interning forces Python to hold onto strings even after > they would normally be garbage collected

Re: is implemented with id ?

2012-11-03 Thread Chris Angelico
On Sun, Nov 4, 2012 at 12:14 PM, Oscar Benjamin wrote: > On 3 November 2012 22:50, Chris Angelico wrote: >> This one I haven't checked the source for, but ISTR discussions on >> this list about comparison of two unequal interned strings not being >> optimized, so the

Re: is implemented with id ?

2012-11-03 Thread Chris Angelico
On Sun, Nov 4, 2012 at 2:10 PM, Steven D'Aprano wrote: > /* Shortcut for empty or interned objects */ > if (v == u) { > Py_DECREF(u); > Py_DECREF(v); > return 0; > } > result = unicode_compare(u, v); > > where v and u are pointers to the unicode object. There's a shortcut if they're t

Re: Obnoxious postings from Google Groups

2012-11-04 Thread Chris Angelico
On Mon, Nov 5, 2012 at 5:10 PM, rusi wrote: > Among people who know me, I am a linux nerd: My sister scolded me > yesterday because I put files on her computer without spaces: > DoesAnyoneWriteLikeThis?!?! My filenames seldom have spaces in them, but that has nothing to do with how I write Englis

Re: Multi-dimensional list initialization

2012-11-04 Thread Chris Rebert
#x27;s also a FAQ: http://docs.python.org/2/faq/programming.html#how-do-i-create-a-multidimensional-list > and if so, why? It's a general (albeit AFAIK unstated) principle that Python never copies objects unless you explicitly ask it to. You have encountered one example of this rule in action. > In my mind either result makes sense, but the inconsistency is what throws me > off. It is perfectly consistent, once you understand what list multiplication actually does. Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi-dimensional list initialization

2012-11-04 Thread Chris Angelico
On Mon, Nov 5, 2012 at 6:07 PM, Chris Rebert wrote: >>>> x = None >>>> x.a = 42 > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'NoneType' object has no attribute 'a' Python needs a YouGottaBeKiddingM

Re: [Python-ideas] sys.py3k

2012-11-04 Thread Chris Angelico
On Mon, Nov 5, 2012 at 9:33 AM, Steven D'Aprano wrote: > On 05/11/12 08:49, anatoly techtonik wrote: >> >> if sys.py3k: >># some py2k specific code >>pass > > # Bring back reload in Python 3. > try: > reload > except NameError: > from imp import reload > > try: > any > except N

Re: No more Python support in NetBeans 7.0

2012-11-04 Thread Chris Angelico
On Mon, Nov 5, 2012 at 5:29 PM, Demian Brecht wrote: > > On 2012-11-04, at 4:45 PM, [email protected] wrote: >> However I am not happy about having to use different IDEs as I find myself >> coding in both python and php from project to project. > > One of the many reasons Vim is my editor of cho

Re: Multi-dimensional list initialization

2012-11-05 Thread Chris Angelico
On Mon, Nov 5, 2012 at 6:54 PM, Andrew Robinson wrote: > On 11/04/2012 11:27 PM, Chris Angelico wrote: >> >> On Mon, Nov 5, 2012 at 6:07 PM, Chris Rebert wrote: >>>>>> >>>>>> x = None >>>>>> x.a = 42 >>> >&g

Re: Obnoxious postings from Google Groups

2012-11-05 Thread Chris Angelico
On Mon, Nov 5, 2012 at 11:56 PM, Roy Smith wrote: > That's a very ascii-esqe attitude. In a fully unicode world, I could > easily see using U+00A0 (NO-BREAK SPACE) in file names, and still have > space-delimited CLI work just fine. > Oh, do you have a "U+00A0-bar" on your keyboard? ChrisA -- h

Re: Coordination between developers in the Python project

2012-11-05 Thread Chris Angelico
On Tue, Nov 6, 2012 at 6:09 AM, Terry Reedy wrote: >> I would like to remind you that the participation is absolutely >> anonymous and voluntary, and you can quit it at any time. Your answers >> will be strictly confidential and will be used only for research purpose >> (no commercial use of any i

Re: Coordination between developers in the Python project

2012-11-05 Thread Chris Angelico
On Fri, Nov 2, 2012 at 7:49 AM, Tengy Td wrote: > It would be a great help for me if you could answer a short online survey > (it should take approximately 5 minutes). > > This survey is designed to reach a better understanding of the cooperation > and coordination between developers in Free/libre

Re: Multi-dimensional list initialization

2012-11-05 Thread Chris Angelico
On Tue, Nov 6, 2012 at 12:32 PM, Oscar Benjamin wrote: > I was just thinking to myself that it would be a hard thing to change > because the list would need to know how to instantiate copies of all > the different types of the elements in the list. Then I realised it > doesn't. It is simply a case

Re: problem with eval and time

2012-11-05 Thread Chris Angelico
On Tue, Nov 6, 2012 at 3:29 PM, Wincent wrote: > Thanks. > > I fetch data from social networking sites and want to mark the time of > access. I store all the information in a redis database, which converts > everything into strings and I need to convert those strings back to original > python o

Re: How to only get a list of the names of the non-directory files in current directory ('.')?

2012-11-05 Thread Chris Angelico
On Tue, Nov 6, 2012 at 4:19 PM, iMath wrote: > How to only get a list of the names of the non-directory files in current > directory ('.')? > (Note excluding its subdirectories ). > > I need the code : ) Start by getting a list of names of everything in the current directory. Then filter that l

Re: Multi-dimensional list initialization

2012-11-05 Thread Chris Angelico
On Tue, Nov 6, 2012 at 4:51 PM, Andrew Robinson wrote: > I really don't think doing a shallow copy of lists would break anyone's > program. Well, it's a change, a semantic change. It's almost certainly going to break _something_. But for the sake of argument, we can suppose that the change could

Re: Coordination between developers in the Python project

2012-11-06 Thread Chris Angelico
On Tue, Nov 6, 2012 at 7:49 PM, Ian Kelly wrote: > On Mon, Nov 5, 2012 at 3:01 PM, Chris Angelico wrote: >> By "URL unshortening service" you mean a simple HTTP request to >> bit.ly:80, right? :) Though I admit there aren't many easy and >> convenient

Re: [Python-ideas] sys.py3k

2012-11-07 Thread Chris Angelico
On Thu, Nov 8, 2012 at 5:35 AM, anatoly techtonik wrote: > I thought of sys.py3k check as an explicit way to guard the code that should > be maintained extra carefully for Python 3 compatibility, so that you can > grep the source for this constant and remove all the hacks (such as bytes to > strin

Re: [Python-ideas] sys.py3k

2012-11-07 Thread Chris Angelico
On Thu, Nov 8, 2012 at 10:56 AM, Steven D'Aprano wrote: > On Thu, 08 Nov 2012 10:14:35 +1100, Chris Angelico wrote: > >> On Thu, Nov 8, 2012 at 5:35 AM, anatoly techtonik >> wrote: >>> I thought of sys.py3k check ... > > Chris, you regularly reply to t

Re: isinstance(.., file) for Python 3

2012-11-08 Thread Chris Angelico
On Thu, Nov 8, 2012 at 11:05 PM, Ulrich Eckhardt wrote: > Firstly, I have code that allows either a file or a string representing its > content as parameter. If the parameter is a file, the content is read from > the file. In Python 2, I used "isinstance(p, file)" to determine whether the > parame

Re: Executing .exe on a remote Windows machine

2012-11-08 Thread Chris Rebert
ocesses remotely > Copyright (C) 2001-2010 Mark Russinovich > Sysinternals - www.sysinternals.com > > > PsExec could not start 'c:\Program Files\Splunk\bin\splunk.exe' restart on > [IP_ADDRESS]: > The filename, directory name, or volume label syntax is incorrect. > [/output] > > I am simply trying to restart the splunk forwarder instance > > Any thoughts?? > Remove the apostrophes surrounding the path to Splunk's executable. The subprocess module already takes care of the quoting for you, so the apostrophes are unnecessary and are being interpreted literally. -- Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: accuracy problem in calculation

2012-11-08 Thread Chris Angelico
On Fri, Nov 9, 2012 at 4:05 AM, Debashish Saha wrote: > (15+1.00067968)-(15+1.00067961) > Out[102]: 2.384185791015625e-07 > > 1.00067968-(1.00067961) > Out[103]: 7.1866624e-08 > > above i am showing the two different results,though the two outputs > should be same if we do

Re: Multi-dimensional list initialization

2012-11-08 Thread Chris Angelico
On Fri, Nov 9, 2012 at 12:39 PM, Mark Lawrence wrote: > On 07/11/2012 01:55, Steven D'Aprano wrote: >> >> >> Who knows? Who cares? Nobody does: >> >> n -= n >> > > But I've seen this scattered through code: > > x := x - x - x Can you enlighten us as to how this is better than either: x := -x or

Re: duck typing assert

2012-11-08 Thread Chris Angelico
On Fri, Nov 9, 2012 at 12:00 PM, Ian Kelly wrote: > looks(Foo).like(IFoo), on the other hand, is crystal clear about which > argument is which. I'm not so sure that it is, tbh. If you read it like an English sentence, it's clearly testing whether Foo matches the template in IFoo, but which are yo

Re: Multi-dimensional list initialization

2012-11-08 Thread Chris Angelico
On Fri, Nov 9, 2012 at 5:37 PM, Steven D'Aprano wrote: > On Fri, 09 Nov 2012 17:07:09 +1100, Chris Angelico wrote: >> Can you enlighten us as to how this is better than either: >> x := -x >> or >> x := 0 - x >> ? I'm not seeing it. > > I'

Re: Python3.3 str() bug?

2012-11-09 Thread Chris Angelico
On Fri, Nov 9, 2012 at 10:08 PM, Helmut Jarausch wrote: > For me it's not funny, at all. His description "funny" was in reference to the fact that you described this as a bug. This is a heavily-used mature language; bugs as fundamental as you imply are unlikely to exist (consequences of design de

Re: duck typing assert

2012-11-09 Thread Chris Angelico
On Sat, Nov 10, 2012 at 1:01 AM, Andriy Kornatskyy wrote: > > 1. In looks-like we check features of Foo (that may be superset) of what IFoo > offers. > > assert looks(Foo).like(IFoo) > > 2. We can check if Foo is limited to IFoo only: > > assert looks(IFoo).like(Foo) > > So it valid to have both

Re: Multi-dimensional list initialization

2012-11-09 Thread Chris Angelico
On Sat, Nov 10, 2012 at 2:05 AM, rusi wrote: > In x86 assembler > mov ax, 0 > is 4 bytes Three bytes actually, B8 00 00 if my memory hasn't failed me. BA for DX, B9 ought to be BX and BB CX, I think. But yes, the xor or sub is two bytes and one clock. ChrisA -- http://mail.python.org/mailman/li

Re: Want to add dictionary keys to namespace?

2012-11-09 Thread Chris Angelico
On Sat, Nov 10, 2012 at 11:00 AM, Jeff Jeffries wrote: > Smart people, Is there a way I can add a dictionaries keys to the python > namespace? It would just be temporary as I am working with a large > dictionary, and it would speed up work using an IDE. I look and find > nothing... none of the ke

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-09 Thread Chris Angelico
On Sat, Nov 10, 2012 at 1:52 PM, Paul Rubin wrote: > [email protected] writes: >> Is there a simpler way to modify all arguments in a function before >> using the arguments? > > Why do you want to do that? > Contrived example: def send_email(from, to, subj, body, whatever, other, headers, y

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread Chris Angelico
On Sat, Nov 10, 2012 at 3:05 PM, Paul Rubin wrote: > Chris Angelico writes: >> Contrived example: >> def send_email(from, to, subj, body, whatever, other, headers, you, like): > > That should be a dictionary with the header names as indexes. In fact > there are alr

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread Chris Angelico
On Sun, Nov 11, 2012 at 12:15 AM, wrote: > Thanks to all. > Steve's example is the one I will try next week. > Passing in lists, will work but it requires extra coding from the calling > routines to build the list. Not necessarily! Watch: def foo(*args): print(repr(args)) foo("Hello","wor

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Chris Angelico
On Sun, Nov 11, 2012 at 6:33 AM, Jennie wrote: > ... def distance(self, point=None): > ... p = point if point else Point() I'd go with this one. Definitely not the third one, which mutates the class according to a current global every time a Point is instantiated - could be *extremely

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Chris Angelico
On Sun, Nov 11, 2012 at 12:13 PM, Steven D'Aprano wrote: > Almost but not quite. I assume that, in a full Point class, you would > want Point(0, 0) to count as false in a boolean context. (A "falsey" > value, like None, [], 0.0, etc.) I would not assume that. The origin is a point, just like any

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Chris Angelico
On Sun, Nov 11, 2012 at 1:43 PM, Ian Kelly wrote: > On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico wrote: >> I would not assume that. The origin is a point, just like any other. >> With a Line class, you could deem a zero-length line to be like a >> zero-element list, b

Re: skip Trackback error for ftp checking

2012-11-12 Thread Chris Angelico
On Mon, Nov 12, 2012 at 8:25 PM, moonhkt wrote: > On Nov 10, 2:50 pm, Steven D'Aprano [email protected]> wrote: >> >> The same way you would skip any other error when you do something wrong: >> catch the exception. > > Thank. Added below. > try: >ftp = FTP(options.remote_host_ad

Re: Is there a way to creat a func that returns a cursor that can be used?

2012-11-12 Thread Chris Angelico
On Mon, Nov 12, 2012 at 9:45 PM, Khalid Al-Ghamdi wrote: > Is there a way to create a func that returns a cursor that can be used to > execute sql statements? Yes, and you're almost there! > I tried this (after importing sqlite3), but it gave me the error below: > def connect(): > retu

Re: How to only get a list of the names of the non-directory files in current directory ('.')?

2012-11-13 Thread Chris Angelico
On Wed, Nov 14, 2012 at 5:16 AM, emile wrote: > BTW, googling for "python how to get a list of names of everything in the > current directory" yields some good information as well. Google is your > friend for this level of question. Not sure anymore beyond that... It yields it? You mean Google

Re: How to only get a list of the names of the non-directory files in current directory ('.')?

2012-11-13 Thread Chris Angelico
On Wed, Nov 14, 2012 at 8:05 AM, John Gordon wrote: > In Chris Angelico > writes: > >> It yields it? You mean Google is an iterator? > > ITYM generator. Yeah, that thing. Troll fail. *whoops* ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Generate unique ID for URL

2012-11-13 Thread Chris Kaynor
rated by a single process (and even in other cases with some work). If you want to be able to go both ways, using base64 encoding is probably your best bet, though you might get benefits by using compression. Chris On Tue, Nov 13, 2012 at 3:56 PM, Richard wrote: > Good point - one way enco

Re: Generate unique ID for URL

2012-11-13 Thread Chris Angelico
On Wed, Nov 14, 2012 at 2:25 PM, Richard wrote: > So the use case - I'm storing webpages on disk and want a quick retrieval > system based on URL. > I can't store the files in a single directory because of OS limitations so > have been using a sub folder structure. > For example to store data at

Re: Simple Question regarding running .py program

2012-11-13 Thread Chris Angelico
On Wed, Nov 14, 2012 at 2:31 PM, Caroline Hou wrote: > Thank you Dave and everybody here for your helpful comments!This place is > awesome! I found this group when I googled python-list. Seems like this is > not the usual way you guys access the list? There are several ways to communicate with

Re: Simple Question regarding running .py program

2012-11-13 Thread Chris Angelico
On Wed, Nov 14, 2012 at 4:08 PM, wrote: > On 11/13/2012 09:10 PM, Chris Angelico wrote: >> * Use a news-to-web gateway such as Google Groups. That >> specific one is deprecated on this list, as there's more >> noise than signal from Google Groups. > > Caroline,

Re: stackoverflow quote on Python

2012-11-14 Thread Chris Angelico
On Wed, Nov 14, 2012 at 7:56 PM, wrote: > I'am still fascinated by the mathematically absurd "negative > logic" used in and by the flexible string representation > (algorithm). I am still fascinated that you persist in comparing a buggy old Python against a bug-free new Python and haven't notice

Re: Simple Question regarding running .py program

2012-11-14 Thread Chris Angelico
On Wed, Nov 14, 2012 at 6:02 PM, wrote: > On 11/13/2012 11:02 PM, Chris Angelico wrote: >> To be more accurate: This is deprecated *by members of* this list. As >> there is no commanding/controlling entity here, it's up to each >> individual to make a decision - for i

Re: Subprocess puzzle and two questions

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 1:22 AM, Roy Smith wrote: > Oh, my. You're using DNS as a replacement for ping? Fair enough. In > that case, all you really care about is that you can connect to port 53 > on the server... > > import socket > import time > s = socket.socket() > t0 = time.time() > s.conne

Re: Error

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 2:18 AM, inshu chauhan wrote: > > for this code m getting this error : > > CODE : > def ComputeClasses(data): > if data[cy,cx] != (0.0,0.0,0.0): > centre = data[cy, cx] > ... > dist = distance(centre, point) > > ERROR

Re: Subprocess puzzle and two questions

2012-11-14 Thread Chris Angelico
> s = socket.socket() >>> s.connect(('8.8.8.8', 53)) > > In article , > Chris Angelico wrote: >>That assumes that (a) the remote server supports TCP for DNS > > This is true. I honestly don't know what percentage of DNS servers > out there only suppor

Re: Python questions help

2012-11-14 Thread Chris Angelico
fficulties you're having. If we write the code for you, it won't help you to learn, will it? Once you have some code that isn't working, we can help you to figure out what it is that isn't working. But do your best to write the code yourself first. Chris Angelico -- http://ma

Re: Subprocess puzzle and two questions

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 12:49 PM, Roy Smith wrote: > 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&

Re: Subprocess puzzle and two questions

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 1:10 PM, Roy Smith wrote: > 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&#x

Re: Dictionary of Functions

2012-11-15 Thread Chris Kaynor
On Thu, Nov 15, 2012 at 8:04 AM, Kevin Gullikson wrote: > Hi all, > > I am trying to make a dictionary of functions, where each entry in the > dictionary is the same function with a few of the parameters set to specific > parameters. My actual use is pretty complicated, but I managed to boil down

Re: Simple Question regarding running .py program

2012-11-15 Thread Chris Angelico
On Fri, Nov 16, 2012 at 3:10 PM, rusi wrote: > One small addition: GG allows spam posts to be marked as spam. > > This feature costs a few seconds and can help everyone (if a few more > GG users would use it) And Gmail lets you do the exact same thing, but I almost never need to do it, because th

Re: Simple Question regarding running .py program

2012-11-15 Thread Chris Angelico
On Fri, Nov 16, 2012 at 5:37 PM, Chris Angelico wrote: > Spam filtering is nothing unique. > (Don't get me wrong though, that doesn't stop it from being a good thing. It's just not a reason to use GG above all else.) ChrisA -- http://mail.python.org/mailman/listinfo/python-list

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

2012-11-17 Thread Chris Angelico
On Sun, Nov 18, 2012 at 5:38 AM, Roy Smith wrote: > In article , > [email protected] wrote: >> Don't forget that most firewalls don't decrement) the time-to-live number, >> and unless you REALLY know what to look for, are invisible. > > Interesting. If the firewall doesn't decrement TTL (a particular

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

2012-11-17 Thread Chris Angelico
On Sun, Nov 18, 2012 at 6:59 AM, Jordan Bylsma wrote: > For this case the firewalls DO respond to TTL(in most cases) and will show in > a traceroute. The objective here is to colorize particular devices to easily > see what type of devices traffic would traverse across the network. I would > be

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

2012-11-17 Thread Chris Angelico
On Sun, Nov 18, 2012 at 12:18 PM, Steven D'Aprano wrote: > On Sun, 18 Nov 2012 09:00:10 +1100, Chris Angelico wrote: > > [...] >> I've never used the program, though, so I have no idea how good it is. >> All I've done is download the tar.gz and glance ove

Re: Point of idle curiosity

2012-11-18 Thread Chris Angelico
On Mon, Nov 19, 2012 at 3:08 AM, Mark Lawrence wrote: > On 18/11/2012 15:59, Steven D'Aprano wrote: >> >> On Sun, 18 Nov 2012 22:45:43 +1100, Chris Angelico wrote: >> >>> (if you'll forgive the pun) >>> >>> Is IDLE named after Eric of th

Re: Problem with subprocess.call and windows schtasks

2012-11-18 Thread Chris Rebert
> 07:50'] > cmd = [pgm] > cmd.extend(args) > subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] > but got this error: > ERROR: Invalid argument/option - <> > > If I use the other args list I get this error: > ERROR: Invalid argument/option - '/SC ONCE' > so apparently it liked the first argument. > > Please advise. Your tokenization of your command is incorrect. Consult the Note box in the docs regarding `args` tokenization, and apply it to your command: http://docs.python.org/2/library/subprocess.html#subprocess.Popen The-docs-are-your-friend-ly Yours, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Interview Questions

2012-11-18 Thread Chris Angelico
On Mon, Nov 19, 2012 at 4:16 AM, D'Arcy J.M. Cain wrote: > On 18 Nov 2012 16:50:52 GMT > Steven D'Aprano wrote: >> On Sun, 18 Nov 2012 08:53:25 -0500, Roy Smith wrote: >>> > Use a list when you need an ordered collection which is mutable >> > (i.e. can be altered after being created). Use a tupl

Re: Python Interview Questions

2012-11-18 Thread Chris Angelico
On Mon, Nov 19, 2012 at 1:09 PM, Roy Smith wrote: > The theorist understands that a chisel and a screwdriver were intended > for different purposes, but the pragmatist gets the paint can open. A good tool can always be used in ways its inventor never intended - and it will function as its user ex

Re: Problems on these two questions

2012-11-18 Thread Chris Angelico
On Mon, Nov 19, 2012 at 12:52 PM, su29090 <[email protected]> wrote: > 1.Given a positive integer n , assign True to is_prime if n has no factors > other than 1 and itself. (Remember, m is a factor of n if m divides n > evenly.) > > 2.An arithmetic progression is a sequence of numbers in

Re: Robust regex

2012-11-19 Thread Chris Angelico
On Tue, Nov 20, 2012 at 7:32 AM, Joseph L. Casale wrote: > Trying to robustly parse a string that will have key/value pairs separated > by three pipes, where each additional key/value (if more than one exists) > will be delineated by four more pipes. > > string = 'key_1|||value_1key_2|||va

Re: Point of idle curiosity

2012-11-19 Thread Chris Angelico
On Mon, Nov 19, 2012 at 11:38 PM, Ulrich Eckhardt wrote: > Am 18.11.2012 12:45, schrieb Chris Angelico: >> Is IDLE named after Eric of that name, or is it pure coincidence? > > > Maybe. Interestingly, there is also http://eric-ide.python-projects.org/, > just to add some more

Re: Python questions help

2012-11-19 Thread Chris Angelico
On Tue, Nov 20, 2012 at 1:57 AM, Neil Cerutti wrote: > On 2012-11-16, Chris Angelico wrote: >> On Sat, Nov 17, 2012 at 5:00 AM, rh >> wrote: >>> "How many people think programming skills are inherent?" i.e. >>> that some people are just born with the g

Re: Splitting a line while keeping quoted items together

2012-11-19 Thread Chris Rebert
#x27;) > #x('"Portland Alpha" 123') -> ('Portland Alpha', '123') > #x("'Portland Beta' 789') -> ('Portland Beta', '789') > > This seem really ugly. Is there a cleaner way to do this? Is there a >

Re: Stack_overflow error

2012-11-19 Thread Chris Angelico
On Tue, Nov 20, 2012 at 11:49 AM, Aung Thet Naing wrote: > I'm having Stack_overflow exception in _ctypes_callproc (callproc.c). The > error actually come from the: > > cleanup: > for (i = 0; i < argcount; ++i) > Py_XDECREF(args[i].keep); > > when args[i].keep->ob_refCnt == 1 Can yo

Re: Yet another Python textbook

2012-11-20 Thread Chris Angelico
On Tue, Nov 20, 2012 at 7:02 PM, Pavel Solin wrote: > Perhaps you are right. Is there any statistics of how many Python > programmers are using 2.7 vs. 3? Most of people I know use 2.7. If you're teaching Python, the stats are probably about zero for zero. Start them off on Py3 and help move the

Re: 10 sec poll - please reply!

2012-11-20 Thread Chris Angelico
On Tue, Nov 20, 2012 at 11:18 PM, Michael Herrmann wrote: > Hi, > > I'm developing a GUI Automation library (http://www.getautoma.com) and am > having difficulty picking a name for the function that simulates key strokes. > I currently have it as 'type' but that clashes with the built-in functio

Re: Index Error

2012-11-20 Thread Chris Angelico
On Wed, Nov 21, 2012 at 12:43 AM, inshu chauhan wrote: > I need help in this part as I am unable to device a method in which if the > points are out of index,it should stop. > > Traceback (most recent call last): > File "Z:/modules/Classify.py", line 73, in > ComputeClasses(data) > Fi

Re: Index Error

2012-11-20 Thread Chris Angelico
On Wed, Nov 21, 2012 at 12:57 AM, inshu chauhan wrote: > I am using python 2.7.3 , so can it be done in that ? (Please don't top-post; just delete the couple of blank lines that gmail oh so kindly provides, and type your response at the bottom. You may also want to consider trimming the quoted te

Re: Problem with list.remove() method

2012-11-20 Thread Chris Angelico
On Wed, Nov 21, 2012 at 12:56 AM, Alvaro Combo wrote: > Hi All, > > I'm relatively new to Python... but I have found something I cannot > explain... and I'm sure you can help me. > > I have the following function that serves for removing the duplicates from a > list... It's a simple and (almost

Re: Problem with list.remove() method

2012-11-20 Thread Chris Angelico
On Wed, Nov 21, 2012 at 1:37 AM, Alvaro Combo wrote: > Dear Chris, > > Thank you very much for you reply... > For a newcomer to Python the Hell is in the details... :-). You're most welcome! As Adam Savage of Mythbusters is fond of saying (with an exaggerated accent), &qu

Re: 10 sec poll - please reply!

2012-11-20 Thread Chris Angelico
On Wed, Nov 21, 2012 at 3:21 AM, Steven D'Aprano wrote: > On Tue, 20 Nov 2012 07:18:42 -0800, Michael Herrmann wrote: > >> Thanks again for your further replies. So far, it's 4 votes for >> 'send_keys' and 1 vote for 'type'. >> >> Regarding 'send_keys': To me personally it makes sense to send keys

Re: Yet another Python textbook

2012-11-20 Thread Chris Angelico
On Wed, Nov 21, 2012 at 1:57 AM, wrote: > Le mardi 20 novembre 2012 09:09:50 UTC+1, Chris Angelico a écrit : >> On Tue, Nov 20, 2012 at 7:02 PM, Pavel Solin wrote: >> >> > Perhaps you are right. Is there any statistics of how many Python >> >> > programmer

Re: Choosing Source Address to Bind Socket to in IMAP Client

2012-11-20 Thread Chris Angelico
On Wed, Nov 21, 2012 at 8:14 AM, wrote: > Hello: > > I have a multihomed machine that I would like to run the Python imaplib's > IMAP4 client on. I would like to be able to specify which interface the > underlying socket will bind to as its source address. How could I best do > this? You're

Re: Yet another Python textbook

2012-11-20 Thread Chris Angelico
On Wed, Nov 21, 2012 at 8:55 AM, Mark Lawrence wrote: > On 20/11/2012 21:00, Chris Angelico wrote: >> >> >> To the OP: jmf has an unnatural hatred of Python 3.3 and PEP 393 >> strings. Take no notice; the rest of the world sees this as a huge >> advantage. Pytho

Re: Choosing Source Address to Bind Socket to in IMAP Client

2012-11-20 Thread Chris Angelico
On Wed, Nov 21, 2012 at 9:00 AM, wrote: > On Tuesday, November 20, 2012 1:48:46 PM UTC-8, Chris Angelico wrote: >> On Wed, Nov 21, 2012 at 8:14 AM, wrote: >> >> > I have a multihomed machine that I would like to run the Python imaplib's >> > IMAP4

<    13   14   15   16   17   18   19   20   21   22   >