Re: .Net Like Gui Builder for Python?

2014-07-26 Thread Steven D'Aprano
discovered because of a programming error. https://en.wikipedia.org/wiki/Stuxnet -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: NameError: name 'requests' is not defined ?

2014-07-27 Thread Steven D'Aprano
ort will be very fast, once a module is imported once the second and subsequent times is very quick. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Prob. Code Downloaded for Programming the Semantic Web (python code)

2014-07-28 Thread Steven D'Aprano
th(sub or pred or obj) # Parenthesised shortcut. def add(self, (sub, pred, obj)): do_stuff_with(sub or pred or obj) Both methods take a single argument, which must be a sequence of exactly three values. The second version saves a single line, hence the first version is longer :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Getting a list of all modules

2014-07-30 Thread Steven D'Aprano
built-in modules that don't live in the file system, and probably more). Is this problem already solved? Can anyone make any suggestions? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: speed up pandas calculation

2014-07-30 Thread Steven D'Aprano
're deleting from the end, not the start. But even better, and this applies to anything not just lists, is not to delete at all, but to create a new list, copying the columns you want, rather than deleting the columns you don't want. I'm not familiar with pandas and am not sure about the exact syntax needed, but something like: new_df = [] # Assuming df is a list. for col in df: if col.value in keep_col: new_df.append(col) > if f[-3:] == 'csv' and f[-6:-4] in ('93', '94', '95', '96', '97', '98', > '99', '00', '91', '02', '03', '04', '05'): Where does f come from? You haven't shown the definition of that. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: speed up pandas calculation

2014-07-30 Thread Steven D'Aprano
x27;MED5']].isin([drugs[n]]).any(1) >> >> > ​I was wrong, this is fast, it was selecting the columns that was slow. > using > keep_col = ['PATCODE', 'PATWT', 'VDAYR', 'VMONTH', 'MED1', 'MED2', > 'MED3&#

Re: Getting a list of all modules

2014-07-31 Thread Steven D'Aprano
On Wed, 30 Jul 2014 21:22:18 +0800, Leo Jay wrote: > On Wed, Jul 30, 2014 at 3:43 PM, Steven D'Aprano > wrote: >> I'm looking for a programmatic way to get a list of all Python modules >> and packages. Not just those already imported, but all those which >> *

Re: Dict when defining not returning multi value key error

2014-07-31 Thread Steven D'Aprano
> hash(n) == hash(Fraction(n)) == hash(Decimal(n)) True With the possible exception of Decimal, which is not fully integrated with the numeric tower, all numbers in the standard library will obey the condition that if x == y, hash(x) == hash(y), regardless of type. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python and IDEs

2014-08-01 Thread Steven D'Aprano
ailable with yum and write the rest yourself. +0.8 on that. Sometimes I install software outside of the package management system, but I always feel a tad dirty when I do so :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: dict to boolean expression, how to?

2014-08-01 Thread Steven D'Aprano
oes away. *wink* But seriously: if you need to ask "why not use eval?", you're not ready to use eval safely. But in a nutshell: - using eval is a large performance hit (about 10 times slower); - eval is dangerous and can introduce code injection vulnerabilities. eval is almost never the right solution to any problem, and in the very few exceptions, it needs careful handling by an expert to ensure you're not introducing serious security bugs. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Dict when defining not returning multi value key error

2014-08-01 Thread Steven D'Aprano
On Fri, 01 Aug 2014 14:17:41 +1000, Ben Finney wrote: > Steven D'Aprano writes: > >> On Thu, 31 Jul 2014 20:12:12 -0700, Dan Stromberg wrote: >> >> > I removed some quotes, and noticed that 1 and 1.0 hash the same. >> > That's a bit

Re: dict to boolean expression, how to?

2014-08-01 Thread Steven D'Aprano
On Fri, 01 Aug 2014 09:32:36 -0400, Roy Smith wrote: > In article <[email protected]>, > Steven D'Aprano wrote: > >> eval is almost never the right solution to any problem, and in the very >> few exceptions, it needs careful

Re: dict to boolean expression, how to?

2014-08-01 Thread Steven D'Aprano
of anyone here who is an expert in pandas, so if you ask questions which are specific to pandas, we may run into the limits of our knowledge. If you can find a dedicated pandas mailing list or other forum, they may help too, but I don't know if they will be more or less willing to explain the basics about Python. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Getting a list of all modules

