Re: open urls in browser

2011-07-18 Thread Chris Angelico
On Mon, Jul 18, 2011 at 10:05 PM, srikanth wrote: > Ex: http://www.google.com - Pass/Fail. What do you mean by "Pass" or "Fail"? If you send a URL to a web browser, all you'll find out is whether or not the browser accepted it - it won't tell you if the page is valid. If you want that, you don't

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

2011-07-18 Thread Chris Angelico
On Tue, Jul 19, 2011 at 5:06 AM, Andrew Berg wrote: > Personally, I think that 80 is pretty arbitrary now, and not the best > limit. I'm more comfortable with 120-130 myself. In any case, Python > won't complain about how many characters are on a line, and that's the > way it should be. > It's a

Re: a little parsing challenge ☺

2011-07-18 Thread Chris Angelico
save those characters to disk, transmit them across the network, or in some other way need to store them as bytes. Otherwise, there is no abstraction, and no leak. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

TestFixtures 1.10.0 Released!

2011-07-19 Thread Chris Withers
butes and dict items using testfixtures.Replacer and testfixtures.replace. The package is on PyPI and a full list of all the links to docs, issue trackers and the like can be found here: http://www.simplistix.co.uk/software/python/testfixtures cheers, Chris -- Simplistix - Content Manag

Re: TestFixtures 1.10.0 Released!

2011-07-19 Thread Chris Withers
Hmm, might have been helpful to include docs for these new bits: On 19/07/2011 09:36, Chris Withers wrote: - Implement the ability to mock out dict and list items using testfixtures.Replacer and testfixtures.replace. - Implement the ability to remove attributes and dict items using

Re: (Maybe off topic) Can someone explain what a finite state machine is?

2011-07-19 Thread Chris Angelico
state #2, finding end-of-line transitions you to state #1 (and, presumably, saves the name/value pair somewhere). This is an extremely simple example with two states and two transitions. It can get a lot more complicated than that! Hope that helps! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: How to iterate through two dicts efficiently

2011-07-19 Thread Chris Rebert
etdefault('RETRY', set()).add(jarid) Code duplication ahoy! Let's refactor that: pairs = [('ACK', '13'), ('NACK', '14'), ('RETRY', '504'), ('RETRY', '505')] for opco in Cn: for service in Cn[opco]: for msg, prkey in pairs: ids = set(Cn[opco][service]['RECV']) & set(Pr[prkey]) for jarid in ids:         Cn[opco][service].setdefault(msg, set()).add(jarid) Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Python ++ Operator?

