Re: Easy "here documents" ??

2004-12-18 Thread Nick Coghlan
Jim Hill wrote: Is there a way to produce a very long multiline string of output with variables' values inserted without having to resort to this wacky """v = %s"""%(variable) business? Try combining Python 2.4's subprocess module with its string

Re: How about "pure virtual methods"?

2004-12-19 Thread Nick Coghlan
they only need a fraction of it. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: dot products

2004-12-19 Thread Nick Coghlan
ase in length, generator expressions generally win in the end due to their reduced memory impact. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- h

Re: newbie question

2004-12-19 Thread Nick Coghlan
ible to alter that determination though: Py> from decimal import Decimal Py> Decimal(1) == int(1) True Py> type(Decimal(1)) Py> type(int(1)) The reason your __abs__ example blows up is because the relevant attribute is missing for string objects - and the

Re: input record seperator (equivalent of "$|" of perl)

2004-12-20 Thread Nick Coghlan
ort reader Py> parsed = reader(demo, delimiter='|') Py> for line in parsed: print line ... ['a', 'b', 'c', 'd'] ['1', '2', '3', '4'] Cheers, Nick. P.S. 'demo' was created via: Py> from tempfi

Re: Web forum (made by python)

2004-12-20 Thread Nick Coghlan
et is to assume it's something in real life that's pissing them off, rather than anything I actually said. And that assumption usually turns out to be pretty close to the mark, and things return to being civil after a day or two. Cheers, Nick. P.S. I think this list may experience the

Re: Is this a good use for lambda

2004-12-21 Thread Nick Coghlan
on composition (although it has the same effect). From a real world programming point of view, though, it's self-documenting, runs faster and uses less memory, so it's really a pure win. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --

Re: A rational proposal

2004-12-21 Thread Nick Coghlan
a suitable intermediate format that makes explicit the degree of precision used in the conversion. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: List limits

2004-12-21 Thread Nick Coghlan
emory, and Python's internal structures are already chewing up some of the address space. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.n

Re: Should I always call PyErr_Clear() when an exception occurs?

2004-12-21 Thread Nick Coghlan
ed to remind you why you love coding in Python ;) Although coding in C when you have the Python API to lean on is a hell of a lot better than just coding in C. . . Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Bri

Re: Is this a good use for lambda

2004-12-21 Thread Nick Coghlan
Steven Bethard wrote: Nick Coghlan wrote: def compose(list_of_functions): application_order = reversed(list_of_functions) def composed(x): for f in application_order: x = f(x) return x return composed so you either need to call reversed each time in 'composed' o

Python, VB and COM

2004-12-21 Thread Nick Leaton
to do something like import win32Com.client pt = win32com.client.Dispatch ("Test.PyTest") pt.Name = "fred" print pt.Name However it doesn't look like the Test.dll is known. Any pointers? Thanks Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are tuples immutable?

2004-12-21 Thread Nick Coghlan
t(). Or, as I suggested elsewhere in this thread, use a special KeyedById class which *doesn't copy anything anywhere*. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Lazy argument evaluation (was Re: expression form of one-to-many dict?)

2004-12-21 Thread Nick Coghlan
, guarded_operation, lazyval(default_case)) Huh. I think I like the idea of lazy() much better than I like the current PEP 312. There must be something wrong with this idea that I'm missing. . . Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: What is on-topic for the python list [was "Re: BASIC vs Python"]

2004-12-21 Thread Nick Vargish
s appropriate for this group? Maybe you should try to lead by example, not decree. Nick -- # sigmask || 0.2 || 20030107 || public domain || feed this to a python print reduce(lambda x,y:x+chr(ord(y)-1),' Ojdl!Wbshjti!=obwAcboefstobudi/psh?') -- http://mail.python.org/mailman/listinfo/python-list

Re: What is on-topic for the python list [was "Re: BASIC vs Python"]