2014-08-01 Thread Steven D'Aprano
On Fri, 01 Aug 2014 14:39:09 +0100, Robert Kern wrote: > Take a look at what has already been implemented in IPython: > > https://github.com/ipython/ipython/blob/master/IPython/core/ completerlib.py#L208 Awesome! Thank you! -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: dict to boolean expression, how to?

2014-08-01 Thread Steven D'Aprano
On Fri, 01 Aug 2014 16:50:51 +0100, Mark Lawrence wrote: >> which can be simplified to: >> >> flag = any( cond[c] == 1 and cond[c.upper()] for c in ['a', 'b', 'c'] ) >> >> > Shouldn't that be cond[c.upper()] == 0 ? Yes it sh

Re: Dict when defining not returning multi value key error

2014-08-01 Thread Steven D'Aprano
our first collision. - It relies on the checksum being unpredictable, to prevent substitution attacks: you're expecting object x with checksum a, but somebody substitutes object y with checksum a instead. Python's hash() function is not cryptographically strong and makes no claim to be. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

eval [was Re: dict to boolean expression, how to?]

2014-08-01 Thread Steven D'Aprano
"((df[{}] == 1) | (df[{}] == 0))".format(c, c.upper()) for c in df > is c.islower()) > result = eval(expr) I really don't believe that there is any benefit to that in readability, power, flexibility, or performance. Also, you're using bitwise operators instead of shortcut bool operators. Any reason why? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Steven D'Aprano
re are two intended uses for object and its instances: - as the base class for all other classes; - instances can be used as featureless sentinel objects where only identity matters. If you need instances which carry state, then object is the wrong class. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Steven D'Aprano
re with sufficient effort we could do so, but that's a lot of effort for negligible (or even negative) gain. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Programing for the Absoulte Beginner

2014-08-03 Thread Steven D'Aprano
like learning a new language. It's more like the difference between American and British English. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Correct type for a simple "bag of attributes" namespace object

2014-08-03 Thread Steven D'Aprano
be class-based. Also, the first OOP languages (Simula and, especially, Smalltalk) are class-based, and people tend to copy what's been done before and what they're familiar with. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Correct type for a simple "bag of attributes" namespace object

2014-08-03 Thread Steven D'Aprano
allible. Suppose you're expecting an Artist, and call the artist.draw() method, but somebody gives you a Gunfighter instead. There's also the problem of what to do when an object provides only *part* of an interface: sometimes, by the time you have to ask forgiveness, you've al

Re: CodeSkulptor

2014-08-03 Thread Steven D'Aprano
odeSkultor. datetime is a standard Python library, if CodeSkulptor doesn't provide it, that's a serious bug. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: try/exception - error block

2014-08-03 Thread Steven D'Aprano
nt "exit" > sys.exit() That's all dead code. I hope it isn't important. > except Exception, e: > print e > print "pycolFac1 - error!! \n"; Does that get printed? > name=subprocess.Popen('uuidgen -t', shell=True,stdout=subprocess.PIPE) > name=name.communicate()[0].strip() > name=name.replace("-","_") > name2="/home/ihubuser/parseErrTest/pp_"+name+".dat" > ofile1=open(name2,"w+") > ofile1.write(e) > ofile1.write(aaa) > ofile1.close() > sys.exit() That's awfully ambitious code for an except clause that you're not even sure is working. Simplify, simplify, simplify. except Exception, e: with open("/tmp/myerror.txt", "w") as f: f.write("%r" % e) sys.exit(102) Now you should be able to see the error written to the file, which you should have write privileges to unless you're doing something very unusual. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: CodeSkulptor

2014-08-03 Thread Steven D'Aprano
Seymore4Head wrote: > On Sun, 03 Aug 2014 22:08:21 -0400, Seymore4Head > wrote: > >>On Mon, 4 Aug 2014 11:43:48 +1000, Chris Angelico >>wrote: >> >>>On Mon, Aug 4, 2014 at 11:29 AM, Steven D'Aprano >>> wrote: >>>>> Putting tha

Re: How to pack a string variable of length 1 as a char using struct.pack?

