Re: Python/C++ timer intermittent bug

2010-07-01 Thread Paul
Thanks, Thomas. The answer to most of your questions is that I'm very new at this! I'm asking this on the forums you suggested. - Paul On Thu, 01 Jul 2010 19:23:53 +0200, Thomas Jollans wrote: >On 06/30/2010 09:28 PM, [email protected] wrote: >> I have a problem with

IMAP Problems

2010-07-02 Thread Paul
y commented out as I replaced it with a imap.search to get the thing working. These are probably very simple things, but I've not tried this library before so am a bit stuck so any help wwould be very gratefully received. Thanks, Paul Code: # -*- coding: cp1252 -*- import imaplib,email #

[ANN] inflect.py: generate plurals, ordinals, numbers to words...

2010-07-15 Thread Paul
;runs') 'running' >>> p.prespart('flies') 'flying' numbers to words: >>> p.numwords(1234567) 'one million, two hundred and thirty-four thousand, five hundred and sixty-seven' Installation: "pip install inflect" or "easy_install inflect" PyPi: http://pypi.python.org/pypi/inflect Bug Tracker: http://github.com/pwdyson/inflect.py/issues Source Code: http://github.com/pwdyson/inflect.py Cheers, Paul Dyson -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN] inflect.py: generate plurals, ordinals, numbers to words...

2010-07-16 Thread Paul
> Thomas Jollans, 15.07.2010 18:41: > > On 07/15/2010 01:00 PM, Paul wrote: > >> I'm pleased to announce the release of inflect.py v0.1.8, a module that > >> correctly generates: > >> * the plural of singular nouns and verbs > >> * the singular

Re: challenging problem for changing to a dedicated non-privileged user within a script.

2009-07-23 Thread paul
ing a new process which gets another uid through sudo. This does not affect the parent process. hth Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: challenging problem for changing to a dedicated non-privileged user within a script.

2009-07-23 Thread paul
Krishnakant schrieb: On Thu, 2009-07-23 at 13:50 +0200, paul wrote: If the user running python program is allowed to call setuid() then yes. NO, i don't think i can do that. I am getting opperation not permitted. Any ways I think probably subprocess will have to sort it out. Did yo

Re: socket policy flash help

2009-08-01 Thread paul
self.sockfd.send(b); And the error is? Doesn't Flash use http as transport? cheers Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Python or ActionScript 3.0

2009-08-16 Thread paul
seems quite popular in the scientific community and for system administration these days. Heard that python is similar to lisp. But both python and AS 3.0 is almost identical. Which is more similar to lisp are powerful? If python is 100m away from lisp, than it's 102.32m for AS3. ch

Re: why python got less developers ?

2009-08-29 Thread paul
nt do "one" thing better than the competition. From there on, they had more ressources (developer time) and grew fast and beyond the original problem domain. Now you can write GUI apps in PHP, great! cheers Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: sympy.nsimplify

2013-05-21 Thread Paul Rudin
Skip Montanaro writes: > Very cool indeed. In the comments was a link to an XKCD cartoon. Its > tool tip mentioned "twin primes". Looked that up. Google pointed (of > course) at Wikipedia. Read that. Backed up to the Google Search, and > noticed there is a news item from 15 hours ago that a

Re: Apache and suexec issue that wont let me run my python script

2013-06-02 Thread Paul Kölle
sion to open the log file that the suexec call requires. Yes, so which logfile and what user is suexec using to run your script? You should be able to answer all this from your apache configuration. cheers Paul -- http://mail.python.org/mailman/listinfo/python-list

Mistakes in documentation

2013-06-06 Thread Paul Volkov
Where can I submit little mistakes in Python documantation? I found one while browsing tutorial.pdf (Python 3.3.2): Section 3.1 says (on page 12): >>> word[2:5] # characters from position 2 (included) to 4 (excluded) ’tho’ Shouldn't the comment say "5 (excluded)" or "4 (included)" instead? -- ht

Re: My son wants me to teach him Python