2011-07-19 Thread Chris Torek
In article Chris Angelico wrote: >I agree that [C's ++ operators are] often confusing (i+j) ... For what it is worth, this has to be written as: i++ + ++j /* or i+++ ++j */ or similar (e.g., newline after the middle "+" operator) as the lexer will group adjacent &q

Re: Pythonic way with more than one max possible

2011-07-19 Thread Chris Rebert
ething close to > "one way to do it".  Any suggestions? # presumes at least 2 items from heapq import nlargest winner, runner_up = nlargest(2, the_dict.itervalues()) if winner == runner_up: winner = the_dict['b'] Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way with more than one max possible

2011-07-20 Thread Chris Rebert
else >> based on the "winner" of such a dict, with these rules: > I realize, now though, (and Chris asked about this) that I was > imprecise in my > rules.  They really should be stated as: > > 1. In this dict, if there is a UNIQUE max value, then its *key* is the >

Re: Writing a MUD Console

2011-07-22 Thread Chris Angelico
http://minstrelhall.com/RosMudAndroid.py and give it a whirl! I haven't tested the code lately. I don't remember whether it's for Python 2 or Python 3. Feel free to pester me with questions; I've written several MUD clients (in various languages) and a couple of MUD servers

Re: Writing a MUD Console

2011-07-22 Thread Chris Angelico
On Sat, Jul 23, 2011 at 3:12 AM, Jonathan Gardner wrote: > On Fri, Jul 22, 2011 at 2:25 AM, Chris Angelico wrote: >> Rather than attach it to this post, I've tossed the script onto my >> MUD's web site. (Yes, I run a MUD. Your subject line grabbed my >>

Re: Inconsistencies between zipfile and tarfile APIs

2011-07-22 Thread Chris Angelico
NSISTENT! Python and C++ are BOTH programming languages and as such should present a consistent API. I really don't care so much about the actual details as long as the APIs (standard libraries) are consistent! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Inconsistencies between zipfile and tarfile APIs

2011-07-22 Thread Chris Angelico
Oh, and: On Sat, Jul 23, 2011 at 3:11 AM, rantingrick wrote: > Will you be starting with the zipfile API migration? > Will you? Rick, quit ranting and start coding. If you want things to happen, the best way is to do them. If you make a post on the dev list WITH A PATCH, or submit your patch on

Re: PEP 8 and extraneous whitespace

2011-07-22 Thread Chris Angelico
On Sat, Jul 23, 2011 at 3:05 AM, Michiel Overtoom wrote: > Indeed. Since Windows95 I always use a proportional font for programming: > >  http://www.michielovertoom.com/incoming/comic-sans-python.jpg > > It's so elegant and gives aesthetic pleasure to look at. http://xkcd.com/590/ ChrisA -- htt

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Chris Angelico
On Sat, Jul 23, 2011 at 5:00 AM, John Gordon wrote: > ... rantingrick writes ... > >> WRONG! > > Why did you say he was wrong? It's Ranting Rick. Why did you expect anything else? :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert '165.0' to int

2011-07-22 Thread Chris Angelico
On Sat, Jul 23, 2011 at 5:32 AM, rantingrick wrote: > That's nine-quadrillion people! Only for galactic measurements or > microscopic reasons would you need such large numbers. > Never decide that "nobody would need numbers bigger than X". Someone will. One common thing to do with big numbers is

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Chris Angelico
On Sat, Jul 23, 2011 at 5:16 AM, rantingrick wrote: > My chastisement of Bruno was only on the grounds of him failing to > offer the required amount of information to a new python programmer. > We should ALWAYS remove any ambiguities from our statements to new > users AND we should always link to

Re: PEP 8 and extraneous whitespace

2011-07-22 Thread Chris Rebert
#x27;70s anymore; I think we can safely increase the max column width a bit. Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Chris Torek
ist.append(Florg('fifth', 5)) for florg in flist: florg.zormonkle() if __name__ == '__main__': example() -- In-Real-Life: Chris Torek, Wind River Systems Intel require I note that my opinions are not those of WRS or Intel Salt Lake City, UT, USA (40°39.22&

Re: Convert '165.0' to int

2011-07-23 Thread Chris Angelico
On Sat, Jul 23, 2011 at 4:53 PM, Frank Millman wrote: > The problem with that is that it will silently ignore any non-zero > digits after the point. Of course int(float(x)) does the same, which I > had overlooked. If you know that there will always be a trailing point, you can trim off any traili

Re: Convert '165.0' to int

2011-07-23 Thread Chris Angelico
On Sun, Jul 24, 2011 at 1:12 AM, Billy Mays wrote: > On 7/23/2011 3:42 AM, Chris Angelico wrote: >> >> int(s.rstrip('0').rstrip('.')) >> > > Also, it will (in?)correct parse strings such as: > > '16500' > &g

Re: Strings show as brackets with a 'u'.

2011-07-23 Thread Chris Angelico
rick is a troll. You can safely ignore him.) Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: I am fed up with Python GUI toolkits...

2011-07-23 Thread Chris Angelico
On Sun, Jul 24, 2011 at 1:56 PM, Cameron Simpson wrote: > And then you have the cross platform nirvana. Except for the browsers' > various differences and bugs etc etc... > The "platform" ceases to be Windows/Linux/Mac, ceases to be Qt/GTK/Tk, and instead becomes Webkit/Gecko/Trident. It's still

Re: Convert '165.0' to int

2011-07-24 Thread Chris Angelico
On Sun, Jul 24, 2011 at 5:58 PM, Frank Millman wrote: >  if int(dec) != 0: > to >    if [_ for _ in list(dec) if _ != '0']: > if dec.rtrim('0')!='': ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert '165.0' to int

2011-07-24 Thread Chris Angelico
On Sun, Jul 24, 2011 at 6:21 PM, Frank Millman wrote: > On Jul 24, 10:07 am, Chris Angelico wrote: >> if dec.rtrim('0')!='': >> >> ChrisA > > I think you meant 'rstrip', but yes, neater and faster. > > Thanks Yeah, I did. Mea culpa.

Re: learning another programing language

2011-07-24 Thread Chris Angelico
ng F7 in SciTE will 'make' the current project and show you the results immediately. Also, find a good mailing list dedicated to C++, and one dedicated to Java. Lurk there for a while and read tips, and when you run into specific problems, ask clear questions. Hope that helps! Chris

Re: Convert '165.0' to int

2011-07-24 Thread Chris Angelico
s not a string representation of an integer - but you CAN take that string, validate it as representing a number that can be represented as an integer, and evaluate what integer it is. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Refactor/Rewrite Perl code in Python

2011-07-24 Thread Chris Angelico
On Sun, Jul 24, 2011 at 7:29 PM, Shashwat Anand wrote: > How do I start ? > The idea is to rewrite module by module. > But how to make sure code doesn't break ? > How can I import perl and python codes in each other ? Can you separate the project into separate executables that call on each other?

Re: python.org is down?

2011-07-24 Thread Chris Angelico
h contact from whois, which is also the contact address listed in the SOA record. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: python.org is down?

2011-07-24 Thread Chris Angelico
On Mon, Jul 25, 2011 at 3:34 AM, Stefan Behnel wrote: > Laszlo Nagy, 24.07.2011 09:43: >> >> Can it be a problem on my side? I have tried from several different >> computers. I cannot even ping it. > > What's even worse is that PyPI is extremely slow in responding, even up to > connection failures

Re: python.org back up ?(was Re: python.org is down?)

2011-07-24 Thread Chris Angelico
On Mon, Jul 25, 2011 at 4:34 AM, Terry Reedy wrote: > On 7/24/2011 3:43 AM, Laszlo Nagy wrote: >> >> Can it be a problem on my side? I have tried from several different >> computers. I cannot even ping it. > > python.org, bugs.python.org, docs.python.org, pypi.python.org > all work for me now. Ye

Re: Help with Latin Characters

2011-07-24 Thread Chris Angelico
On Mon, Jul 25, 2011 at 5:01 AM, Joao Jacome wrote: > Already tried without unicode string in rootdir, same results. What if try > using raw strings? Raw strings are just another way of typing them into your source code. There are different ways of writing string literals, but they produce the sa

Re: Convert '165.0' to int

2011-07-24 Thread Chris Angelico
On Mon, Jul 25, 2011 at 10:07 AM, Billy Mays wrote: > if the goal is speed, then you should use generator expressions: > > list_of_integers = (int(float(s)) for s in list_of_strings) Clarification: This is faster if and only if you don't actually need it as a list. In spite of the variable name,

Re: Trying to learn about metaclasses

2011-07-25 Thread Chris Kaynor
On Mon, Jul 25, 2011 at 8:36 AM, Steven W. Orr wrote: > I have been doing a lot of reading. I'm starting to get it. I think it's > really cool as well as dangerous, but I plan on being respectful of the > construct. I found a web page that I found quite readable. > > http://cleverdevil.org/**comp

Re: Signal only works in main thread

2011-07-25 Thread Chris Rebert
On Mon, Jul 25, 2011 at 12:19 PM, RVince wrote: > I am instantiating an SSH client class using this class: > > http://www.goldb.org/sshpython.html You might consider using Paramiko instead: http://www.lag.net/paramiko/ Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Selecting unique values

2011-07-26 Thread Chris Angelico
On Tue, Jul 26, 2011 at 8:03 AM, Kumar Mainali wrote: > Greetings > > I have a dataset with occurrence records of multiple species. I need to get > rid of multiple listings of the same occurrence point for a species (as you > see below in red and blue typeface). How do I create a dataset only with

Re: ActivePython: multiple versions on OSX?

2011-07-26 Thread Chris Angelico
On Wed, Jul 27, 2011 at 2:33 AM, Melton Low wrote: > It's probably impractical.  You would need a pair for each version of Python > installed, ie. (PYTHON26PATH,PYTHON26HOME) for 2.6.x, > (PYTHON27PATH,PYTHON27HOME) for 2.7.x, for 3.1.x, for 3.2.x, etc). You could set up a script for each ve

Re: How can I make a program automatically run once per day?

2011-07-26 Thread Chris Angelico
On Wed, Jul 27, 2011 at 2:09 PM, John Salerno wrote: > Thank you. I changed it as suggested so that now it runs C: > \Python32\python.exe extract_songs.py but it still isn't working. Have you confirmed that the job's working directory is set correctly? Naming the script without a path depends on

Re: How can I make a program automatically run once per day?

2011-07-27 Thread Chris Angelico
On Wed, Jul 27, 2011 at 10:27 PM, Dave Angel wrote: > As Chris pointed out, you probably aren't getting the script's directory > right.  After all, how can the scheduler guess where you put it?  The > obvious answer is to use a full path for the script's filename.  Ano

TestFixtures 1.11.0 Released!

2011-07-27 Thread Chris Withers
are/python/testfixtures cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-list

Re: How should I document exceptions thrown by a method?

2011-07-27 Thread Chris Torek
with Ben Finney though, and so does "import this": ... Simple is better than complex. ... Letting exceptions flow upward unchanged is (usually) simpler, hence "better". -- In-Real-Life: Chris Torek, Wind River Systems Intel require I note that my opinions a

Re: multilanguage application - step by step

2011-07-28 Thread Chris Rebert
Here’s an example of typical usage for this API:" code snippet. For the translation file workflow, the Wikipedia article seems enlightening: http://en.wikipedia.org/wiki/GNU_gettext Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: PEP8: A cauldron of inconsistencies.

2011-07-28 Thread Chris Angelico
On Thu, Jul 28, 2011 at 8:34 AM, rantingrick wrote: >> -- >> Encodings (PEP 263) >> >> Code in the core Python distribution should always use the >> ASCII or Latin-1 encoding (a.k.a. ISO-8859-1).  For Python >> 3.0 and beyond, UTF-8 is prefer

Re: NoneType and new instances

2011-07-28 Thread Chris Angelico
On Fri, Jul 29, 2011 at 7:03 AM, Ethan Furman wrote: > I'll use a lambda to get around it, but that's not very elegant.  Why > shouldn't NoneType be able to return the singleton None? Why a lambda? def ThisFunctionWillReturnNone(): pass Although, since the returning of None is crucial to it

Re: gettext switch language on the fly

2011-07-28 Thread Chris Rebert
ing? Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 8 and extraneous whitespace

2011-07-29 Thread Chris Angelico
On Thu, Jul 28, 2011 at 4:18 PM, OKB (not okblacke) wrote: > Thomas 'PointedEars' Lahn wrote: >>  Automatic word-wrap, where available, really is not a solution; it >> is a bad workaround to a problem caused by the original author of >> the source code that can be easily avoided by them taking mor

Re: PyWart: os.path needs immediate attention!

2011-07-29 Thread Chris Angelico
On Sat, Jul 30, 2011 at 3:22 AM, rantingrick wrote: > ~ >  3. Non Public Names Exposed! > ~ > >  * genericpath >  * os >  * stat >  * sys >  * warnings > And you intend to do what, exactly, with these? > - splitunc --> Unix specific! 1) So? 2) ht

