Re: Where to handle try-except - close to the statement, or in outer loop?

2013-11-11 Thread Steven D'Aprano
end any good examples that show current best practices > for exception handling, for programs with moderate complexity? (i.e. > anything more than the examples in the tutorial, basically). Yes. Read the code in the Python standard library! Open your text editor, if possible set it to open files in read-only mode, and browse the standard library. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: 'isimmutable' and 'ImmutableNester'

2013-11-12 Thread Steven D'Aprano
So your function is subject to both false negatives and false positives. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: 'isimmutable' and 'ImmutableNester'

2013-11-12 Thread Steven D'Aprano
ython has existed, nobody who wanted it was willing to do the work to write it, and nobody willing to do the work thought it was important. I believe that if you wish this PEP to go anywhere, you need to concentrate on two things: 1) demonstrating that checking for immutability is *necessary* 2)

Re: To whoever hacked into my Database

2013-11-12 Thread Steven D'Aprano
least are also productive members of the community who contribute to discussing Python and helping solve Python problems. You don't, not as far as I can see. Since you are now in my opinion almost as big a problem here as Nikos, I'm adding you back to my kill-file. See you in six months. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Bullying [was Re: To whoever hacked into my Database]

2013-11-12 Thread Steven D'Aprano
is "bullying" anywhere here. Just because (generic) you are annoyed by Nikos, or even if your feelings are hurt because he called you a bad name or insulted your dead mother, doesn't mean you are the victim of bullying. Claiming the badge of victimhood for mild annoyances and hurt feelings is one of the least admirable parts of the politically-correct crowd, please don't emulate them. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Please help with this

2013-11-12 Thread Steven D'Aprano
nts: print("Welcome!") print() or you can manually add an extra newline to the string: print("Welcome!\n") Hope this helps, -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Steven D'Aprano
e "File exists" could possibly mean. Really Nikos, you're not a beginner at this. Your English is excellent. Between simple logic and Google, you ought to be able to work out what "File exists" means faster than writing a post and sending it here. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: change volume of single audio device

2013-11-13 Thread Steven D'Aprano
eed to look up the documentation for the Windows API used (I think it is mixerSetControlDetails) and see what return code 11 means. I don't even know if it's documented. Start by googling for "mixerSetControlDetails return value 11" and go on from there. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Steven D'Aprano
ou can start up the Python version of your choice, then do: py> import sys py> sys.executable '/usr/local/bin/python2.5' -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Steven D'Aprano
re Nikos if you like, answer his questions if you must, but please keep the abusive posts off- list. They aren't helping. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Steven D'Aprano
a newsgroup, and I believe that there is no moderator on that. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Steven D'Aprano
On Thu, 14 Nov 2013 10:47:35 +1000, alex23 wrote: > On 14/11/2013 9:48 AM, Steven D'Aprano wrote: >> I believe that whatever >> negative effect Nikos the help-vampire is having, it is long ago >> overwhelmed by the negative of the anti-Nikos vigilantes. > > I don&

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Steven D'Aprano
ther package's use of "spam" for a different purpose. But that's not the case here: alpha's "spam" is separate from module omega's "spam" variable. To give an analogy: just because I can walk through the door of number 23 Alpha Street and rummage through their fridge, and walk through the door of number 42 Omega Road and do the same, doesn't mean that the two fridges are actually the same fridge. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Using alpha software in production [was Re: Trying tcompile an use the Python 3.4a]

2013-11-13 Thread Steven D'Aprano
rsion; and finally (4) anything else, including > straight from Mercurial. The further down that list you go, the more > work you have to do yourself to ensure compatibility, dependency > management, etcetera. +1 -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: chroot to install packages