2013-06-13 Thread Paul Rubin
Tomasz Rola writes: > I've reposted on another list and got this reply. At first I was sceptic > a bit, but for the sake of completeness, here goes. Processing language > seems to be interesting in its own right. Examples are Java-flavoured, > images are ok. There is a book "Python for Kids" t

Re: Stack Overflow moderator “animuson”

2013-07-10 Thread Paul Scott
On 10/07/2013 14:22, Chris Angelico wrote: Either that or it's funny only to other Australians. ChrisA As a South African, I found it funny too, but then again, we often get confused. -- http://mail.python.org/mailman/listinfo/python-list

Re: Kivy for Python 3.3

2013-07-11 Thread Paul Kölle
r python install is). See http://bugs.python.org/issue15315 msg191106 hth Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Editor Ergonomics [was: Important features for editors]

2013-07-11 Thread Paul Rudin
Roy Smith writes: > This is why I never understood the attraction of something like > xemacs, where you use the mouse to make text selections and run > commands out of menus. Menus are good for learning the functionality, and you have them just as much in Gnu emacs as in xemacs. You can even us

Re: Kivy for Python 3.3

2013-07-12 Thread Paul Kölle
sts glew.h is part of VisualStudio, and has some other interesting information. hth Paul -- http://mail.python.org/mailman/listinfo/python-list

[ANN] pyparsing 2.0.1 released - compatible with Python 2.6 and later

2013-07-20 Thread Paul McGuire
pport and interest in pyparsing! -- Paul McGuire -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem installing Pyparsing

2013-07-20 Thread Paul McGuire
Pyparsing 2.0.1 fixes this incompatibility, and should work with all versions of Python 2.6 and later. -- Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I make this piece of code even faster?

2013-07-21 Thread Paul Rudin
Steven D'Aprano writes: > On Sat, 20 Jul 2013 13:22:03 -0700, pablobarhamalzas asked: > > "How can I make this piece of code even faster?" > > - Use a faster computer. > - Put in more memory. > - If using Unix or Linux, decrease the "nice" priority of the process. > > I mention these because some

Re: Is that safe to use ramdom.random() for key to encrypt?

2012-06-20 Thread Paul Rudin
[email protected] writes: > On 2012-06-17, Jon Clements wrote: > >> Whatever you do - *do not* attempt to write your own algorithm. > > very true If everyone took that advice then we'd have a problem -- http://mail.python.org/mailman/listinfo/python-list

Re: [newbie] Equivalent to PHP?

2012-06-21 Thread Paul Rubin
Gilles writes: > Do Python hosters provide a VM so that it's just like a remote Linux > server where I'm free to install whatever I want, or do they force > users to use specific versions of Python and specific frameworks eg. > Django? There are both kinds. The first kind is called a Virtual Pri

Re: tiffany 0.6.1 released

2012-06-30 Thread Paul Rubin
Christian Tismer writes: > Tiffany stands for any tiff. The tiny module solves a large set of > problems, has no dependencies and just works wherever Python works. > Tiffany was developed in the course of the *DiDoCa* project and will > always appear on PyPi. This sounds pretty neat. I didn't co

Re: code review

2012-07-04 Thread Paul Rudin
Mark Lawrence writes: > On 03/07/2012 03:25, John O'Hagan wrote: >> On Tue, 3 Jul 2012 11:22:55 +1000 >> >> I agree to some extent, but as a counter-example, when I was a child there >> a subject called "Weights and Measures" which is now redundant because of the >> Metric system. I don't miss ho

Re: adding a simulation mode

2012-07-04 Thread Paul Rubin
andrea crotti writes: > copytree(src, dest) becomes: > if not PRETEND_ONLY: > copytree(src, dest) > > But I don't like it too much because I would have to add a lot of > garbage around.. I've had good results writing the module under test in the style of a java applet, i.e. one of its args is

2 + 2 = 5