Re: removing nested iffs

2011-07-29 Thread Chris Angelico
thon 3.2, and on Python 2.4 and 2.6, a TypeError "cannot concatenate 'str' and 'NoneType' objects". Check what your version does. In any case, the above try/except will bail out without error when it gets a TypeError of any sort, so be sure this won't be a problem to you! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 8 and extraneous whitespace

2011-07-29 Thread Chris Angelico
On Sat, Jul 30, 2011 at 4:45 AM, OKB (not okblacke) wrote: > Chris Angelico wrote: >> That mandates that formatting NOT be a part of the language. I could >> take C code and reformat it in various ways with a script, and easily >> guarantee that the script won't affect

Re: PyWart: os.path needs immediate attention!

2011-07-29 Thread Chris Angelico
On Sat, Jul 30, 2011 at 6:44 AM, Corey Richardson wrote: > Excerpts from rantingrick's message of Fri Jul 29 13:22:04 -0400 2011: >>  * New path module will ONLY support one path sep! > > People who use windows are used to \ being their pathsep. If you show > them a path that looks like C:/whateve

Re: removing nested iffs

2011-07-29 Thread Chris Angelico
On Sat, Jul 30, 2011 at 6:42 AM, Peter Otten <[email protected]> wrote: > def format_pairs(pairs): >    for template, value in pairs: >        if value is None: >            break >        yield template.format(value) > Cool! May I suggest a trifling change: def format_pairs(*pairs): for t