2014-08-05 Thread Steven D'Aprano
;char format requires a bytes object of > length 1": > s = '1' > p = struct.pack('c', s) Here you use a Unicode string of length 1, '1'. Do this instead: s = b'1' p = struct.pack('c', s) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Steven D'Aprano
maybe*, barely acceptable as a quick-and-dirty convenience at the interactive interpreter, in a Bunch or Bag class that has very little in the way of methods or behaviour, but not acceptable for a class as fundamental and important as dict. No matter what Javascript thinks. Consider: d

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Steven D'Aprano
y mydict$key, but the proliferation of "many ways to do it" (to paraphrase the Perl motto) has costs of its own. It's harder to learn, read and understand Perl code than Python code, simply because there's more syntax to learn, and more special cases to understand. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: eval [was Re: dict to boolean expression, how to?]

2014-08-05 Thread Steven D'Aprano
Duncan Booth wrote: > Steven D'Aprano wrote: [...] >> My refactoring, with the bare minimum use of exec necessary: >> >> https://code.activestate.com/recipes/578918-yet-another-namedtuple/ > > > This may be a silly question, but what would stop you moving th

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-05 Thread Steven D'Aprano
Duncan Booth wrote: > Steven D'Aprano wrote: > >> Unfortunately, software development on Windows is something of a >> ghetto, compared to the wide range of free tools available for Linux. I remember writing this. But I don't remember when it was. Presumably some

Re: Making every no-arg method a property?

2014-08-05 Thread Steven D'Aprano
nction(obj): if inspect.getargspec(obj) == (['self'], None, None, ()): setattr(cls, name, property(obj)) return cls @make_zero_arg_methods_into_properties class Spam: def eggs(self): ... -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Making every no-arg method a property?

2014-08-06 Thread Steven D'Aprano
On Wed, 06 Aug 2014 12:07:58 +1000, Chris Angelico wrote: > On Wed, Aug 6, 2014 at 10:49 AM, Steven D'Aprano > wrote: >> A >> plethora of argument-less methods is a code smell -- that doesn't mean >> it's *necessarily* a bad idea, but the class design reall

Re: Python 3 is killing Python

2014-08-06 Thread Steven D'Aprano
for as long as needed; - or do without bug fixes and security updates. If you want bug fixes, security updates AND feature enhancements, for free, you have have to migrate to Python 3 (or another language). If you're unhappy with that, write to Oprah, I'm sure she'll listen. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Test for an empty directory that could be very large if it is not empty?

2014-08-06 Thread Steven D'Aprano
ble to (potentially) slow down the common case of local file systems by a tiny amount, in order to protect against the (rare) case where it will give a big speed things up? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-06 Thread Steven D'Aprano
uot; I daresay that Linus Torvalds spends more time in front of a computer screen than most 9 to 5 "screenworkers". By the way, you keep replying to people, and quoting them, but deleting their name. Please leave the attribution in place, so we know who you are replying to. -- Steven

Re: Wikibooks example doesn't work

2014-08-06 Thread Steven D'Aprano
we normally shouldn't need to, if you give as the details you already have. And of course just because it "doesn't work" on your system, doesn't mean it won't work on ours. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3 is killing Python

2014-08-06 Thread Steven D'Aprano
2.x users can be as > confident that Python 2.x will be supported on future operating systems. Oh well, life wasn't meant to be easy. Fortunately they can run it under Windows 98 or Centos 3.5 in a virtual machine. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Wikibooks example doesn't work

2014-08-06 Thread Steven D'Aprano
back and asking for another guess. You don't check the counter until after the loop has finished. It needs to be inside the loop, not outside: while looping: # See the indent? # this is inside the loop # No indent. # This is outside the loop. Also, having reached the count of

Re: AttributeError: 'module' object has no attribute 'fork'

2014-08-07 Thread Steven D'Aprano
fork() except NotImplementedError: is_implemented = False else: if pid == 0: # In the child process. os._exit(0) # Unconditionally exit, right now, no excuses. is_implemented = True which is not obvious, simple or cheap. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: AttributeError: 'module' object has no attribute 'fork'

2014-08-07 Thread Steven D'Aprano
Rustom Mody wrote: > On Thursday, August 7, 2014 10:26:56 PM UTC+5:30, Steven D'Aprano wrote: >> Roy Smith wrote: > >> > Peter Otten wrote: >> >> os.fork() >> >> Fork a child process. >> >> ... >> >> Availability: Un

Re: Keep one GUI always on TOP while python code is running

2014-08-08 Thread Steven D'Aprano
his out of the box, but I expect that there's probably a way to do it in a platform specific way on each platform you wish to support. Either that, or the OP can google for (including the quotes) and see what comes up. I'd do so myself, except some damn fool Javascript code running on some rubbish web site just crashed my browser. Again. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Template language for random string generation