2012-07-04 Thread Paul Rubin
I just came across this (https://gist.github.com/1208215): import sys import ctypes pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5)) five = ctypes.cast(id(5), pyint_p) print(2 + 2 == 5) # False five.contents[five.contents[:].index(5)] = 4 print(2 + 2 == 5) # Tru

Re: Finding duplicate file names and modifying them based on elements of the path

2012-07-18 Thread Paul Rubin
"[email protected]" writes: > I have an interesting problem I'm trying to solve. I have a solution > almost working, but it's super ugly, and know there has to be a > better, cleaner way to do it. ... > > My solution involves multiple maps and multiple iterations through the > data. How woul

Re: Encapsulation, inheritance and polymorphism

2012-07-19 Thread Paul Rudin
Steven D'Aprano writes: > For example, both ML and Haskell can, under some circumstances, report a > type-error for an infinite loop, *at compile time*. ... and in Charity all programs are guaranteed to terminate. Of course it's not Turing complete.

Re: Finding duplicate file names and modifying them based on elements of the path

2012-07-19 Thread Paul Rubin
"[email protected]" writes: > Thanks for the reply Paul. I had not heard of itertools. It sounds > like just what I need for this. But I am having 1 issue - how do you > know how many items are in each group? Simplest is: for key, group in groupby(xs, lambd

Re: Finding duplicate file names and modifying them based on elements of the path

2012-07-19 Thread Paul Rubin
"[email protected]" writes: > You can't do a len on the iterator that is returned from groupby, and > I've tried to do something with imap or defaultdict, but I'm not > getting anywhere. I guess I can just make 2 passes through the data, > the first time getting counts. Or am I missing

Re: Finding duplicate file names and modifying them based on elements of the path

2012-07-20 Thread Paul Rubin
"[email protected]" writes: > It seems that if you do a list(group) you have consumed the list. This > screwed me up for a while, and seems very counter-intuitive. Yes, that is correct, you have to carefully watch where the stuff in the iterators is getting consumed, including when there ar

Re: Finding duplicate file names and modifying them based on elements of the path

2012-07-20 Thread Paul Rudin
"[email protected]" writes: > It seems that if you do a list(group) you have consumed the list. This > screwed me up for a while, and seems very counter-intuitive. You've consumed the *group* which is an iterator, in order to construct a list from its elements. Sorry if this is excessively

Re: Converting a list of strings into a list of integers?

2012-07-22 Thread Paul Rubin
Tony the Tiger writes: > # options.modus_list contains, e.g., "[2,3,4]" Try this: import ast MODUS_LIST = ast.literal_eval(options.modus_list) literal_eval is like eval except it can only evaluate literals rather than calling functions and the like. The idea is you can use it on untrus

Re: Daemon loses __file__ reference after a while.

2012-07-24 Thread Paul Rubin
Dieter Maurer writes: > I have only one vague idea: should something try to terminate the > process, modules would start to lose their variables during shutdown. That happens all the time with multi-threaded programs, because the shutdown is happening concurrently with other threads doing stuff.

Re: Is Python a commercial proposition ?

2012-07-29 Thread Paul Rubin
Rodrick Brown writes: > Hence the reason why no one will seriously look at Python for none > glue work or simple web apps. When it comes to designing complex > applications that need to exploit large multicore systems Python just > isn't an option. That's wrong, I've run multicore apps in Python

Re: Is Python a commercial proposition ?

2012-07-30 Thread Paul Rubin
Steven D'Aprano writes: > And at that level, you aren't going to write your app in Python anyway, > and not because of the GIL. (These microcontrollers are unlikely to have > multiple cores -- why the hell does your microwave oven need two cores?) http://greenarrays.com ;-) > It seems to me th

Re: Search and replace text in XML file?

2012-07-31 Thread Paul Rudin
Terry Reedy writes: > ... a proper text-editor* > * ... Notepad++ is one such on Windows. Surely emacs is the only such on any platform? :) -- http://mail.python.org/mailman/listinfo/python-list

Re: On-topic: alternate Python implementations

2012-08-04 Thread Paul Rubin
Stefan Krah writes: > In the free software world, apparently many people like C. C is also > quite popular in the zero-fault software world: Several verification > tools do exist and Leroy et al. are writing a certified compiler for > C to plug the hole between the verified source code and the gen

Re: On-topic: alternate Python implementations

2012-08-04 Thread Paul Rubin
Stefan Behnel writes: >> C is pretty poor as a compiler target: how would you translate Python >> generators into C, for example? > Depends. If you have CPython available, that'd be a straight forward > extension type. Calling CPython hardly counts as compiling Python into C. > For the yielding,

Re: On-topic: alternate Python implementations

2012-08-04 Thread Paul Rubin
Stefan Behnel writes: >> Calling CPython hardly counts as compiling Python into C. > CPython is written in C, though. So anything that CPython does can be > done in C. It's not like the CPython project used a completely unusual > way of writing C code. CPython is a relatively simple interpreter,

Re: On-topic: alternate Python implementations

2012-08-04 Thread Paul Rubin
Steven D'Aprano writes: > Runtime optimizations that target the common case, but fall back to > unoptimized code in the rare cases that the optimization doesn't apply, > offer the opportunity of big speedups for most code at the cost of > trivial slowdowns when you do something unusual. The pr

Re: [newbie] Looking for a good introduction to object oriented programming with Python

2012-08-06 Thread Paul Rubin
Steven D'Aprano writes: >> I suspect), but can't say that I've ever used a "factory function"... > If you've ever used an ordinary function decorator, you almost certainly > have. > If you've every created a closure, you definitely have. Or anything with a __iter__ method... -- http://mail.pyth

Re: dictionary comprehensions with Python 2.4/2.5

2012-08-07 Thread Paul Rubin
Iryna Feuerstein writes: > code. The dictionary comprehensions were added to Python in version > 2.7 at first time. Is it possible to make it compatible with Python > 2.5 anyway? Perhaps by using the __future__ module? Not back to 2.5, but they're not that important anyway. Just use: d = dict

Re: I thought I understood how import worked...

2012-08-07 Thread Paul Rubin
Roy Smith writes: >> In general, you should avoid non-idempotent code. > I don't understand your aversion to non-idempotent code as a general > rule. Most code is non-idempotent. Surely you're not saying we > should never write: foo += 1 > or my_list.pop() > ??? I don't think "in gen

Re: Arithmetic with Boolean values

2012-08-11 Thread Paul Rubin
John Ladasky writes: > I have gotten used to switching back and forth between Boolean algebra > and numerical values. Python generally makes this quite easy. Generally ugly though, at least to my tastes. "Explicit is better than implicit" as the saying goes. > If the length of the list L is o

Re: Arithmetic with Boolean values

2012-08-12 Thread Paul Rubin
> which can be simplified to: > for x in range(len(L)//2 + len(L)%2): for x in range(sum(divmod(len(L), 2))): ... -- http://mail.python.org/mailman/listinfo/python-list

Re: set and dict iteration

2012-08-16 Thread Paul Rubin
Dave Angel writes: > Everything else is implementation defined. Why should an implementation > be forced to have ANY extra data structure to detect a static bug in the > caller's code? For the same reason the interpreter checks for type errors at runtime and raises TypeError, instead of letting

Re: set and dict iteration

2012-08-16 Thread Paul Rubin
Ian Kelly writes: > With regard to key insertion and deletion while iterating over a dict > or set, though, there is just no good reason to be doing that > (especially as the result is very implementation-specific), and I > wouldn't mind a more complete low-level check against it as long as > it's

Re: set and dict iteration

2012-08-16 Thread Paul Rubin
Steven D'Aprano writes: > Luckily, Python is open source. If anyone thinks that sets and dicts > should include more code protecting against mutation-during-iteration, > they are more than welcome to come up with a patch. Don't forget unit and > regression tests, and also a set of timing result

Re: How do I display unicode value stored in a string variable using ord()

2012-08-18 Thread Paul Rubin
Steven D'Aprano writes: > (There is an extension to UCS-2, UTF-16, which encodes non-BMP characters > using two code points. This is fragile and doesn't work very well, > because string-handling methods can break the surrogate pairs apart, > leaving you with invalid unicode string. Not good.) .

Re: How do I display unicode value stored in a string variable using ord()

2012-08-18 Thread Paul Rubin
Chris Angelico writes: > UTF-8 is highly inefficient for indexing. Given a buffer of (say) a > few thousand bytes, how do you locate the 273rd character? How often do you need to do that, as opposed to traversing the string by iteration? Anyway, you could use a rope-like implementation, or an i

Re: How do I display unicode value stored in a string variable using ord()

2012-08-18 Thread Paul Rubin
Chris Angelico writes: "asdfqwer"[4:] > 'qwer' > > That's a not uncommon operation when parsing strings or manipulating > data. You'd need to completely rework your algorithms to maintain a > position somewhere. Scanning 4 characters (or a few dozen, say) to peel off a token in parsing a UTF

Re: How do I display unicode value stored in a string variable using ord()

2012-08-18 Thread Paul Rubin
Chris Angelico writes: > Sure, four characters isn't a big deal to step through. But it still > makes indexing and slicing operations O(N) instead of O(1), plus you'd > have to zark the whole string up to where you want to work. I know some systems chop the strings into blocks of (say) a few hund

Re: How do I display unicode value stored in a string variable using ord()

2012-08-18 Thread Paul Rubin
Chris Angelico writes: > Generally, I'm working with pure ASCII, but port those same algorithms > to Python and you'll easily be able to read in a file in some known > encoding and manipulate it as Unicode. If it's pure ASCII, you can use the bytes or bytearray type. > It's not so much 'random

Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread Paul Rubin
Steven D'Aprano writes: > This is a long post. If you don't feel like reading an essay, skip to the > very bottom and read my last few paragraphs, starting with "To recap". I'm very flattered that you took the trouble to write that excellent exposition of different Unicode encodings in response

Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread Paul Rubin
Steven D'Aprano writes: > result = text[end:] if end not near the end of the original string, then this is O(N) even with fixed-width representation, because of the char copying. if it is near the end, by knowing where the string data area ends, I think it should be possible to scan backward

Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread Paul Rubin
Chris Angelico writes: > And of course, taking the *entire* rest of the string isn't the only > thing you do. What if you want to take the next six characters after > that index? That would be constant time with a fixed-width storage > format. How often is this an issue in practice? I wonder how

Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread Paul Rubin
Terry Reedy writes: >> Meanwhile, an example of the 393 approach failing: > I am completely baffled by this, as this example is one where the 393 > approach potentially wins. What? The 393 approach is supposed to avoid memory bloat and that does the opposite. >> I was involved in a project that

Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread Paul Rubin
Ian Kelly writes: sys.getsizeof(bytes(range(256)).decode('latin1')) > 329 Please try: print (type(bytes(range(256)).decode('latin1'))) to make sure that what comes back is actually a unicode string rather than a byte string. -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread Paul Rubin
Ian Kelly writes: print (type(bytes(range(256)).decode('latin1'))) > Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Abuse of Big Oh notation

2012-08-19 Thread Paul Rubin
Steven D'Aprano writes: > Of course *if* k is constant, O(k) is constant too, but k is not > constant. In context we are talking about string indexing and slicing. > There is no value of k, say, k = 2, for which you can say "People will > sometimes ask for string[2] but never ask for string[3]"

Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread Paul Rubin
Steven D'Aprano writes: > Paul Rubin already told you about his experience using OCR to generate > multiple terrabytes of text, and how he would not be happy if that was > stored in UCS-4. That particular text was stored on disk as compressed XML that had UTF-8 in the data field

Re: Abuse of Big Oh notation

2012-08-20 Thread Paul Rubin
Oscar Benjamin writes: > No it doen't. It is still O(k). The point of big O notation is to > understand the asymptotic behaviour of one variable as it becomes > large because of changes in other variables. Actually, two separate problems got mixed together late at night. In neither case is k an

Re: Abuse of Big Oh notation

2012-08-20 Thread Paul Rubin
Ian Kelly writes: > The difference between the two is that the former is bounded by a > constant that is fundamental to the algorithm at hand,... S is > clearly bounded by the constraints of actual shoes, so we can safely > treat S as a constant and call it O(N). Thanks, that is a good explain o

Re: How to convert base 10 to base 2?

2012-08-20 Thread Paul Rubin
Ian Kelly writes: > Everybody should know the generic algorithm, though: > from itertools import chain ... For n>0, assuming you just want the converted digits and not a string. String conversion and minus sign for n<0 left as exercise. Note this returns a generator that you can convert to a lis

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread Paul Rubin
alex23 writes: > Oh my god, how DARE people with EXPERIENCE in a language challenge the > PRECONCEPTIONS of an AMATEUR!!! HOW DARE THEY?!?! +1 QOTW :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Flexible string representation, unicode, typography, ...

2012-08-26 Thread Paul Rubin
Steven D'Aprano writes: >> http://golang.org/ref/spec#Numeric_types > Thanks. > Well that's just plain nuts. I'm not sure how Rust handles Unicode, but overall I think it is more clueful than Go while having sort of comparable goals. See: http://rust-lang.org . -- http://mail.python.org/mailman

Re: Looking for an IPC solution

2012-08-31 Thread Paul Rubin
Laszlo Nagy writes: > application will be running on a single computer, so the IPC should be > using shared memory (or mmap) and have very short response times. Zeromq (suggested by someone) is an option since it's pretty fast for most purposes, but I don't think it uses shared memory. The close

Re: Logging handler: No output

2012-09-02 Thread Paul Rubin
Florian Lindner writes: > The file is being created but stays empty. If I use a print output in the > while loop it works, so output is catched and the applications stdout in > working. But why the logger proclog catching nothing? I don't see you setting the log level anyplace in that sample, a

Re: tornado.web ioloop add_timeout eats CPU

2012-09-04 Thread Paul Rubin
Laszlo Nagy writes: > but a threaded server cannot handle 100+ simultaneous (long running) > requests, because that would require 100+ threads to be running. On a reasonable server these days, 100 threads seems to be no big deal. I've run several times that many. I think things get ragged at a f

Re: Parsing ISO date/time strings - where did the parser go?

2012-09-06 Thread Paul Rubin
John Nagle writes: > There's an iso8601 module on PyPi, but it's abandoned; it hasn't been > updated since 2007 and has many outstanding issues. Hmm, I have some code that uses ISO date/time strings and just checked to see how I did it, and it looks like it uses iso8601-0.1.4-py2.6.egg . I don't

Re: Bitshifts and "And" vs Floor-division and Modular

2012-09-06 Thread Paul Rubin
rusi writes: > On an 8086/8088 a MUL (multiply) instruction was of the order of 100 > clocks ... On most modern processors (after the pentium) the > difference has mostly vanished. I cant find a good data sheet to > quote though See http://www.agner.org/optimize/ : 4. Instruction tables: L

Re: simple client data base

2012-09-08 Thread Paul Rubin
Mark R Rivet writes: >>ones for a few dollars. You're reading about lists, tuples, and >>dictionary data? Great, but other home accounting businesses have >>their client databases automatically synced with their smart-phones >>and their time-charging and their invoicing. > Well I have to say that

Re: Is there a unique method in python to unique a list?

2012-09-09 Thread Paul Rubin
Token Type writes: def average_polysemy(pos): > synset_list = list(wn.all_synsets(pos)) > sense_number = 0 > lemma_list = [] > for synset in synset_list: > lemma_list.extend(synset.lemma_names) > for lemma in list(set(lemma_list)): >

Re: Is there a unique method in python to unique a list?

2012-09-09 Thread Paul Rubin
Paul Rubin writes: > I think you mean (untested): > > synsets = wn.all_synsets(pos) > sense_number = 0 > lemma_set = set() > for synset in synsets: > lemma_set.add(synset.lemma_names) > for lemma in lemma_set: > sense_number

Re: simple client data base

2012-09-09 Thread Paul Rubin
Tim Chase writes: > urge you in a direction less fraught with peril. Rather than starting > by duplicating existing functionality of a complex domain More importantly, as others have mentioned, the main peril comes from having someone else relying on the success of the program. If you want to l

Re: Hiring Python Developer @ CA, USA

2012-09-18 Thread Paul Rudin
[email protected] writes: > ...Must be an export in this language... Are you hiring proof readers as well? :) -- http://mail.python.org/mailman/listinfo/python-list