2013-11-13 Thread Steven D'Aprano
plicated usage, you should read the docs for the subprocess module. For quick and dirty uses, you can use: import sys sys.system('path/to_jail/inside.py "first arg" "second arg" "third arg"') but I recommend against that except for throw-away scripts. Corrections welcome! -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Steven D'Aprano
Marine Corps sergeants. > And i also want to point out the hypocrisy of Python's design. Python > DOES have globals Is that why it has a global keyword and a globals() function? Thanks for the information, I never would have worked that out without your keen insight. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Steven D'Aprano
On Wed, 13 Nov 2013 09:29:38 -0800, Ned Batchelder wrote: > I strongly recommend that you stay on Python 2, and focus on other > concerns. Nikos has been using Python 3.3 for his website for months now. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Steven D'Aprano
en times when I've been part of the problem > (usually in the form of trying to help Nikos, which results in > stupidity, which leads to anger,. which leads to hate, to suffering, and > to the dark side). Don't forget the cookies! https://i.chzbgr.com/maxW500/4488083200/h464994D9/ -

Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Steven D'Aprano
er of this community when you put your mind to it, but your prideful refusal to stop attacking Nikos is helping to wreck this community. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Steven D'Aprano
On Wed, 13 Nov 2013 19:45:42 -0800, Rick Johnson wrote: > On Wednesday, November 13, 2013 8:45:16 PM UTC-6, Steven D'Aprano wrote: >> A fully-auto machine gun with a hair-trigger and no >> safety is no different from a single-barrel shotgun with a safety and >> a t

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Steven D'Aprano
highly coupled code is harmful whether it occurs due to global variables or via RPC calls or some other mechanism. But the difference is you have to work at it to write such highly coupled code with RPC calls, while with single-process globals such coupling occurs naturally without effort.

Re: Automation

2013-11-14 Thread Steven D'Aprano
imagine that "ghoti" could legitimately be pronounced "fish"? "gh" sounds like F, as in "enough" (enuf) "o" sounds like I, as in "women" (wimmin) "ti" sounds like SH, as in "station" (stayshun) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Automation

2013-11-14 Thread Steven D'Aprano
then write a post which is better written, more clear, and far more articulate than the native English speakers :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: PyMyth: Global variables are evil... WRONG!

2013-11-15 Thread Steven D'Aprano
On Thu, 14 Nov 2013 09:26:18 -0800, Rick Johnson wrote: > On Wednesday, November 13, 2013 11:50:40 PM UTC-6, Steven D'Aprano > wrote: [...] >> of course, but that in general *its too damn hard* for human >> programmers to write good, reliable, maintainable, correct (i.e.

Re: Getting globals of the caller, not the defining module

2013-11-15 Thread Steven D'Aprano
vinced me that I don't, in fact, want what I thought I wanted. I'm still playing around with the code, but it's looking likely that auto- detecting the caller's globals is not really what I want. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: python 3.3 repr

2013-11-15 Thread Steven D'Aprano
position 2: unexpected end of data py> b.decode('utf-8') Traceback (most recent call last): File "", line 1, in UnicodeDecodeError: 'utf8' codec can't decode byte 0xa5 in position 0: invalid start byte No, UTF-8 is okay for writing to files, but it

Re: python 3.3 repr

2013-11-15 Thread Steven D'Aprano
f > runes. > > It comes with support for no encodings save utf-8 (natively) and utf-16 > (if you work at it). Is that really enough? Only if you never need to handle data created by other applications. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Oh look, another language (ceylon)

2013-11-16 Thread Steven D'Aprano
ed. (Why do people keep doing that when they design languages?) When the only tool you've used is a hammer, every tool you design ends up looking like a hammer. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question regarding 2 modules installed via 'pip'

2013-11-16 Thread Steven D'Aprano
On Sat, 16 Nov 2013 15:59:13 +0200, Νίκος wrote: > HELP ME How rude. You're not the centre of the universe and we're not your mother. *plonk* -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: inconsistency in converting from/to hex

2013-11-16 Thread Steven D'Aprano
e "it". Do you mean "convert bytes to bytes", "bytes to str", "str to bytes", or "str to str"? Besides, one *obvious* way is not the same as *only one* way. I agree that its a bit of a mess. But only a little bit, and it will be less messy by 3.5 when the codecs solution is re-introduced. Then the codecs.encode and decode functions will be the one obvious way. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Beginner