Re: PyWart: PEP8: A cauldron of inconsistencies.

2011-07-30 Thread Chris Angelico
On Sat, Jul 30, 2011 at 5:52 PM, [email protected] wrote: > On 28 juil, 00:34, rantingrick wrote: > >> In Python4000 i'm making it a syntax error to >> include ANY blank lines in a func/meth body. > > Hopefully this is not going to happen. It will happen when Rick stops ranting and s

Re: Windows: setting title of console window

2011-07-30 Thread Chris Angelico
On Sat, Jul 30, 2011 at 6:23 PM, Ethan Furman wrote: > 8<-- sitecustomize.py - > class SetTitle(object): >    def __del__(self): >        command = ' '.join(sys.argv) > > sys.argv = SetTitle() I'm afraid I don't understand this. Why create an object and do the work

Re: Windows: setting title of console window

2011-07-30 Thread Chris Angelico
On Sat, Jul 30, 2011 at 7:39 PM, Ethan Furman wrote: > Well, you /could/ have followed the link and read the explanation there... > ;) I tend to avoid clicking random links in posts :) > How it works: since the sys.argv object does yet exist... That's the bit I didn't understand. I assume that'

Re: eval, exec and execfile dilemma

2011-07-30 Thread Chris Angelico
On Sat, Jul 30, 2011 at 8:48 PM, Laszlo Nagy wrote: > the exec statement can be used to execute a def statement. However, I see no > way to change the globals, so I cannot use the exec statement. You can't use: exec "blah blah" in globals() ? I've not used exec, nor its Python 3 equivalent exe