2014-08-08 Thread Steven D'Aprano
ng for exactly the same purposes > each time So, there's nothing wrong with it, except for the five things you list which are wrong with it :-) Seriously, if you're going to compete with the Stackoverflow ad hoc solutions, you have to be more assertive that there is a problem with the ad hoc solutions. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Keep one GUI always on TOP while python code is running

2014-08-08 Thread Steven D'Aprano
Chris Angelico wrote: > On Fri, Aug 8, 2014 at 11:58 PM, Steven D'Aprano > wrote: >> Chris Angelico wrote: >> >>> Yeah; like I said, "Don't" is the short answer. There will be >>> exceptions, some extremely rare situations when system mod

Re: how to get the ordinal number in list

2014-08-08 Thread Steven D'Aprano
if obj == target: results.append(i) return results index_all(x, "x3") => returns [1, 3] -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: attendance system in pybluez

2014-08-09 Thread Steven D'Aprano
mes = True) > print("found %d devices" % len(nearby_devices)) > > > The function can discover all of them ? 300 bluetooth mac address? You will have to ask the author of the bluetooth module. Where did you find it? Does it come with documentation? Did you read it? -- S

Re: how to get the ordinal number in list

2014-08-09 Thread Steven D'Aprano
hink suggesting comprehensions in an answer should be reserved for > people at levels 3 and 4. Maybe level 2-1/2. Certainly not level 1. Yes, this! Strongly agreed. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: how to write file into my android phone?

2014-08-10 Thread Steven D'Aprano
on a pc as a drive at all. >> For example the Samsung gs4. > > This is actually true for ALL android devices, starting with Android 3.0. o_O Android phones don't mount as storage devices? Oh well, that's Android crossed off my list. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Template language for random string generation

2014-08-10 Thread Steven D'Aprano
...") I can't see any way to realistically attack the password generator based on the weakness of the random number generator. Perhaps I'm missing something? > Someone should write a cryptographically secure pseudorandom number > generator library for Python. :( Here, let me google that for you :-) https://duckduckgo.com/html/?q=python+crypto -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: how to get the ordinal number in list

2014-08-10 Thread Steven D'Aprano
eralised print. Wait... I get it... you have a print, it's just a function, not a statement. Am I close? > Instead if we treated the python: > > [x**2 for x in range(10)] > > as an executable version for the standard set-theory expression: > > {x² | x ∈ [0.

Re: how to get the ordinal number in list

2014-08-10 Thread Steven D'Aprano
n+1] = x[n] + 1 we have a perfectly good mathematical recursive definition. All it needs is an initial value x[0] and we're good to go. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Template language for random string generation

2014-08-10 Thread Steven D'Aprano
Devin Jeanpierre wrote: > On Sun, Aug 10, 2014 at 9:31 AM, Steven D'Aprano > wrote: >> I don't think that using a good, but not cryptographically-strong, random >> number generator to generate passwords is a serious vulnerability. What's >> your threat mo

Re: how to get the ordinal number in list

2014-08-10 Thread Steven D'Aprano
t;. That's what I mean by >> first you come up with an algorithm, then you implement it in code. > >>>> l= [6,2,9,12,1,4] >>>> sorted(l,reverse=True)[:5] > [12, 9, 6, 4, 2] > > No need to know how sorted works nor [:5] > > Now you (or Steven) can

Is print thread safe?

2014-08-11 Thread Steven D'Aprano
but I do care if the two lines are mixed in together, something like this: spam spaeggs eggs m seggspams Does print perform its own locking to prevent this? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: how to get the ordinal number in list

2014-08-11 Thread Steven D'Aprano
ext does not necessarily have the same meaning as in another context. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What's the future of perfect Python?

2014-08-11 Thread Steven D'Aprano
O Python is designed > by great Guido van Rossum then what is the future of Python( Guido van > Rossum, GREAT man, but STILL just one person)? " Haven't you heard? Guido has retired. http://legacy.python.org/dev/peps/pep-0401/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: how to get the ordinal number in list

2014-08-11 Thread Steven D'Aprano
ew experimental asynchronous CPUs, computers are all based on CPUs with an internal clock signal which synchronizes distinct parts of the circuit with each other. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: how to get the ordinal number in list