Re: A little morning puzzle

2012-09-19 Thread Paul Rubin
Neal Becker writes: > I have a list of dictionaries. They all have the same keys. I want to find > the > set of keys where all the dictionaries have the same values. Suggestions? Untested, and uses a few more comparisons than necessary: # ds = [dict1, dict2 ... ] d0 = ds[0] ks = set(k for

Re: Exact integer-valued floats

2012-09-21 Thread Paul Rubin
Steven D'Aprano writes: > Have I got this right? Is there a way to work out the gap between one > float and the next? Yes, 53-bit mantissa as people have mentioned. That tells you what ints can be exactly represented. But, arithmetic in some situations can have a 1-ulp error. So I wonder if i

Re: How to limit CPU usage in Python

2012-09-22 Thread Paul Rubin
Rolando Cañer Roblejo writes: > Is it possible for me to put a limit in the amount of processor usage > (% CPU) that my current python script is using? Is there any module > useful for this task? One way is check your cpu usage once in a while, compare with elapsed time, and if your % usage is a

Re: [RELEASED] Python 3.3.0 release candidate 3

2012-09-23 Thread Paul Rubin
Georg Brandl writes: > Python 3.3 includes a range of improvements of the 3.x series, as well > as easier porting between 2.x and 3.x. Major new features and changes > in the 3.3 release series are: [good stuff snipped] This is cool, and Python 3 is finally starting to show some real advantages