2004-12-21 Thread Nick Vargish
#x27;re working towards a career in the political field. Nick -- # sigmask || 0.2 || 20030107 || public domain || feed this to a python print reduce(lambda x,y:x+chr(ord(y)-1),' Ojdl!Wbshjti!=obwAcboefstobudi/psh?') -- http://mail.python.org/mailman/listinfo/python-list

Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-22 Thread Nick Coghlan
e of hash() for sorting into hash buckets and "x == y" for key matching. An identity_dict variant that uses id() (or object.__hash__ in Jython) and "x is y" would seem to quite happily meet the use cases you have posted in this th

Re: Lazy argument evaluation (was Re: expression form of one-to-many dict?)

2004-12-22 Thread Nick Coghlan
Nick Coghlan wrote: def lazycall(x, *args, **kwds): """Executes x(*args, **kwds)() when called""" return lambda : x(*args, **kwds)() It occurred to me that this should be: def lazycall(x, *args, **kwds): """Executes x()(*args, **kwds) when c

Re: Lazy argument evaluation (was Re: expression form of one-to-many dict?)

2004-12-22 Thread Nick Coghlan
not entirely sure about it myself, since I'm in a similar boat to you w.r.t. lazy evaluation (I usually just define functions that do what I want and pass them around). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia -

Re: A rational proposal

2004-12-22 Thread Nick Coghlan
est: float() + Decimal() fails with a TypeError float() + float(Decimal()) works fine And I believe Decimal's __float__ operation is a 'best effort' kind of thing, so I have no problem with Rationals working the same way. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED]

Re: input record sepArator (equivalent of "$|" of perl)

2004-12-22 Thread Nick Coghlan
John Machin wrote: Nick Coghlan wrote: [snip] delimeter. Hey, Terry, another varmint over here! Heh. Just don't get me started on the issues I have with typing apostrophes in the right spot. My *brain* knows where they go, but for some reason it refuses to let my fingers in on the s

Re: Is this a good use for lambda

2004-12-22 Thread Nick Coghlan
:) Although if you genuinely prefer a functional programming style, I'd go with Terry's answer rather than mine. (Incidentally, I didn't even know what the reduce trap *was* until Terry described it, but the iterative version avoids it automatically) Cheers, Nick. -- Nick

Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-22 Thread Nick Coghlan
in using sets to classify mutable objects like lists (such as Antoon's example of applying special processing to certain graph points). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-22 Thread Nick Coghlan
faster than the standard dict() and set(), since they don't have to deal with user-overridable special methods :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://bore

Re: A rational proposal

2004-12-22 Thread Nick Coghlan
playing well with other types have been considered properly. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie namespace question

2004-12-22 Thread Nick Coghlan
ver, if you would prefer not to alter jdbc.py, consider trying: import jdbc jdbc.AdminConfig = AdminConfig Global variables are bad karma to start with, and monkeying with __builtin__ is even worse :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia -

Re: list IndexError

2004-12-23 Thread Nick Coghlan
7;m not sure why the in-place version is getting faster (as it makes more method calls and performs more deletions). One possibility is that as the list gets shorter due to the deletions, the whole thing gets pulled into the processor's cache and the operations start going blazingly fast. Cheer

Re: list IndexError

2004-12-23 Thread Nick Coghlan
they demonstrate what they were meant to demonstrate - that there's a reason filtration is the recommended approach! Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: Lambda going out of fashion

2004-12-23 Thread Nick Coghlan
(*a, **k)) for x, a, k in func_list) Anyway, thats just some ideas if you're concerned about the plan to have lambda disappear in 3K. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: deriving from str

2004-12-23 Thread Nick Coghlan
han the new instance. The __new__ method *creates* the instance, and returns it. See here for the gory details of overriding immutable types: http://www.python.org/doc/newstyle.html Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-23 Thread Nick Coghlan
case, I don't think we now disagree on anything more substantial than what the __hash__ documentation in the Language Reference should be saying :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane,

Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-23 Thread Nick Coghlan
long-held assumptions. Those don't get changed overnight - it takes at least a couple of days :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skyst

Re: Lambda going out of fashion

2004-12-23 Thread Nick Coghlan
stands will disappear for the Python 2.x series. Python 3.0 will be a case of "OK, let's take the things we learned were good and keep them, and throw away the things we realised were bad" Undoubtedly, the two languages will co-exist for quite some time. Cheers, Nick. -- Nick C

Re: Newbie namespace question

2004-12-23 Thread Nick Coghlan
out circular imports. Any extra global configuration properties can be added by updating the 'setConfiguration' function. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: Lambda going out of fashion

2004-12-23 Thread Nick Coghlan
Alex Martelli wrote: Nick Coghlan <[EMAIL PROTECTED]> wrote: ... Perhaps something like: accepts_func( (def (a, b, c) to f(a) + o(b) - o(c)) ) Nice, except I think 'as' would be better than 'to'. 'as' should be a full keyword in 3.0 anyway (rather than a

Re: Lambda going out of fashion

2004-12-23 Thread Nick Coghlan
Nick Coghlan wrote: Indeed, lambda as it currently stands will disappear for the Python 2.x series. Will NOT disappear. I repeat, will NOT disappear. Cheers, Nick. Damn those missing negators. . . -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: hidding the "console" window + system global shortcut keys

2004-12-24 Thread Nick Coghlan
at, I have no idea :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Optional Static Typing

2004-12-24 Thread Nick Coghlan
compile time code optimisation through static type declarations. The write up is here: http://boredomandlaziness.skystorm.net/2004/12/type-checking-in-python.html Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: Features for a Python package manager?

2004-12-25 Thread Nick Coghlan
l it after gentoo's portage, with less features of course. > Would this be acceptable? I don't know enough about Portage to answer that question. I do know any package manager which made it into the standard distribution would need to work for at least the big three platforms (

Re: Lambda going out of fashion

2004-12-25 Thread Nick Coghlan
)) ['Test'] Py> list(x()) [] Your failing case with len(*args) was due to the iterator having already been consumed :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Clearing the screen

2004-12-25 Thread Nick Coghlan
quot;Py>'). I believe PYTHONSTARTUP is handled by CPython's main function before it gets to the interactive interpreter. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-25 Thread Nick Coghlan
lassify mutable objects, and then check for membership in those groups. You can use lists for this, but the lookup is slow. Conventional dictionaries and sets give a fast lookup, but require that the items in use be hashable. An identity dictionary (or set) solves the 'object classification&

Re: Complementary language?

2004-12-25 Thread Nick Coghlan
s well with the CPython interpreter as that, as you may have guessed from the name, is written in C and exports a direct C/API. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: list addition methods compared.

2004-12-26 Thread Nick Coghlan
t;only add items greater than zero", it is worth checking the timings for calling extend with a generator expression or list comprehension that filters out the values you don't want) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia -

Re: A Revised Rational Proposal

2004-12-26 Thread Nick Coghlan
good. Regards, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: A Revised Rational Proposal

2004-12-26 Thread Nick Coghlan
potential source of precision bugs: Py> bignum = 2 ** 62 Py> bignum 4611686018427387904L Py> bignum + 1.0 4.6116860184273879e+018 Py> float(bignum) != bignum + 1.0 False Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: methods of addition in Python

2004-12-26 Thread Nick Coghlan
or things to show up :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Python on Linux

2004-12-26 Thread Nick Coghlan
m packages but failed with dependence. I didn't try the rpm's. Just get the source tarball, configure, make, and make install. Although one might argue that make altinstall is a safer approach ;) (Any scripts using "/usr/bin/env python" would then continue to use Python 2.2) C

Re: A Revised Rational Proposal

2004-12-27 Thread Nick Coghlan
#x27; if the denominator is one, or ''(num / denom)'' if the denominator is not one. Is that acceptable? Sounds fine to me. On the str() front, I was wondering if Rational("x / y") should be an acceptable string inpu

Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-29 Thread Nick Coghlan
requirements. Providing these two data types seemed like a nice way to do an end run around the bulk of the 'potentially variable hash' key problem. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: objects as mutable dictionary keys

2004-12-29 Thread Nick Coghlan
work properly - the default hash is inherited from object anyway. This *is* a bug (since Guido called it such), but one not yet fixed as the obvious solution (removing object.__hash__) causes problems for Jython, and a non-obvious solution has not been identified. Cheers, Nick. -- Nick Co

Re: [Python-au] Processes and pipes; newbie alert

2004-12-29 Thread Nick Coghlan
only way I know of to get an actual Named Pipe is with CreateNamedPipe. The folks on the win32 SIG might be able to help you out with more specifics about the uses of named pipes. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Aust

Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-29 Thread Nick Coghlan
here you don't want to modify the class definitions for the objects being annotated or classified. I don't want the capability enough to pursue it, but Antoon seems reasonably motivated :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: objects as mutable dictionary keys

2004-12-29 Thread Nick Coghlan
Terry Reedy wrote: "Nick Coghlan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] This *is* a bug (since Guido called it such), but one not yet fixed as the obvious solution (removing object.__hash__) causes problems for Jython, and a non-obvious solution has not

Securing a future for anonymous functions in Python

2004-12-30 Thread Nick Coghlan
ooking for feedback on a def-based syntax that came up in a recent c.l.p discussion: http://boredomandlaziness.skystorm.net/2004/12/anonymous-functions-in-python.html Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane,

Computer text recognition (was. Re: Why tuples use parentheses ()'s instead of something else like <>'s?)

2004-12-30 Thread Nick Coghlan
Ed Leafe wrote: Exactly! Now can we clear anything else up for you? ;-) How about a computer program than can correctly count the number of letter E's in your signature? :) Cheers, Nick. I like the sig, if you hadn't guessed. . . -- Nick Coghlan | [EMAIL PROTECTED] |

Re: Tkinter vs wxPython

2004-12-30 Thread Nick Coghlan
s written with the 'other' toolkit track any changes you make to the theme used by your window manager. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.s

Re: Securing a future for anonymous functions in Python

2004-12-30 Thread Nick Coghlan
Paul Rubin wrote: Nick Coghlan <[EMAIL PROTECTED]> writes: Anyway, I'm looking for feedback on a def-based syntax that came up in a recent c.l.p discussion: Looks like just an even more contorted version of lambda. It doesn't fix lambda's main deficiency which is inab

Re: Securing a future for anonymous functions in Python

2004-12-30 Thread Nick Coghlan
Jp Calderone wrote: On Fri, 31 Dec 2004 00:00:31 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote: Paul Rubin wrote: Nick Coghlan <[EMAIL PROTECTED]> writes: Anyway, I'm looking for feedback on a def-based syntax that came up in a recent c.l.p discussion: Looks like just an ev

Re: Securing a future for anonymous functions in Python

2004-12-30 Thread Nick Coghlan
Batista, Facundo wrote: [Nick Coghlan] #- I just don't understand why people complain so much about #- the restriction to a #- single expression in lambdas, yet there is nary a peep about #- the same #- restriction for generator expressions and list comprehensions. What *I* don't under

Re: Securing a future for anonymous functions in Python

2004-12-30 Thread Nick Coghlan
something to think about. I forgot about that little trap. . . Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python

Re: Securing a future for anonymous functions in Python

2004-12-30 Thread Nick Coghlan
Carl Banks wrote: Nick Coghlan wrote: In much the same way that programmers often spend a lot of time optimizing parts of their program that will yield very minor dividends, while they could have spent that time working on other things that will pay off a lot, many of the wannabe language

Re: Securing a future for anonymous functions in Python

2004-12-30 Thread Nick Coghlan
x: ( for in if ) def expression_func(): return def generator(): for in if : yield expression_func() Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlazin

Re: what would you like to see in a 2nd edition Nutshell?

2004-12-30 Thread Nick Coghlan
Mariano Draghi wrote: I think that somehow Python's "J2EE" equivalent is already out there (sort of...), I think it's called PEAK. . . Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: what would you like to see in a 2nd edition Nutshell?

2004-12-30 Thread Nick Coghlan
(and providing references for additional information, including books if they're available) seems like the most reasonable alternative. Now, if we could just switch to wxPython and Boa Constructor for Py3K. . . Cheers, Nick. Sorry Kurt! -- Nick Coghlan | [EMAIL PROTECTED] |

Re: Is there a better way of listing Windows shares other than us ing "os.listdir"

2004-12-31 Thread Nick Coghlan
e a bit of work (given what a tangle of ifdef's the function is). The relevant file is dist/src/Modules/posixmodule.c and the relevant function is posix_listdir. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Python List Issue

2005-03-27 Thread Nick L
I had the same trouble. Until this point everything was going good, but this has really bugged me Any ideas, suggestions, comments are greatly appreciated thanks Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Python List Issue

2005-03-27 Thread Nick L
> See copy.deepcopy(). It will make sure that everything gets copied and > nothing just referenced (more or less). So far copy.deepcopy() seems to be working perfectly. Thanks for the input Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Python List Issue

2005-03-27 Thread Nick L
Thanks, thats a really handy function "Ron_Adam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sun, 27 Mar 2005 09:01:20 GMT, "Nick L" <[EMAIL PROTECTED]> > wrote: > > >I've hit a brick wall on something that I'm guess

Re: Question about the Python Cookbook: How much of this is new?

2005-04-06 Thread Nick Vargish
Robert Kern <[EMAIL PROTECTED]> writes: > So yeah, buy it. Seconded. My copy arrived from ORA yesterday and I'm still giddy with delight. Even if you have the first edition, the second includes a lot of recipes that leverage or demonstrate the new features in 2.3 and 2.4. Nick

Re: Thoughts on some stdlib modules

2005-04-08 Thread Nick Efford
ut it is far from being the mess you imply. My own personal bugbear is the issue of consistency. Java's standard library might be a huge and clumsy beast with more than its fair share of overloading and obsolescence, but it at least has the virtue of more consistently following conventions on

Re: Why Python does *SLICING* the way it does??

2005-04-20 Thread Nick Efford
string[2:4], you know instantly by looking at the slice indices that this contains 4-2 = 2 characters from the original string. If the last index were included in the slice, you'd have to remember to add 1 to get the number of characters in the sliced string. It all makes perfect sense whe

Re: How to Convert a makefile to Python Script

2005-04-20 Thread Nick Vargish
, but you get what I'm suggesting, right? To mangle a lwall quote, "The only substitute for make is make." Nick -- # sigmask (lambda deprecation version) 20041028 || feed this to a python print ''.join([chr(ord(x)-1) for x in 'Ojdl!Wbshjti!=ojdlAwbshjti/psh?']) -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-ideas] Unicode stdin/stdout

2013-11-18 Thread Nick Coghlan
= codecs.getwriter("utf-8")(sys.stdout.detach()) > sys.stdout.encoding = 'utf8' > sys.stderr = codecs.getwriter("utf-8")(sys.stderr.detach()) > sys.stderr.encoding = 'utf8' Note that calling detach() on the standa

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

2013-12-04 Thread Nick Mellor
lly. Here's an example: def spreadsheet(csv_filename): with open(csv_filename) as csv_file: for csv_row in list(csv.DictReader(csv_file, delimiter='\t')): yield csv_row then invoked using: for row in spreadsheet("...") # your processing code here Cheers, Nick -- https://mail.python.org/mailman/listinfo/python-list

RE: Does Python optimize low-power functions?

2013-12-06 Thread Nick Cash
>My question is, what do Python interpreters do with power operators where the >power is a small constant, like 2? Do they know to take the shortcut? Nope: Python 3.3.0 (default, Sep 25 2013, 19:28:08) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.

RE: cascading python executions only if return code is 0

2013-12-23 Thread Nick Cash
utions. Which is to say, not at all. -Nick Cash -- https://mail.python.org/mailman/listinfo/python-list

RE: the Gravity of Python 2

2014-01-09 Thread Nick Cash
> and "%s" (which is incredibly useful) is not even documented (I suspect it's > also not available on all platforms). The format specifiers available to Python are just whatever is available to the underlying c time.h. The manpage for strftime indicates that %s isn't part of the C standard, bu

RE: kivy

2014-02-04 Thread Nick Cash
ou narrow down where the problem lies. -Nick Cash -- https://mail.python.org/mailman/listinfo/python-list

Re: Administrators and moderators of Python-list, please erase all the messages that I not should have posted here in python-list!

2015-12-10 Thread Nick Sarbicki
p your past you will do more to damage any future relationships you will have with developers. - Nick. On Thu, Dec 10, 2015 at 2:55 PM françai s wrote: > Administrators and moderators of Python-list, please erase all the messages > that I not should have posted here in python-list. >

python 3.5.1 winsound bug

2016-01-08 Thread nick mcelwaine
Dear python team, On my 64bit windows10 the SND_ASYNC flag doesn’t cause the sound to play asynchronously. Nick McElwaine Sent from Mail for Windows 10 -- https://mail.python.org/mailman/listinfo/python-list

subscripting Python 3 dicts/getting the only value in a Python 3 dict

2016-01-12 Thread Nick Mellor
[0]] 1 >>> for k in d: ... value = d[k] ... break ... >>> value 1 >>> list(d.values())[0] 1 None of this feels like the "one, and preferably only one, obvious way to do it" we all strive for. Any other ideas? Thanks, Nick -- https://mail.python.org/mailman/listinfo/python-list

Re: python-2.7.3 vs python-3.2.3

2016-01-26 Thread Nick Sarbicki
one the same. But some systems will still be reliant on it. Then there is also this PEP: https://www.python.org/dev/peps/pep-0394/ - Nick. -- https://mail.python.org/mailman/listinfo/python-list

Re: A mistake which almost went me mad

2016-03-03 Thread Nick Sarbicki
On Thu, Mar 3, 2016 at 10:26 AM ast wrote: > Hello > > This has to be told > > I created a file pickle.py > You could stop there. The number of times I've had to correct a student for naming their script "turtle.py". And the number of times I've caught myself doing it... ...

[no subject]

2016-03-23 Thread Nick Eubank
Hello All, Found an odd behavior I'd never known about today, not sure if it's a bug or known. Python 3.4.4 (anaconda). True, False, 0, 1 can all be used as dictionary keys. But Apparently True and 1 hash to the same item and False and 0 hash to the same item, so they can easily overwrite (whic

Re: How to make Python interpreter a little more strict?

2016-03-26 Thread Nick Sarbicki
On Sat, Mar 26, 2016 at 9:59 AM Aleksander Alekseev wrote: > Hello > > Recently I spend half an hour looking for a bug in code like this: > > eax@fujitsu:~/temp$ cat ./t.py > #!/usr/bin/env python3 > > for x in range(0,5): > if x % 2 == 0: > next > print(str(x)) > > eax@fujitsu:~/

Re: optional types

2014-10-29 Thread Nick Cash
> Am I the only one who'd like to see optional types introduced in Python? Nope! Some dude named "Guido" would like to see them as well: https://mail.python.org/pipermail/python-ideas/2014-August/028742.html -- https://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] Python 2.x and 3.x use survey, 2014 edition

2014-12-13 Thread Nick Coghlan
ling to consider an update to the C extension porting guide to be more in line with Brett's latest version of the Python level porting guide? Regards, Nick. -- https://mail.python.org/mailman/listinfo/python-list

Generator using item[n-1] + item[n] memory

2014-02-14 Thread Nick Timkovich
belt-and-suspenders-and-duct-tape approach `data = None`, `del data`, and `gc.collect()` does nothing. I'm pretty sure the generator itself is not doubling up on memory because otherwise a single large value it yields would increase the peak usage, and in the *same iteration* a large object a

Re: Generator using item[n-1] + item[n] memory

2014-02-14 Thread Nick Timkovich
Ah, I think I was equating `yield` too closely with `return` in my head. Whereas `return` results in the destruction of the function's locals, `yield` I should have known keeps them around, a la C's `static` functions. Many thanks! -- https://mail.python.org/mailman/listinfo/python-list

Re: Generator using item[n-1] + item[n] memory

2014-02-14 Thread Nick Timkovich
Roy Smith wrote: > In article , > Nick Timkovich wrote: > > > Ah, I think I was equating `yield` too closely with `return` in my head. > > Whereas `return` results in the destruction of the function's locals, > > `yield` I should have known keeps them around, a la

Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Nick Timkovich
On Tue, Feb 25, 2014 at 2:32 PM, mauro wrote: > > So I wonder why operations such us intersection, union, difference, > symmetric difference that are available for sets and are not available > for dictionaries without going via key dictviews. How would the set operations apply to the dictionary v

Re: Tuples and immutability

2014-02-27 Thread Nick Timkovich
On Thu, Feb 27, 2014 at 10:33 AM, Chris Angelico wrote: > On Fri, Feb 28, 2014 at 3:27 AM, Eric Jacoboni > wrote: > > But, imho, it's far from being a intuitive result, to say the least. > > It's unintuitive, but it's a consequence of the way += is defined. If > you don't want assignment, don't

random.seed question (not reproducing same sequence)

2014-04-15 Thread Nick Mellor
ndom to the stockbin parameter, the test passes. Best wishes, Nick for qty in [4, 0]: random.seed(seed) for cart in range(test_size): for special in range(randrange(3)): s.addUpdate_special_to_cart(

Re: random.seed question (not reproducing same sequence)

2014-04-15 Thread Nick Mellor
ial_id=rnd.randrange(test_size), special_qty=qty, products=[(rnd.choice(PRODUCTS), rnd.choice(range(10))) for r in range(rnd.randrange(7))]) Cheers, Nick -- https://mail.python.

Re: Proposal: [... for ... while cond(x)]

2013-09-26 Thread Nick Mellor
xs: if not cond(x): break yield e(x) and for 'from': emit = False for x in xs: if not emit: if cond(x): emit = True else: yield e(x) Cheers, Nick -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposal: [... for ... while cond(x)]

2013-09-26 Thread Nick Mellor
On Friday, 27 September 2013 00:39:30 UTC+10, Nick Mellor wrote: [snip] > for x in xs: > if not emit: > if cond(x): > emit = True > else: > yield e(x) > Oops! for x in xs: if not emit: if cond(x): emit = True

RE: Code golf challenge: XKCD 936 passwords

2013-10-09 Thread Nick Cash
eeded! Although it's not as pretty as the original post, but neither was Roy's. -Nick Cash -- https://mail.python.org/mailman/listinfo/python-list

RE: chunking a long string?

2013-11-08 Thread Nick Cash
be added to itertools before, but rejected: https://mail.python.org/pipermail/python-ideas/2012-July/015671.html and http://bugs.python.org/issue13095 - Nick Cash -- https://mail.python.org/mailman/listinfo/python-list

RE: How to tell an HTTP client to limit parallel connections?

2013-11-08 Thread Nick Cash
tc. It's not the prettiest solution, but it could work. -Nick Cash -- https://mail.python.org/mailman/listinfo/python-list

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