2014-08-11 Thread Steven D'Aprano
On Sun, 10 Aug 2014 21:29:12 -0700, Rustom Mody wrote: > On Monday, August 11, 2014 8:30:32 AM UTC+5:30, Steven D'Aprano wrote: > >> You did the same thing in your own course, the only difference being >> you accepted a different set of primitive functions. But ul

Re: how to get the ordinal number in list

2014-08-11 Thread Steven D'Aprano
Chris Angelico wrote: > On Mon, Aug 11, 2014 at 7:44 PM, Steven D'Aprano > wrote: >> And even when you can >> parallelize a series of tasks, it's > > ... easy for one task to get aborted part way while the rest of the > tasks continue on, oblivious to the a

Re: Is print thread safe?

2014-08-11 Thread Steven D'Aprano
INADA Naoki wrote: > On Python 3, print is thread safe. > > But Python 2 has broken scenario: Is this documented somewhere? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Is print thread safe?

2014-08-11 Thread Steven D'Aprano
Cameron Simpson wrote: > On 12Aug2014 02:07, Steven D'Aprano > wrote: >>INADA Naoki wrote: >> >>> On Python 3, print is thread safe. >>> But Python 2 has broken scenario: >> >>Is this documented somewhere? > > In python/2.7.6/reference/

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-11 Thread Steven D'Aprano
or one reason or another) is missing some of the referenced posts, possibly because they have expired, or were never delivered in the first place. So please stop being rude, and follow the convention of both email and usenet (as well as broader society) to give attribution to those you quote.

Re: Quoting and attribution (was: Python and IDEs [was Re: Python 3 is killing Python])

2014-08-11 Thread Steven D'Aprano
On Mon, 11 Aug 2014 19:27:25 -0500, Tim Chase wrote: > On 2014-08-12 10:11, Steven D'Aprano wrote: >> It is rude to deliberately refuse to give attributes > > While I find this true for first-level attribution, I feel far less > obligation to attribute additional levels

Re: Suitable Python code to scrape specific details from web pages.

2014-08-12 Thread Steven D'Aprano
ike that > off the 'inspect element' or 'source' htaml pages, on www.Racingpost.com. Specifically those pages? Doubtful. If you are really lucky (1) somebody else has already done the programming, (2) they've made their program available to others, and (3) you can

Re: how to get the ordinal number in list

2014-08-12 Thread Steven D'Aprano
Chris Angelico wrote: > On Mon, Aug 11, 2014 at 7:44 PM, Steven D'Aprano > wrote: >> I think this is why both declarative and functional programming idioms >> will remain niche (although important niches). Most tasks are inherently >> imperative to at least so

Re: how to get the ordinal number in list

2014-08-12 Thread Steven D'Aprano
y abstraction of the concept of sorting a collection. Both are abstractions, because they are *intended* to gloss over real world details of Real numbers and sorting, but both leak because the implementation of the abstraction spoils the abstraction. http://www.joelonsoftware.com/articles/LeakyAbstractions.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: how to get the ordinal number in list

2014-08-12 Thread Steven D'Aprano
Steven D'Aprano wrote: [...] > I am using "abstract" in the sense of an abstraction, as opposed to > something concrete and real, not as a mechanism for specifying interfaces > in Java or Python. Python's float is a leaky abstraction of mathematical > Real numbers,

Re: [Announce] Python-Future v0.13; cheatsheet for Python 2/3 compatible code

2014-08-13 Thread Steven D'Aprano
e only works in certain versions of Python 2? E.g. raising bare strings only works up to Python 2.5, in 2.6 and higher it is a syntax error. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Arbitrary dunder attributes (was Re: odd difference calling function from class or instance variable)

2014-08-13 Thread Steven D'Aprano
didn't even know about __self__, but I understood __func__ to be public. And yes, it should be public: being able to introspect a method and find the function it came from is a good thing, and sometimes useful. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Log base 2 of large integers

2014-08-13 Thread Steven D'Aprano
of log2, the simplest way is calculate it like this: def log2(n): """Return the floor of log2(n).""" if n <= 0: raise ValueError i = -1 while n: n //= 2 i += 1 return i log2(511) => returns 8 log2(512) => returns 9 log2(

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-13 Thread Steven D'Aprano
Wolfgang Keller wrote: > I've been using mail and news for over 20 years now, you definitely > don't need to teach me anything. Except common courtesy. You may have been rude for over 20 years, but I don't have to put up with it for a second longer. > Good Bye, Agree

Why does str not have a __radd__ method?