Re: For Counter Variable

2012-09-24 Thread Paul Rubin
alex23 writes: > To highlight the vast gulf between what you think you are and what you > actually produce. By now I think we're in the DNFTT zone. -- http://mail.python.org/mailman/listinfo/python-list

Re: Article on the future of Python

2012-09-25 Thread Paul Rubin
Kevin Walzer writes: > language, but it's another thing entirely to call Python the One > Language to Rule Them All. (That's C, because all other languages are > implemented in it. :-) ) I got into a discussion about that in another newsgroup and noticed that C seems to have been a 20th-century l

Re: Article on the future of Python

2012-09-25 Thread Paul Rubin
Chris Angelico writes: > That is true, but the concept is still around - that you can write > your code in some other language and compile to js. http://www.haskell.org/haskellwiki/The_JavaScript_Problem -- http://mail.python.org/mailman/listinfo/python-list

Re: Article on the future of Python

2012-09-26 Thread Paul Rubin
Chris Angelico writes: > When you compare against a wide build, semantics of 3.2 and 3.3 are > identical, and then - and ONLY then - can you sanely compare > performance. And 3.3 stacks up much better. I like to have seen real world benchmarks against a pure UTF-8 implementation. That means O(n)

Re: Article on the future of Python

2012-09-26 Thread Paul Rubin
Chris Angelico writes: > So, I don't actually have any stats for you, because it's really easy > to just not index strings at all. Right, that's why I think the O(n) indexing issue of UTF-8 may be overblown. Haskell 98 was mentioned earlier as a language that did Unicode "correctly", but its str

Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-26 Thread Paul Rubin
TP writes: > copies a list, he copies in fact the *pointer* to the list > Is it the correct explanation? Yes, that is correct. > In these conditions, how to make this list [[0,0,0],[0,0,0]] with "*" > without this behavior? >>> a = [[0]*3 for i in xrange(2)] >>> a[0][0]=2 >>>