2013-11-16 Thread Steven D'Aprano
ur business is to IT and computing services, then the more likely it is that you can find ways to use Python to help you. But without knowing more, I can't say anything further. > I would recommend that you primarily code purely for pleasure And such a luxury it is, to h

When to use assert

2013-11-16 Thread Steven D'Aprano
horter than an explicit test followed by a raise. Assert is not a shortcut for lazy coders. * Don't use them for checking input arguments to public library functions (private ones are okay) since you don't control the caller and can't guarantee that it will never break the function's contract. * Don't use assert for any error which you expect to recover from. In other words, you've got no reason to catch an AssertionError exception in production code. * Don't use so many assertions that they obscure the code. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: When to use assert

2013-11-17 Thread Steven D'Aprano
On Sun, 17 Nov 2013 06:50:56 -0600, Tim Chase wrote: > On 2013-11-17 07:35, Steven D'Aprano wrote: >> py> x = 23 >> py> assert x > 0, "x is not zero or negative" > > This is the worst way to use an assertion: with a misleading message > ;-) D

Re: Fire Method by predefined string!

2013-11-17 Thread Steven D'Aprano
;bye", "double", "echo", "hello" and "help". (Help is predefined for you.) See also http://drunkenpython.org/dispatcher-pattern-safety.html for another use of command dispatch. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Oh look, another language (ceylon)

2013-11-18 Thread Steven D'Aprano
(like Haskell and, apparently, Ceylon); * or UTF-16 without support for the supplementary planes (which makes it virtually UCS-2), like Javascript; * choose UTF-32, and use two or four times as much memory as needed. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Oh look, another language (ceylon)

2013-11-18 Thread Steven D'Aprano
On Mon, 18 Nov 2013 13:31:33 +, Steven D'Aprano wrote: > On Mon, 18 Nov 2013 21:04:41 +1100, Chris Angelico wrote: > >> On Mon, Nov 18, 2013 at 8:44 PM, wrote: >>> string >>> Satisfied Interfaces: Category, Cloneable>, >>> Collection, Com

Re: Setting longer default decimal precision

2013-11-18 Thread Steven D'Aprano
, but in 3.3 they got a major speed increase and are now nearly as fast as floats. An example: py> import decimal py> x = decimal.Decimal(1)/3 py> decimal.getcontext().prec = 50 py> y = decimal.Decimal(1)/3 py> print(x, y) 0. 0.3333

Re: Oh look, another language (ceylon)

2013-11-18 Thread Steven D'Aprano
about early binding and late binding of default arguments: def my_function(a=[early, binding, happens, once], b=>[late, binding, happens, every, time] ): ... Want! These two features alone may force me to give Ceylon a try. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Why do only callable objects get a __name__?

2013-11-18 Thread Steven D'Aprano
o concepts of names. The first SomeTuple, on the left of the equals sign, is the variable name. The second, inside the parentheses, is the class name. They need not be the same. > 2. If I created a superclass of namedtuple which exposed > type(namedtuple).__name__ in the namespace

Re: Why do only callable objects get a __name__?

2013-11-18 Thread Steven D'Aprano
ly, with a little helper function to handle the tedious bits: def state(name, x, y): class Inner(object): pass Inner.x = x Inner.y = y Inner.__name__ = Inner.name = name return Inner And in use: py> state1 = state('state1', 100, 101) py> state1 py

Re: Oh look, another language (ceylon)

2013-11-18 Thread Steven D'Aprano
code string, SMP and BMP, it is a major disappointment that Ceylon doesn't. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Oh look, another language (ceylon)

2013-11-18 Thread Steven D'Aprano
gt; 32k. Yep, I screwed up. Thanks for the correction. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Oh look, another language (ceylon)

2013-11-18 Thread Steven D'Aprano
unt your nightmares! You're easily terrified if you have nightmares about that. I can't imagine what you would do if faced with the M-combinator applied to itself. > But even the previous example, whilst quite logical, is violating the > "contract of transformations" What contract of transformations? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Why do only callable objects get a __name__?