Re: What is xrange?

2011-07-30 Thread Chris Angelico
On Sun, Jul 31, 2011 at 1:06 AM, Dennis Lee Bieber wrote: >        Ah, but what did they change range() into -- I seem to recall > reading the Python 3.x turned the regular range() into something else... > (from Python <3.x returning a full list) > xrange got renamed to range, as I understand it.

Re: Not able to store data to dictionary because of memory limitation

2011-07-31 Thread Chris Angelico
identical content. (In Python 3, that function has been shoved off to a module, so it's sys.intern() and you need to import sys.) You'll save some space and improve dictionary performance, but you won't lose clarity. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Deeply nested dictionaries - should I look into a database or am I just doing it wrong?

2011-07-31 Thread Chris Rebert
lter.fft3d.ffte vs. QueueItem.x264['avs']['filter']['fft3d']['ffte'] It would also make clear that your sets of "keys" are static (unlike typical dictionary usage). Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Spam

2011-07-31 Thread Chris Angelico
uisite for recognizing spammers :) If you are willing to take on the job, I would support your application for the power to do it. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Quick question about threads and interpreters.

2011-07-31 Thread Chris Angelico
u're not 100% sure of where your DLL is going to be called from. It might be easier and safer to have your parent program actually provide a function pointer to the DLL, which the DLL can then use to call on Python; that way, there's no direct linkage from your DLL to the Python li