Re: creating an artificial "last element" in sort list

2012-09-28 Thread Paul Rubin
dave writes: > What does x need to be to always be last on an ascending sort no > matter what 'a' and 'b' are within reason... Why are you trying to do that? It sounds ugly. Just sort the list with the a's and b's. If you absolutely have to, you could make a class with comparison methods

Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

2012-09-28 Thread Paul Rubin
iMath writes: > write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. And then you have two problems. -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] [RELEASED] Python 3.3.0

2012-09-29 Thread Paul Moore
elease, thanks to all who put it together. Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Slicing iterables in sub-generators without loosing elements

2012-09-29 Thread Paul Rubin
Thomas Bach writes: result = [ [('foo', 1), ('foo', 2)], [('bar', 3), ('bar', 2)] ] > by _only_ _iterating_ over the list (caching all the elements sharing > the same first element doesn't count)? itertools.groupby(data, lambda (x,y) : x) is basically what you want. -- http://mail.python.o

Re: Convert MAC to hex howto

2012-10-07 Thread Paul Rubin
Johannes Graumann writes: > '00:08:9b:ce:f5:d4' > ... > hexcall = "\\x".join(hexcall).decode('string_escape') I think it's best not to mess with stuff like that. Convert to integers then convert back: mac = '00:08:9b:ce:f5:d4' hexcall = ''.join(chr(int(c,16)) for c in mac.split(':'))

Re: Insert item before each element of a list

2012-10-08 Thread Paul Rubin
[email protected] writes: x = [1, 2, 3] .. y > ['insertme', 1, 'insertme', 2, 'insertme', 3] def ix(prefix, x): for a in x: yield prefix yield a y = list(ix('insertme', x)) from itertools import * y = list(chain.from_iterable(izip(repeat('insertme'

Re: What's the tidy/elegant way to protect this against null/empty parameters?

2012-10-15 Thread Paul Rubin
[email protected] writes: > I want to fix an error in some code I have installed, however I don't > really want to just bodge it. ... > Now its *probably* something higher up the tree causing the problem > (it's only one particular image in 20 thousand or so that breaks > things) but I really want

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Paul Rubin
Zero Piraeus writes: > 2. Say "screw it" and break the line using a backslash. Often the line will break ok without a backslash, but I don't feel any particular pain in using a backslash in the other cases. I do pretty rigorously try to keep all lines shorter than 72 columns or so, unless there'

error executing "import html.parser" from a script

2012-10-19 Thread Paul Volkov
What is this madness? I have Python 3.3.0 installed on Windows XP. I do not have Python 2 (but I had it before). I do the following steps: 1. Import from an interactive session (no problems) >python Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32 Typ

Compiling extension module (linker error)

2012-10-22 Thread Paul Volkov
I am trying to compile an extension module with C++ Builder 6 for Python 3.3. I converted python33.lib using coff2omf.exe and added this library into my project. I wonder why I get this error message while building: [Linker Error] Unresolved external '_PyModule_Create2TraceRefs' referenced from 'D

Re: Compiling extension module (linker error)

2012-10-23 Thread Paul Volkov
2012/10/22 MRAB : > By the way, the recommendation is for module names to be lowercase with > underscores, so "fund_rose" instead of "FundRose". > > Try this code: > I tried as you suggested, but the linker error (unresolved external) is still there. I'm sure python33.lib is properly added because

Re: Fast forward-backward (write-read)

2012-10-23 Thread Paul Rubin
Virgil Stokes writes: > Finally, to my question --- What is a fast way to write these > variables to an external file and then read them in backwards? Seeking backwards in files works, but the performance hit is significant. There is also a performance hit to scanning pointers backwards in memor

Re: Fast forward-backward (write-read)

2012-10-23 Thread Paul Rubin
Paul Rubin writes: > Seeking backwards in files works, but the performance hit is > significant. There is also a performance hit to scanning pointers > backwards in memory, due to cache misprediction. If it's something > you're just running a few times, seeking backwards t

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