2013-11-18 Thread Steven D'Aprano
} and one or two other things automatically inserted for you. A factory function, being just a function, can't take advantage of any magic syntax. While you can put anything you like inside the function, the function can't see what's on the left hand side of the assignment to retrieve

Re: Automation

2013-11-18 Thread Steven D'Aprano
*wack* "Will you speak proper now or wot?" -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie - Trying to Help a Friend

2013-11-19 Thread Steven D'Aprano
f you prefer: count += 1 Either way adds one to count. I expect that the above should be enough to get your friend started and possibly even finished. If she/he gets stuck, come back with some code and specific questions. Good luck! -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Using try-catch to handle multiple possible file types?

2013-11-19 Thread Steven D'Aprano
ip compressed data, was "blah.txt", from Unix, last modified: Wed Nov > 20 10:48:35 2013 > > I suppose it's enough to just do a? > > if "gzip compressed data" in results: > > or is there a better way? *shrug* Read the docs of python-magic. Do they offer a programmable API? If not, that kinda sucks. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python classes for reading/writing/parsing MIDI files

2013-11-19 Thread Steven D'Aprano
ying to someone else's >> post? All we have is a subject line. > > They appear to be resurrecting a 12 year old thread. Wow, that's one slow News server. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie - Trying to Help a Friend

2013-11-19 Thread Steven D'Aprano
On Tue, 19 Nov 2013 22:10:55 -0500, Dave Angel wrote: > On 20 Nov 2013 00:17:23 GMT, Steven D'Aprano > wrote: >> problem by hand. I'll get you started by solving the problem for 7. > > > > >> Positive integers less than 23 are 1, 2, 3, 4, 5, 6. So l

Re: Getting RuntimeError: invalid slot offset when importing a module

2013-11-20 Thread Steven D'Aprano
the _ssl module fails to compile correctly, the ssl module can't work. You're going to need to check the compilation error and see what it says. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Setting longer default decimal precision

2013-11-20 Thread Steven D'Aprano
ecision trig functions. If you study the decimal.py module, you could possibly work out how to add support for trig functions, but they have no current support for them. You could try this third-party module: http://code.google.com/p/mpmath/‎ which claims to be arbitrary-precision maths for Pyth

Off-topic: Pop culture references [was Re: Newbie - Trying to Help a Friend]

2013-11-20 Thread Steven D'Aprano
x27;m > dealing with an arsehole from the Python Software Foundation or one > who's not. This, however, is very rarely an appropriate response for anyone over the age of two. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Off-topic: Aussie place names [was Re: Automation]

2013-11-20 Thread Steven D'Aprano
placenames named after Australian Aboriginal words, see wikipedia: http://en.wikipedia.org/wiki/List_of_Australian_place_names_of_Aboriginal_origin -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: zip list, variables

2013-11-20 Thread Steven D'Aprano
o handle this or will list > comprehension > >>> [ [ x + y for x, y in zip(x,y) ] for x, y in zip(a,b) ] > Be sufficient ? Be sufficient for what? You've deleted all context from your post, so I have no clue what you're talking about. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Having trouble setting up an extremely simple server...

2013-11-21 Thread Steven D'Aprano
rong... er, I use other, um, programming languages, um, from time to time, um, and I'd, er, rather, um, just always, um, use semicolons, um, as with, er, the parentheses, um." Pretty horrible. The sentences are still grammatically correct. But that doesn't mean it's a good

Method chaining

2013-11-22 Thread Steven D'Aprano
here for further discussion of the limitations: http://code.activestate.com/recipes/578770-method-chaining/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-22 Thread Steven D'Aprano
"count the number of 1s" (do you mean the byte with value 1, or the ASCII code for 1, or the bit 1?), then count them. > Could you PLEASE provide me with the codes (codes only for the asked > queries) ? If you explain your question in more detail, we can give more detailed answers. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Help me to print to screen as well as log

2013-11-22 Thread Steven D'Aprano
t, please explain in more detail what you are trying to do, what you have already tried, and what happened when you tried it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Method chaining