2014-08-13 Thread Steven D'Aprano
e "", line 1, in AttributeError: type object 'str' has no attribute '__radd__' This is especially astonishing, since int and float both have __radd__ methods, and yet numeric addition is commutative (x+y == y+x) whereas the same is not true for string concatena

Re: Captcha identify

2014-08-13 Thread Steven D'Aprano
d it for stuff, so dont worry :-) You'll only use it for good, right? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Why does str not have a __radd__ method?

2014-08-13 Thread Steven D'Aprano
Ethan Furman wrote: > On 08/13/2014 09:00 AM, Steven D'Aprano wrote: >> >> What is the rationale for str not having __radd__ method? > > At a guess I would say because string only knows how to add itself to > other strings, so __add__ is sufficient. # Pyt

[OT] Awesome bug of the week

2014-08-13 Thread Steven D'Aprano
Nothing to do with Python, but awesome: "OpenOffice won't print on Tuesdays". https://bugs.launchpad.net/ubuntu/+source/cupsys/+bug/255161/comments/28 -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Optional static typing

2014-08-13 Thread Steven D'Aprano
The BDFL Guido van Rossum is considering optional static typing (ish) for Python 3.5: https://mail.python.org/pipermail/python-ideas/2014-August/028618.html Does anyone here use function annotations? If so, what do you use them for? -- Steven -- https://mail.python.org/mailman/listinfo

Re: a python console in bluestacks

2014-08-14 Thread Steven D'Aprano
id development on his PC, instead of poking at the virtual keyboard on a screen the size of your palm, being able to test the software on the PC (under emulation) rather than having to upload it to your phone is very useful. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'?

2014-08-14 Thread Steven D'Aprano
es of code, and deals with generator .close() and .throw() methods, error checking, and various other issues. That is why "yield from" was added to Python. The simple case is too simple to care about, the complicated cases are too complicated to expect people to write their own solutions, so it was added to the language. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Unable to run print('Réussi') on windows and on linux

2014-08-14 Thread Steven D'Aprano
ve you garbage. * Fix your system to use UTF-8 by default. * Fix your editor to use UTF-8. * Add a UTF-8 encoding declaration. And then things should work. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Matplotlib Contour Plots

2014-08-14 Thread Steven D'Aprano
lib contour plot", and it only took that long because I misspelled "contour" the first time. http://matplotlib.org/examples/pylab_examples/contour_demo.html Does this help? If not, please explain what experience you have with matplotlib, what you have tried, what you expected it

Re: Matplotlib Contour Plots

2014-08-15 Thread Steven D'Aprano
], ... [9.5, 8.1, 7.0, 6.2] ]) # Two dimensional array py> b array([[ 1.2, 2.5, 3.7, 4.8], [ 9.5, 8.1, 7. , 6.2]]) One dimensional arrays are made from a single list of numbers: [...] Two dimensional arrays are made from a list of lists: [ [...], [...] ] -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Matplotlib Contour Plots

2014-08-15 Thread Steven D'Aprano
ou can check the dimensions by storing the array into a variable like this: py> a = numpy.array([[[ 2, 2, 2, 1, 2]], [[ 8, 8, 8, 7, 8]]]) py> a.shape (2, 1, 5) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: string encoding regex problem

2014-08-15 Thread Steven D'Aprano
and replaced it with a different one? Did you update Python to a new version? Have you changed the regex search pattern? Has the text you are searching changed? Websites upgrade their HTML quite frequently. Perhaps the Boost website has changed enough to break your regex. -- Steven -- https://m

Re: redirect stderr to syslog?

2014-08-15 Thread Steven D'Aprano
difference to performance? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Unicode in cgi-script with apache2

2014-08-16 Thread Steven D'Aprano
First you need to find out why Python is trying to convert to ASCII. That's probably because of something Apache is doing. Do you have an Apache technician you can ask? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Unicode in cgi-script with apache2

2014-08-17 Thread Steven D'Aprano
ing="utf-8" ) That makes no sense. If you're reading in binary mode, there's no encoding. Every byte represents itself. > f = open( "/var/www/cgi-data/index.html", "r", encoding="utf-8" ) That's the bunny! If you just want to hide the prob

Re: Unicode in cgi-script with apache2