Re: Spam

2011-07-31 Thread Chris Rebert
> From: Ashraf Ali And off to [email protected] I dash. Fsck you Mr. Ali. (Yeah, not their real name, I know. Still worth reporting such accounts.) Cheers, Chris > Date: Mon, Aug 1, 2011 at 10:54 AM > Subject: Hello My Sweet Friends. > To: [email protected] > > &g

Re: Question

2011-08-01 Thread Chris Angelico
o versions of Python installed somehow. What does this display: $ python -V If it doesn't say Python 2.7.2, then you already had an older Python. All the best! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: os.path.dirname(sys.argv[0]) always returns nothing

2011-08-01 Thread Chris Angelico
On Mon, Aug 1, 2011 at 6:38 PM, happykid wrote: > I want to use this function to get the directory path of the running > script, but it always returns empty string. Can anyone help me solve > this? Thank you. As long as you haven't changed directory since startup, you should be able to use os.pat

Re: os.path.dirname(sys.argv[0]) always returns nothing

2011-08-01 Thread Chris Angelico
On Mon, Aug 1, 2011 at 6:55 PM, Thijs Engels wrote: > argv[0] returns the name of the current file (string), but no path > information if I recall correct. It will give path information if you're invoking a script from another directory. Under some circumstances it might happen to give an absolut

Re: test systems

2011-08-01 Thread Chris Angelico
ay mean putting it in a special directory. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Spam

2011-08-01 Thread Chris Angelico
On Tue, Aug 2, 2011 at 4:58 AM, Ghodmode wrote: > I hope it's clear that reading an email doesn't constitute visiting all of > the sites linked in the email and therefore doesn't improve Google page > ranks or provide any other tracking information.  Also note that the > original email didn't have

Re: python reading file memory cost

2011-08-01 Thread Chris Rebert
ultidimensional arrays are involved. The next obvious question would then be: do you /really/ need /all/ of the data in memory at once? Also, just so you're aware: http://docs.python.org/library/sys.html#sys.getsizeof Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Notifications when process is killed

2011-08-02 Thread Chris Angelico
said, but if you need to know what caused a process to end, the best way is to have code in the parent process to catch SIGCHLD. When the child ends, for any reason, its parent is sent SIGCHLD with some parameters, including the signal number that caused the termination; you can then log anythi

Re: range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 10:20 AM, Stefan Behnel wrote: > What version of Py3 were you using? If you used the latest, maybe even the > latest hg version, you will notice that that's substantially faster for > integers than, e.g. 3.1.x. > I just tried this out, using a slightly modified script but t

Re: range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 10:05 AM, Peter Otten <[email protected]> wrote: > i/2 returns a float in Python 3; you should use i//2 for consistency. > And I forgot to make this change before doing my tests. Redoing the Python 3 ones with // quite drastically changes things! 3.2 (r32:88445, Feb 20 2011,

Re: Notifications when process is killed

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 11:36 AM, Andrea Di Mario wrote: > If i use SIGCHLD, i will have difficult when parent receive a SIGTERM, or not? What you would do is create two processes. Set up your signal handlers, then fork; in the parent, just watch for the child's death - in the child, do all your w

Re: Please code review.

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 12:45 PM, Karim wrote: > ...         for char in cellnames.replace('', ' ').split()[:cols]: for char in cellnames[:cols]: Strings are iterable over their characters. Alternatively, you could use chr and ord, but it's probably cleaner and simpler to have the string there. I

Re: range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 3:45 PM, Steven D'Aprano wrote: > (But don't make the mistake of doing what I did, which was to attempt to > produce range(29000) in Python 2. After multiple *hours* of swapping, I > was finally able to kill the Python process and get control of my PC again. > Sigh.) >