2013-11-22 Thread Steven D'Aprano
to the adaptor signals that everything that follows is called only for the side-effects. obj = chained(MyClass()).spam().eggs().cheese() -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Method chaining

2013-11-22 Thread Steven D'Aprano
On Fri, 22 Nov 2013 07:34:53 -0500, Terry Reedy wrote: > On 11/22/2013 6:26 AM, Steven D'Aprano wrote: >> A frequently missed feature is the ability to chain method calls: >> >> x = [] >> x.append(1).append(2).append(3).reverse().append(4) => x now equals [3

Re: Method chaining

2013-11-22 Thread Steven D'Aprano
On Fri, 22 Nov 2013 16:20:03 +0100, Peter Otten wrote: > Steven D'Aprano wrote: > >> On Fri, 22 Nov 2013 13:08:03 +0100, Peter Otten wrote: >> >>> These things are nice to write as long as you omit the gory details, >>> but personally I don't w

Re: python for everyday tasks

2013-11-22 Thread Steven D'Aprano
rators and generator expressions. * Coroutines: http://dabeaz.com/coroutines/ Some of these things (e.g. coroutines, metaclasses) can be extremely advanced, and perhaps you only want to mention them in passing just to give a flavour for what you can do with Python. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-22 Thread Steven D'Aprano
rice, barley and others, You would have to say something like "give me a grain of pease" if you only wanted one. Eventually, people began to assume that "pease", or "peas", was the plural and therefore "pea" must be the singular. I look forward to the day that "rice" is the plural of "ri" :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: select.select()

2013-11-22 Thread Steven D'Aprano
;t request any of those to be opened. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Behavior of staticmethod in Python 3

2013-11-23 Thread Steven D'Aprano
+ 1 x = helper(10) y = helper(20) def method(self, arg): return self.helper(arg) This should now work exactly as you hope. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Steven D'Aprano
On Sat, 23 Nov 2013 15:06:42 -0800, Rick Johnson wrote: > On Friday, November 22, 2013 8:18:03 PM UTC-6, Steven D'Aprano wrote: >> As this is an international forum, it behoves us all to make allowances >> for slight difference in dialect. > > I don't thank s

Re: Implement logic on object.attribute and object.attribute()

2013-11-24 Thread Steven D'Aprano
T request. return "Get stuff" def do_put(self): # Do a HTTP PUT request. return "Put stuff" Possible or not, it doesn't seem like a reasonable API to me. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Importing by file name

2013-11-24 Thread Steven D'Aprano
ulean job. If I remember correctly, it uncovered a number of undetected bugs and dark corners with unspecified behaviour. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Behavior of staticmethod in Python 3

2013-11-24 Thread Steven D'Aprano
.* Making staticmethod instances callable is a feature enhancement, not a bug fix. Or you could just define your own callable- staticmethod descriptor, it's easy enough to do. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Method chaining

2013-11-24 Thread Steven D'Aprano
On Sat, 23 Nov 2013 19:53:32 +, Rotwang wrote: > On 22/11/2013 11:26, Steven D'Aprano wrote: >> A frequently missed feature is the ability to chain method calls: [...] >> chained([]).append(1).append(2).append(3).reverse().append(4) => >> returns [3, 2, 1, 4] >

Re: sys.stdout and Python3

2013-11-24 Thread Steven D'Aprano
partial output. I don't think the REPL handles return values inside loops any different from how it handles them outside loops. The difference is that file.write methods used to return None in Python 2, in Python 3 they return the number of bytes written. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Implement logic on object.attribute and object.attribute()