2014-08-17 Thread Steven D'Aprano
1') 'Hello World! é ü Ã\xa0 Å©' which appears to be exactly what you have. Why Latin-1 instead of ASCII? Because the process has to output *something*, and Latin-1 is sometimes called "extended ASCII". I'm starting to fear a bug in Python 3.4, but since I have almost no knowledge about wsgi and cgi, I can't be sure that this isn't just normal expected behaviour :-( -- Steven -- https://mail.python.org/mailman/listinfo/python-list

GIL detector

2014-08-17 Thread Steven D'Aprano
nd the GIL will just be an embarrassment, but today is not that day. I wonder whether Ruby programmers are as obsessive about Ruby's GIL? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: GIL detector

2014-08-17 Thread Steven D'Aprano
Johannes Bauer wrote: > On 17.08.2014 16:21, Steven D'Aprano wrote: >> Coincidentally after reading Armin Ronacher's criticism of the GIL in >> Python: >> >> http://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-to-see/ > > Sure that's the r

Re: Module-level functions and the module type

2014-08-17 Thread Steven D'Aprano
a local, but how about b and c? Are they globals or attributes of the instance? Python decided on giving globals (well, actually nonlocals) priority, and requiring an explicit self, so we can write this: def method(self): a = self.b + len(c) instead of this: def method(): locals.a = b + globals.len(globals.c) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

RE: GIL detector

2014-08-17 Thread Steven D'Aprano
ss for each core instead. Ironically, using threads for email in Python is probably going to work quite well, since it is limited by I/O and not CPU. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: User class binary ops seem too slow (was re: GIL detector)

2014-08-18 Thread Steven D'Aprano
OAD_CONST 2 (2) 3 POP_TOP 4 LOAD_CONST 1 (None) 7 RETURN_VALUE -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Why Python 4.0 won't be like Python 3.0

2014-08-18 Thread Steven D'Aprano
ion 4.0, when it comes out, will merely be a return to past practices in Python-land, which are quite similar to practices in many major software packages. Version 3.0 was the anomaly. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Matplotlib Contour Plots

2014-08-18 Thread Steven D'Aprano
ady arrays. a = np.array([hs_con_sw, te_con_sw]) ought to do what you want. That's a list [] of arrays, hence two-dimensional. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Adapt bash readline operate-and-get-next

2014-08-18 Thread Steven D'Aprano
ent. It's not very complicated. I wouldn't worry about Apple users for the time being. Let's see if we can get it accepted first. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Why Python 4.0 won't be like Python 3.0

2014-08-18 Thread Steven D'Aprano
ings an error. # 2.4 py> raise "hello" Traceback (most recent call last): File "", line 1, in ? hello # 2.6 py> raise "hello" Traceback (most recent call last): File "", line 1, in TypeError: exceptions must be old-style classes or derived fr

Re: Why Python 4.0 won't be like Python 3.0

2014-08-18 Thread Steven D'Aprano
s over tabs, because some tools can't deal with tabs correctly.) Rather than fix the tools, the Haskell community removed non-numeric tags from the specification. On the other hand, Oracle and Sun before them take the attitude that a jump in Java's version number from 5 to 6 to 7 are only minor release changes, and the Java community is quite happy to agree. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: 'is not' or '!='

2014-08-19 Thread Steven D'Aprano
s a surname since her marriage. Prior to her marriage, she used "Elizabeth Windsor" on those rare occasions that "Princess Elizabeth" or "Queen Elizabeth II" was not sufficient. Her children, should they need a surname, use Mountbatten-Windsor. Prince William

Re: Why Python 4.0 won't be like Python 3.0

2014-08-19 Thread Steven D'Aprano
uctant to install software by hand if it wasn't handled by my system's package manager. I still am, but not as reluctant as I was back then. (3) I was still learning the language, and all the books I had on Python covered 1.5. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: 'is not' or '!='

2014-08-19 Thread Steven D'Aprano
rt (X == Y or id(X) != id(Y)) Traceback (most recent call last): File "", line 1, in AssertionError This demonstrates that the condition (X == Y or id(X) != id(Y)) fails to tell us anything useful about identity, since it is sometimes true and sometimes false. You cannot understand identity from first principles, precisely because it is not a metaphysical concept in Python. In Python it is defined by and in terms of the concrete programming model of the language. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: 'is not' or '!='

2014-08-19 Thread Steven D'Aprano
doversion; guidoprint(guidoversion)-ly yr's, -- Steven -- https://mail.python.org/mailman/listinfo/python-list

<    79   80   81   82   83   84   85   86   87   88   >