Re: python import error, what's wrong?

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 4:52 PM, smith jack wrote: > from org.test.A import A This is going to look for org/test/A.py but not for org.test/A.py - are you able to rename your directories to not have dots? ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: os.path needs immediate attention!

2011-08-02 Thread Chris Angelico
rief explanations. For quite a few things, you need to go direct to the language's source code. (Do a docs search for FIXME and you'll find that this is not an isolated case.) That doesn't happen with Python, largely a consequence (if somewhat indirectly) of its being so widely u

Early binding as an option

2011-08-02 Thread Chris Angelico
ormal declarations of variables, and the consequential simplification of local code, although since there are no globals being looked up here, there's little to be gained from those. Is this the realm of JIT compilation, or can it be done in regular CPython? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: How to define repeated string when using the re module?

2011-08-02 Thread Chris Rebert
org/2008/03/30/python-html-parser-performance/ Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: 'Use-Once' Variables and Linear Objects

2011-08-02 Thread Chris Rebert
On Tue, Aug 2, 2011 at 7:19 AM, Neal Becker wrote: > I thought this was an interesting article > > http://www.pipeline.com/~hbaker1/Use1Var.html See also: http://en.wikipedia.org/wiki/Uniqueness_type Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Early binding as an option

2011-08-02 Thread Chris Angelico
operations. If "len" could be replaced with "@10794928" where 10794928 is the actual address of the len object, then it'd be doing no work that isn't normally done, and would go straight to the object and call it. But I don't really know how to go about profilin

Re: Early binding as an option