2013-11-24 Thread Steven D'Aprano
quot;) > time.sleep(1) > return "Put stuff" > > (PUT or POST, makes no difference; I think you were looking for POST, > but Steven wrote PUT here so I'll use that for simplicity) Oops, did I screw that bit up? Sorry. One possible solution here is to ca

Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Steven D'Aprano
sign of someone who wears his underpants on his head." -- (Terry Pratchett, Maskerade) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Cracking hashes with Python

2013-11-25 Thread Steven D'Aprano
u have to write your own program, start here: https://duckduckgo.com/?q=python+how+to+download+data+from+the+web -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Excute script only from another file

2013-11-25 Thread Steven D'Aprano
ermissions and ACLs to prevent Python from reading the file, rather than delete it, but given the possibility of privilege-escalation security vulnerabilities, even that's not sure-fire. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python String Formatting - passing both a dict and string to .format()

2013-11-26 Thread Steven D'Aprano
0}, {1} etc.) I'd do it like this: py> mydict = {'cat': 42, 'dog': 23, 'parrot': 99} py> '{cat} and {dog}, {}'.format('aardvark', **mydict) '42 and 23, aardvark' -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Completely and utterly Off Topic [was Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !]

2013-11-26 Thread Steven D'Aprano
that "doubt" and "question" are synonyms. http://thesaurus.com/browse/doubt Of course, if you have any doubts about this, feel free to ask, we're happy to answer all reasonable questions. [...] > "A new home-run record!" What is this "home-run" of which you speak? Houses don't generally run. Surely you're not using a regional idiom outside of your region? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Still off topic. Deal with it. [was Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !]

2013-11-26 Thread Steven D'Aprano
ife or even the lives of innocent > motorist/by-standards, or Of course, because being introduced to regional idiomatic phrases KILLS!!! -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-27 Thread Steven D'Aprano
mplete. *Not* being Turing complete is normally a bad thing, at least for a full- blown programming language. On the other hand, a less powerful non-Turing complete language would probably be great for things like user-defined macros, plugins, and similar, where the users are not entirely trusted. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: '_[1]' in .co_names using builtin compile() in Python 2.6

2013-11-27 Thread Steven D'Aprano
en you execute the compiled code, don't do this: eval(code) # No! Instead, provide an explicit globals and locals namespace: safe_ish_namespace = {'__builtins__': None} eval(code, safe_ish_namespace) Again, this increases the barrier to somebody hacking out of your sandbox without ruling it out altogether. Good luck! -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python and PEP8 - Recommendations on breaking up long lines?

2013-11-27 Thread Steven D'Aprano
12 LOAD_CONST 2 (23) 15 STORE_MAP 16 LOAD_CONST 3 (42) 19 LOAD_CONST 4 ('b') 22 STORE_MAP 23 POP_TOP 24 LOAD_CONST 0 (1) 27 STORE_NAME 1 (y) 30 LOAD_CONST 5 (None) 33 RETURN_VALUE -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python and PEP8 - Recommendations on breaking up long lines?

2013-11-27 Thread Steven D'Aprano
) is a better idea > with multi-line comments, right? *shrug* That's a matter of personal preference. > However, I've noticed that I can't seem to put in line-breaks inside the > comment without triggering a warning. For example, trying to put in > another empty line

Re: Python and PEP8 - Recommendations on breaking up long lines?

2013-11-27 Thread Steven D'Aprano
as" clauses if you like.) That's really clever! Why didn't I think of that? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python and PEP8 - Recommendations on breaking up long lines?

