Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Paul Rubin
Steven D'Aprano writes: > If the Python community rallies around this "record" functionality and > takes to it like they took too namedtuple I like namedtuple and I think that it's a feature that they're modified by making a new copy. I know that has overhead but it's palpably bug-avoidant. I'v

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Lawrence D’Oliveiro
On Sunday, August 14, 2016 at 4:21:16 PM UTC+12, Chris Angelico wrote: > You have a working class factory, which is downright *impossible* in > many languages. If good old, plain old C can do this: /*prints itself*/void main(void){int c=34;char*s="/*prints itself*/void main(void){int c=34;ch

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Chris Angelico
On Sun, Aug 14, 2016 at 2:20 PM, Chris Angelico wrote: > You have a working class factory, which is downright *impossible* in > many languages. (Unless you count "metaprogramming" to include "programs that write other programs", of course. That is a legit form of metaprogramming, in a sense, and

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Chris Angelico
On Sun, Aug 14, 2016 at 2:13 PM, Steven D'Aprano wrote: > What you should be doing is comparing the types of record *instances* > instead: > > py> x = record('Spam', 'breakfast lunch dinner')('spam', > ... 'spam and eggs', 'spam and eggs and spam with a side-dish of spam') > py> y = record('Da

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Steven D'Aprano
On Sun, 14 Aug 2016 06:59 am, BartC wrote: > On 13/08/2016 17:06, Steven D'Aprano wrote: >> On Sat, 13 Aug 2016 08:09 pm, BartC wrote: > >>> record date=# define the record >>> var day, month, year >>> end >>> >>> d := date(25,12,2015) # create an instance > >> Sure. Bu

How do I tell if I'm running on a PowerPC?

2016-08-13 Thread Steven D'Aprano
I need to be able to programmatically test whether I'm running on a PowerPC. How can I do that? import platform if platform.machine() in ('ppc', 'ppc64'): print('running PowerPC') Is that right? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, thi

Re: Anyone here running Python on a PowerPC?

2016-08-13 Thread Lawrence D’Oliveiro
On Sunday, August 14, 2016 at 3:11:56 PM UTC+12, Michael Torrie wrote: > I also suggested QEMU, but I'm not sure it's 64-bit PPC, and I'm pretty > sure PowerMacs wouldn't be 64-bit either. Though I see some references > to PPC64 and QEMU in google searches. A little table here

Re: Multi-Line Strings: A Modest Proposal

2016-08-13 Thread Lawrence D’Oliveiro
On Sunday, August 14, 2016 at 1:53:42 PM UTC+12, John Wong wrote: > s = ("this string continues " + >"substring continues") Now there’s a Java way of doing it. :) I prefer implicit string concatenation myself. Isn’t it peculiar that, while this feature was introduced in C and faithfully

Re: Multi-Line Strings: A Modest Proposal

2016-08-13 Thread Steven D'Aprano
On Sun, 14 Aug 2016 11:53 am, John Wong wrote: > The way I solve it, and I still find that extremely ugly, is > > s = ("this string continues " + >"substring continues") You don't need the plus sign, as Python will concatenate string literals (not variables) at compile time: "foo" 'bar'

Re: Anyone here running Python on a PowerPC?

2016-08-13 Thread Michael Torrie
On 08/13/2016 08:35 PM, Paul Rubin wrote: > Steven D'Aprano writes: >> Is there anyone here running Python on a PowerPC willing to help me >> diagnose and fix this issue? http://bugs.python.org/issue27761 > > https://duckduckgo.com/?q=powerpc+emulator > > gets a few hits, one on sourceforge and

Re: Anyone here running Python on a PowerPC?

2016-08-13 Thread Michael Torrie
On 08/13/2016 08:35 PM, Paul Rubin wrote: > Steven D'Aprano writes: >> Is there anyone here running Python on a PowerPC willing to help me >> diagnose and fix this issue? http://bugs.python.org/issue27761 > > https://duckduckgo.com/?q=powerpc+emulator > > gets a few hits, one on sourceforge and

Re: Anyone here running Python on a PowerPC?

2016-08-13 Thread Paul Rubin
Steven D'Aprano writes: > Is there anyone here running Python on a PowerPC willing to help me > diagnose and fix this issue? http://bugs.python.org/issue27761 https://duckduckgo.com/?q=powerpc+emulator gets a few hits, one on sourceforge and one in QEMU. I don't know if those would exhibit the

Anyone here running Python on a PowerPC?

2016-08-13 Thread Steven D'Aprano
Is there anyone here running Python on a PowerPC willing to help me diagnose and fix this issue? http://bugs.python.org/issue27761 -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-

Re: Multi-Line Strings: A Modest Proposal

2016-08-13 Thread John Wong
On Sat, Aug 13, 2016 at 8:38 PM, Lawrence D’Oliveiro wrote: > Python allows a single string literal to cross multiple lines, provided it > begins and ends with three quote characters, e.g. > > s = """this string continues > on the next line.""" > > There is a drawback with this: any white

Re: Win32 API in pywin32

2016-08-13 Thread Michael Torrie
On 08/13/2016 06:22 PM, Lawrence D’Oliveiro wrote: > On Saturday, August 13, 2016 at 10:49:11 PM UTC+12, eryk sun wrote: >> You can call GetFileSizeEx [1]. Or call GetFileInformationByHandleEx >> [2] to get the FileStandardInfo. These APIs use the LARGE_INTEGER >> union type, which has a long long

Re: Win32 API in pywin32

2016-08-13 Thread Michael Torrie
On 08/13/2016 06:22 PM, Lawrence D’Oliveiro wrote: > On Saturday, August 13, 2016 at 10:49:11 PM UTC+12, eryk sun wrote: >> You can call GetFileSizeEx [1]. Or call GetFileInformationByHandleEx >> [2] to get the FileStandardInfo. These APIs use the LARGE_INTEGER >> union type, which has a long long

Re: Asynchronous programming

2016-08-13 Thread Ethan Furman
On 08/11/2016 10:47 PM, Paul Rudin wrote: Steven D'Aprano writes: [...] In this case, all the work is pure computation, so I don't expect to save any time by doing this, because the work is still all being done in the same process/thread, not in parallel. It may even take a little bit longer,

Re: Multi-Line Strings: A Modest Proposal

2016-08-13 Thread Ben Finney
Lawrence D’Oliveiro writes: > So really, you should write it more like > > s = """this string continues > on the next line.""" > > which gets a bit ugly. For this I have the following treatment http://stackoverflow.com/a/2504454/70157>: import textwrap s = textwrap.dedent("""\

Re: Asynchronous programming

2016-08-13 Thread Lawrence D’Oliveiro
On Saturday, August 13, 2016 at 8:26:05 PM UTC+12, Marko Rauhamaa wrote: > ... (unless Python takes Linux's AIO API into use, which > would be groundbreaking). Last I looked, asynchronous I/O on Linux was still a work in progress. The whole POSIX API has been grounded in the assumption that all

Re: Creating dictionary of items from Excel with mutliple keys

2016-08-13 Thread Lawrence D’Oliveiro
On Sunday, August 14, 2016 at 6:43:54 AM UTC+12, Michael Selik wrote: > Rather than using xlrd or other tools to read from excel, can you save the > file as CSV (comma-separated values)? I think you'll find Python's csv > module is very pleasant to use. Trying to use Python as a substitute for VBA

Multi-Line Strings: A Modest Proposal

2016-08-13 Thread Lawrence D’Oliveiro
Python allows a single string literal to cross multiple lines, provided it begins and ends with three quote characters, e.g. s = """this string continues on the next line.""" There is a drawback with this: any whitespace at the start of the continuation line is included as part of the s

Re: Win32 API in pywin32

2016-08-13 Thread Lawrence D’Oliveiro
On Saturday, August 13, 2016 at 10:49:11 PM UTC+12, eryk sun wrote: > You can call GetFileSizeEx [1]. Or call GetFileInformationByHandleEx > [2] to get the FileStandardInfo. These APIs use the LARGE_INTEGER > union type, which has a long long "QuadPart" member. > ... > FILETIME is a legacy of the W

Re: Why my image cannot be displayed?

2016-08-13 Thread huey . y . jiang
On Friday, August 12, 2016 at 9:40:15 PM UTC-4, huey.y...@gmail.com wrote: > Hi All, > > Image display drives me crazy. After I get it displayed, and want to do the > job with a class, display failed again. Please take a look at my trial code: > > from Tkinter import * > > class imageDisplay: >

Re: A strange list concatenation result

2016-08-13 Thread Mok-Kong Shen
Am 13.08.2016 um 03:08 schrieb Steven D'Aprano: On Sat, 13 Aug 2016 06:44 am, Mok-Kong Shen wrote: list2 = [1,2,3] list1 += [4,5,6] print(list1, list2) [1, 2, 3, 4, 5, 6] [1, 2, 3] Does that help? I don't yet understand why in my 2nd example list2 came out as [1, 2, 3] outside. Because y

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread BartC
On 13/08/2016 17:06, Steven D'Aprano wrote: On Sat, 13 Aug 2016 08:09 pm, BartC wrote: record date=# define the record var day, month, year end d := date(25,12,2015) # create an instance Sure. But you've put most of the work into the compiler. Into the language

Re: Asynchronous programming

2016-08-13 Thread Ethan Furman
On 08/11/2016 07:14 AM, Steven D'Aprano wrote: On Thu, 11 Aug 2016 03:06 pm, Paul Rubin wrote: The basic characteristic of asynchronous programming is that it involves changing all your usual blocking i/o calls to non-blocking ones, so your program can keep running as soon as your request is st

Looking for info on how Python developers negotiate breaking changes in PyPI packages

2016-08-13 Thread Chris Bogart
Hi, I'm looking for some help from Python developers who write PyPI packages (or open source software that depends on PyPI packages). My research group is interested in the impacts of different choices package managers make when designing their ecosystems -- e.g. Python/PyPi, Hackage and R/CRAN. We

Re: How to add data in xlm file ?

2016-08-13 Thread Karim
On 13/08/2016 11:05, Asad ur Rehman wrote: def Test(request): save_path = '/usr/share/newfies/' name_of_file = ("Avatar") completeName = os.path.join(save_path, name_of_file+".xlm") file1 = open(completeName, "w") toFile = raw_input("Write what you want into the fi

Re: Creating dictionary of items from Excel with mutliple keys

2016-08-13 Thread Michael Selik
On Sat, Aug 13, 2016 at 12:46 PM Atri Mahapatra wrote: > I am trying to create a following dictionary. I am reading data from excel > Rather than using xlrd or other tools to read from excel, can you save the file as CSV (comma-separated values)? I think you'll find Python's csv module is very p

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Christian Gollwitzer
Am 12.08.16 um 11:58 schrieb BartC: On 12/08/2016 10:45, Chris Angelico wrote: On Fri, Aug 12, 2016 at 7:38 PM, BartC wrote: You can be too dynamic. Take an example like this: d.yaer=1999 print (d.day,d.month,d.year) This would never get past a static language nor some that also have

Re: Python Indentation

2016-08-13 Thread Cai Gengyang
Yay ! On Sunday, August 14, 2016 at 1:40:09 AM UTC+8, Chris Angelico wrote: > On Sun, Aug 14, 2016 at 3:06 AM, Cai Gengyang wrote: > > Oh ok, so for the first block , it works because the indentation is the > > same for all 3 "print" statements , i.e. the indentation is 4 spaces for > > each of

Re: Python Indentation

2016-08-13 Thread Chris Angelico
On Sun, Aug 14, 2016 at 3:06 AM, Cai Gengyang wrote: > Oh ok, so for the first block , it works because the indentation is the same > for all 3 "print" statements , i.e. the indentation is 4 spaces for each of > the 3 print statements. > > if a == 1: > print("If a is one, this will print.")

Re: Python Indentation

2016-08-13 Thread Cai Gengyang
Oh ok, so for the first block , it works because the indentation is the same for all 3 "print" statements , i.e. the indentation is 4 spaces for each of the 3 print statements. if a == 1: print("If a is one, this will print.") print("So will this.") print("And this.") print("T

Creating dictionary of items from Excel with mutliple keys

2016-08-13 Thread Atri Mahapatra
I am trying to create a following dictionary. I am reading data from excel which has data in the following format: Sl no: Name Thickness Length Material Width Quantity Side It has 20 rows of data. The dictionary for the 20 rows, I would like to make is Data_Dict = [ { 'Name': 'X', 'Length

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Steven D'Aprano
On Sat, 13 Aug 2016 08:09 pm, BartC wrote: > (The way I deal with records elsewhere is so ridiculously simple that it > almost makes me want to cry when I see what most dynamic languages have > to do. Example: > > record date=# define the record > var day, month, year > end >

Re: Asynchronous programming

2016-08-13 Thread Paul Rubin
Marko Rauhamaa writes: > Also, one must be careful with file access, which is necessarily > blocking on linux (unless Python takes Linux's AIO API into use, which > would be groundbreaking). AIO is a possibility for i/o on an already-open file and I think there may be other ways to do it too. Bu

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread BartC
On 13/08/2016 13:08, BartC wrote: On 13/08/2016 12:10, Chris Angelico wrote: On Sat, Aug 13, 2016 at 8:09 PM, BartC wrote: And if subclassing isn't enough, there's no end of stuff you can do with decorators. Try this: class Foo: @prop class demo: """Declarative property"""

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Marko Rauhamaa
Gregory Ewing : > Nine hours to compile a simple text editor sounds completely > ridiculous to me, even for the times. Something must have been very, > very badly wrong. Some ten years back full compilations of our product could take 23 hours. The bulk of the time was spent thrashing, as SCons pro

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread BartC
On 13/08/2016 12:10, Chris Angelico wrote: On Sat, Aug 13, 2016 at 8:09 PM, BartC wrote: And if subclassing isn't enough, there's no end of stuff you can do with decorators. Try this: class Foo: @prop class demo: """Declarative property""" def get(self): p

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Gregory Ewing
Steven D'Aprano wrote: To be honest, I don't remember. It was so-called "Lightspeed Pascal", later renamed "Think Pascal", and especially after that experience I mostly used it for experimenting with Hypertalk XCMDs and XFNCs, which were much simpler as they weren't stand-alone GUI applications.

Re: Python Indentation

2016-08-13 Thread Chris Angelico
On Sat, Aug 13, 2016 at 8:52 PM, Cai Gengyang wrote: > Indentation must be the same. This code doesn't work. > > if a == 1: > print("Indented two spaces.") > print("Indented four. This will generate an error.") > print("The computer will want you to make up your mind.") > > Why does the

Re: Python Indentation

2016-08-13 Thread Marko Rauhamaa
Cai Gengyang : > Can someone explain in layman's terms what indentation is Indentation means the number space (" ") characters in the beginning of a line. A sequence of lines that have the same indentation belong to the same block of statements. Marko -- https://mail.python.org/mailman/listin

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Chris Angelico
On Sat, Aug 13, 2016 at 8:09 PM, BartC wrote: > The language doesn't make it easy for itself! No, it doesn't. But it does make things easy for *me*, the programmer. And yaknow what? If I want a language that makes things easy on *itself*, I can always go write assembly language code. That's not w

Python Indentation

2016-08-13 Thread Cai Gengyang
Indentation matters. Each line under the if statement that is indented will only be executed if the statement is true: if a == 1: print("If a is one, this will print.") print("So will this.") print("And this.") print("This will always print because it is not indented.") Indentation

Re: Win32 API in pywin32

2016-08-13 Thread eryk sun
On Sat, Aug 13, 2016 at 4:22 AM, Lawrence D’Oliveiro wrote: > On Friday, August 5, 2016 at 11:58:05 AM UTC+12, I wrote: >> >> Are people still using Win32? I thought Windows went 64-bit years ago. > > Here > is a little titbi

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread BartC
On 13/08/2016 08:37, Steven D'Aprano wrote: On Fri, 12 Aug 2016 09:55 pm, BartC wrote: I know because my intention was to create a RECORD, with a specific set of members or fields. With records, you usually don't just create arbitrary named members as you go along. Unfortunately your intenti

How to add data in xlm file ?

2016-08-13 Thread Asad ur Rehman
def Test(request): save_path = '/usr/share/newfies/' name_of_file = ("Avatar") completeName = os.path.join(save_path, name_of_file+".xlm") file1 = open(completeName, "w") toFile = raw_input("Write what you want into the field") file1.write(toFile) file1.c

Re: Asynchronous programming

2016-08-13 Thread Marko Rauhamaa
Paul Rubin : > Keep in mind that the above basically takes the task off the list of > runnables for 0.2 seconds, so it sits doing nothing and doesn't > interfere with other tasks running. In the case where you're doing > actual computation, you want to yield (await) much more often than 0.2 > sec,

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Steven D'Aprano
On Fri, 12 Aug 2016 11:30 pm, Michael Torrie wrote: > On 08/12/2016 05:07 AM, Steven D'Aprano wrote: >> The first time I ever compiled a full-sized application (not a particular >> large one either, it was a text editor a little more featureful than >> Notepad) it took something like nine hours to

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Steven D'Aprano
On Fri, 12 Aug 2016 09:55 pm, BartC wrote: > On 12/08/2016 12:07, Steven D'Aprano wrote: >> On Fri, 12 Aug 2016 07:38 pm, BartC wrote: >> >>> 'year' has been spelled wrongly >> >> How do you know? > > I know because my intention was to create a RECORD, with a specific set > of members or fields.