2011-08-02 Thread Chris Rebert
On Tue, Aug 2, 2011 at 9:55 AM, Chris Angelico wrote: > As I understand it, Python exclusively late-binds names; when you > define a function, nothing is ever pre-bound. This allows a huge > amount of flexibility (letting you "reach into" someone else's > function and

Re: Early binding as an option

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 9:23 PM, Terry Reedy wrote: > On 8/2/2011 12:55 PM, Chris Angelico wrote: >> >> As I understand it, Python exclusively late-binds names; when you >> define a function, nothing is ever pre-bound. > > By 'pre-bound' you presumably mean

Re: Early binding as an option

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 11:21 PM, Gelonida N wrote: > On the other hand: It might be interesting, that the early binding would > just take place when python is invoked with -O > This could be an excellent safety catch, but on the other hand, it might destroy all value of the feature - once again,

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

2011-08-02 Thread Chris Rebert
are whether it generates a new object or not? If you /really/ need a sorted mapping datatype, google for "sorteddict" (which is quite distinct from OrderedDict). Or look for a binary search tree or skip list implementation of some sort; but these aren't commonly used in Python, so

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

2011-08-02 Thread Chris Angelico
be inclined to use dictionary-literal syntax: a,b,c,d,e = {},{},{},{},{} It might be possible to do something weird with map(), but I think it'll end up cleaner to do it this way. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Early binding as an option

2011-08-03 Thread Chris Angelico
On Wed, Aug 3, 2011 at 5:46 AM, Dennis Lee Bieber wrote: >        Horrors... That looks like some MUF code I've seen (I never had a > MUF flag on my old characters, so had no privilege to write in MUF -- > MPI was available to all, and even it had some links to MUF operations > using similar magic

Re: Early binding as an option

2011-08-03 Thread Chris Angelico
On Wed, Aug 3, 2011 at 11:16 AM, Steven D'Aprano wrote: > Chris Angelico wrote: >> Of course; that's a different issue altogether. No, I'm talking about >> the way a tight loop will involve repeated lookups for the same name. > > It's not really a dif

Re: python distributed computing

2011-08-03 Thread Chris Angelico
! Since you profiled your code up in step 1, you'll know which parts are the best candidates for C code. I think there are quite a few options better than forking across computers; although distributed computing IS a lot of fun. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Snippet: The leanest Popen wrapper

2011-08-03 Thread Chris Rebert
ally don't want to have to worry about doing proper shell escaping yourself. >                     stdout= subprocess.PIPE, >                     stderr= subprocess.PIPE, >                     bufsize= 4096 ) Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Early binding as an option

2011-08-03 Thread Chris Angelico
On Wed, Aug 3, 2011 at 8:51 PM, Steven D'Aprano wrote: > Chris Angelico wrote: > >> Ah! I was not aware of this, and thought that locals were a dictionary >> too. Of course, it makes a lot of sense. In that case, the classic >> "grab it as a local" isn&#x

Re: Equality check

2011-08-03 Thread Chris Angelico
On Wed, Aug 3, 2011 at 8:15 PM, Dave Angel wrote: > If one is complex, ... The situation is complex enough without bringing complex numbers into it! OP, I recommend reading this page and then re-asking your question: http://www.catb.org/~esr/faqs/smart-questions.html ChrisA -- http://mail.pyth

Re: python module to determine if a machine is idle/free

2011-08-03 Thread Chris Rebert
ions on > which python module I should use to detect if a machine is not performing > idle (ex. Some specific task is not running)? Yes, psutil: http://code.google.com/p/psutil/ os.getloadavg() may or may not also be useful to you: http://docs.python.org/library/os.html#os.getloadavg C

Re: range() vs xrange() Python2|3 issues for performance

2011-08-04 Thread Chris Angelico
On Thu, Aug 4, 2011 at 4:01 AM, Steven D'Aprano wrote: >        a, b = divmod(n, i) >        if b == 0: >            total += a+i > Wouldn't this fail on squares? It happens to give correct results as far as I've checked; no square up to 10,000 is called perfect, and there are no perfect squares

Re: Inconsistencies with tab/space indentation between Cygwin/Win32?

2011-08-04 Thread Chris Rebert
e indents are /recommended/ by PEP 8, but the interpreter does not require or prefer that style. What the interpreter does when parsing indentation is rather more complicated; see http://docs.python.org/reference/lexical_analysis.html#indentation You might wanna look at tabnanny: http:/

Re: making my extensions work together

2011-08-04 Thread Chris Angelico
On Thu, Aug 4, 2011 at 2:19 AM, Mathew wrote: > I have 2 extensions and they both access a function in a (static) library. > The function maintains state information using a static variable. If your extensions are DLLs and they're both linking to the same static library, you should have two indep

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Chris Rebert
On Thu, Aug 4, 2011 at 1:10 AM, Thomas Rachel wrote: > Am 03.08.2011 19:27 schrieb Chris Rebert: > >>>                     shell= True, >> >> I would strongly encourage you to avoid shell=True. > > ACK, but not because it is hard, but because it is unnecess

Re: PyWhich

2011-08-04 Thread Chris Rebert
gt;        sys.exit(0) Nothing wrong per se, but the flush()es seem unnecessary, and why do stdout.write() when you can just print()? Cheers, Chris -- I can't not think of the pitchman when I read your posts... http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Early binding as an option

2011-08-04 Thread Chris Torek
>Chris Angelico wrote: [snippage] >> def func(x): >>len = len # localize len >>for i in x: >>len(i) # use it exactly as you otherwise would In article <[email protected]> Steven D'Aprano wrote: >That ca

Re: PyWhich

2011-08-04 Thread Chris Angelico
On Fri, Aug 5, 2011 at 1:34 AM, Steven D'Aprano wrote: > Especially for a tool aimed at programmers (who else would be interested in > PyWhich?) The use that first springs to my mind is debugging import paths etc. If you have multiple pythons installed and aren't sure that they're finding the rig

Re: JSON Strict Mode

2011-08-04 Thread Chris Rebert
code corresponding to your pseudocode: if strict: raise NonFreeLicenseError("The '%s' license is nonfree and thus impermissible." % x) As written, I have NonFreeLicenseError as a kind of ValueError. This may or may not be appropriate depending on your program; a list of

<    26   27   28   29   30   31   32   33   34   35   >