2013-11-27 Thread Steven D'Aprano
On Thu, 28 Nov 2013 03:57:03 +, Steven D'Aprano wrote: > if True: # add indentation, just for the example's sake. > if True: > if True: > with (open(self.full_path, 'r') as input, > op

Re: For-each behavior while modifying a collection

2013-11-28 Thread Steven D'Aprano
in fact it actually inserts extra items in the middle of the sequence. (There is no law that says that methods must do what they say they do.) You are expecting Python to know more about your program than you do. That is not the case. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: how to implement a queue-like container with sort function

2013-11-28 Thread Steven D'Aprano
iest way to do that is with a deque, which is a double-ended queue. The threading Queue class is based on a deque, so this will be at least as fast: py> from collections import deque py> my_queue = deque([], 5) # maximum of five items py> my_queue.append(7) py> my_queue.append(3) py&

Re: Cannot print greek letters in Python 2.6

2013-11-28 Thread Steven D'Aprano
rd() data = win32clipboard.GetClipboardData() win32clipboard.CloseClipboard() data = data.decode('UTF-16BE') -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Python Unicode handling wins again -- mostly

2013-11-29 Thread Steven D'Aprano
acters"). Python 3.3 is now halfway there, having excellent support for code-points across the entire Unicode character set, not just the BMP. The next step is to provide either a data type, or a library, for working on grapheme clusters. The Unicode Consortium provides a detailed discussion of this issue here: http://www.unicode.org/reports/tr29/ If anyone is looking for a meaty project to work on, providing support for grapheme clusters could be it. And if not, hopefully you've learned something about Unicode and the limitations of Python's Unicode support. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Unicode handling wins again -- mostly

2013-11-29 Thread Steven D'Aprano
On Fri, 29 Nov 2013 21:08:49 -0500, Roy Smith wrote: > In article <[email protected]>, > Steven D'Aprano wrote: > >> (8) What's the uppercase of "baffle" spelled with an ffl ligature? >> >> Like most

Re: Python Unicode handling wins again -- mostly

2013-11-29 Thread Steven D'Aprano
s of multiply incompatible character sets. It cannot hope to replace them if it cannot represent every distinct character they represent.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Unicode handling wins again -- mostly

2013-11-29 Thread Steven D'Aprano
o glyph for the ligature, and rather than display a MISSING CHAR glyph (usually one of those empty boxes you sometimes see), it normalized it to ASCII. But if it's that clever, why the hell doesn't it set an encoding line in posts? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Unicode handling wins again -- mostly

2013-11-29 Thread Steven D'Aprano
ne manufacturers, TV stations, map makers and similar. So there's a large number of symbols and emoji (emoticons) specifically added for them, presumably because they pay big dollars to the Unicode Consortium and therefore get a lot of influence in what gets added. -- Steven -- ht

Re: Python Unicode handling wins again -- mostly

2013-11-30 Thread Steven D'Aprano
is not included in Unicode is the Apple logo from Mac charsets. [2] The actual glyphs depends on the typeface used. [3] Again, modulo the typeface you're using to view them. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Change a file type in Python?

2013-11-30 Thread Steven D'Aprano
't difficult to throw away the file object and create a new one. That part is cheap. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Unicode handling wins again -- mostly

2013-11-30 Thread Steven D'Aprano
On Sat, 30 Nov 2013 18:52:48 -0600, Tim Chase wrote: > On 2013-12-01 00:22, Steven D'Aprano wrote: >> * KELVIN SIGN versus LATIN CAPITAL LETTER A > > I should hope so ;-) I blame my keyboard, where letters A and K are practically right next to each other, only seven le

Re: Change a file type in Python?

2013-12-01 Thread Steven D'Aprano
not. What's with that? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Extending the 'function' built-in class

2013-12-01 Thread Steven D'Aprano
It's even simpler if it doesn't need to be a method: spam.function = lambda n: "spam got %d as arg" % n) Want more complex behaviour? Write a callable class: class MyCallable(object): def __call__(self, arg): pass func = MyCallable() There are plenty of ways to

Re: Python Unicode handling wins again -- mostly

2013-12-02 Thread Steven D'Aprano
On Mon, 02 Dec 2013 16:14:13 -0500, Ned Batchelder wrote: > On 12/2/13 3:38 PM, Ethan Furman wrote: >> On 11/29/2013 04:44 PM, Steven D'Aprano wrote: >>> >>> Out of the nine tests, Python 3.3 passes six, with three tests being >>> failures or dubious. I

Re: Code of Conduct, Trolls, and Thankless Jobs [was Re: Python Unicode handling wins again -- mostly]

2013-12-02 Thread Steven D'Aprano
ink given that an awful lot of people think that "extended ASCII" is a thing and that you ought to be able to deal with it just like ASCII. > Evertime I start to read anything about Unicode with any > technical detail at all, I start to get dizzy and bleed from the ears. Heh,

Re: [OT] Managing Google Groups headaches

2013-12-02 Thread Steven D'Aprano
le, on the other hand, can and will take away software that you use. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

<    49   50   51   52   53   54   55   56   57   58   >