Re: Future standard GUI library

2013-05-29 Thread Chris Angelico
On Wed, May 29, 2013 at 3:26 AM, Wolfgang Keller wrote: > I won't give you an example, but just some very basic criteria: > > - It must be very efficient for very small "datagrams" > - It must provide connections > - For asynchronous programming it must provide for callbacks In other words, a TEL

Re: String object has no attribute "append"

2013-05-29 Thread Chris Angelico
On Wed, May 29, 2013 at 4:25 AM, Matt Graves wrote: > I receive this error while toying around with Functions... > > def pulldata(speclist,speccolumn): > (speclist).append(column[('speccolumn')]) > > pulldata(speclist = 'numbers', speccolumn = "0") > > I'm getting the error becaus

Re: IndentationError: expected an indented block but it's there

2013-05-29 Thread Chris Angelico
On Wed, May 29, 2013 at 2:53 AM, Peter Otten <__pete...@web.de> wrote: > Chris Angelico wrote: > >> On Wed, May 29, 2013 at 2:19 AM, Peter Otten <__pete...@web.de> wrote: >>> Solution: configure your editor to use four spaces for indentation. >> >> ITYM eight spaces. > > I meant: one hit of the Tab

Re: Python for IPSA (Power flow analysis)

2013-05-29 Thread steve . ingram
On Tuesday, May 28, 2013 11:00:42 AM UTC+1, Debbie wrote: > Hi there, > > I am new to Python, and wondering if you could help me with python based > coding for the IPSA (Power system analysis software). I have a electrical > distribution network with generators, buses and loads, on which I am >

MySQL dymanic query in Python

2013-05-29 Thread RAHUL RAJ
Can anyone tell me the proper way in which I can execute dynamic MySQL queries in Python? I want to do dynamic queries for both CREATE and INSERT statement. Here is my attempted code: sql="create table %s (%%s, %%s, %%s ... )" % (tablename,''.join(fields)+' '.join(types)) cur.execute(sql)

Re: MySQL dymanic query in Python

2013-05-29 Thread Fábio Santos
On 29 May 2013 10:13, "RAHUL RAJ" wrote: > > Can anyone tell me the proper way in which I can execute dynamic MySQL queries in Python? > > I want to do dynamic queries for both CREATE and INSERT statement. > > Here is my attempted code: > > > sql="create table %s (%%s, %%s, %%s ... )" % (tablename

Re: Text-to-Sound or Vice Versa (Method NOT the source code)

2013-05-29 Thread rusi
On May 29, 4:30 am, Dennis Lee Bieber wrote: > On Tue, 28 May 2013 15:10:03 + (UTC), Grant Edwards > declaimed the following in > gmane.comp.python.general: > > > On 2013-05-25, Rakshith Nayak wrote: > > > > Always wondered how sound is generated from text. Googling couldn't > > > help. Devs

Re: Encodign issue in Python 3.3.1 (once again)

2013-05-29 Thread nagia . retsina
What makes us o sure it is a pymysql issue and not python's encoding issue? -- http://mail.python.org/mailman/listinfo/python-list

Re: usage of os.posix_fadvise

2013-05-29 Thread Antoine Pitrou
Hi, Wolfgang Maier biologie.uni-freiburg.de> writes: > > Dear all, > I was just experimenting for the first time with os.posix_fadvise(), which > is new in Python3.3 . I'm reading from a really huge file (several GB) and I > want to use the data only once, so I don't want OS-level page caching.

detect key conflict in a JSON file

2013-05-29 Thread Jabba Laci
Hi, How can you detect if a key is duplicated in a JSON file? Example: { "something": [...], ... "something": [...] } I have a growing JSON file that I edit manually and it might happen that I repeat a key. If this happens, I would like to get notified. Currently the value of the sec

Output is not coming with defined color

2013-05-29 Thread Avnesh Shakya
hi, I am trying to display my output with different colour on terminal, but it's coming with that colour code. Please help me how is it possible? my code is - from fabric.colors import green, red, blue def colorr(): a = red('This is red') b = green('This is green') c = blue('This i

Fatal Python error

2013-05-29 Thread Joshua Landau
Hello all, again. Instead of revising like I'm meant to be, I've been delving into a bit of Python and I've come up with this code: class ClassWithProperty: @property def property(self): pass thingwithproperty = ClassWithProperty() def loop(): try: thingwithproperty.property except: pass loop

Re: Output is not coming with defined color

2013-05-29 Thread Fábio Santos
On 29 May 2013 12:25, "Avnesh Shakya" wrote: > > hi, >I am trying to display my output with different colour on terminal, but it's > coming with that colour code. > Please help me how is it possible? > > my code is - > from fabric.colors import green, red, blue > def colorr(): > a = red('T

Re: Fatal Python error

2013-05-29 Thread Dave Angel
On 05/29/2013 07:48 AM, Joshua Landau wrote: Hello all, again. Instead of revising like I'm meant to be, I've been delving into a bit of Python and I've come up with this code: To start with, please post in text mode. By using html, you've completely messed up any indentation you presumably

Re: Fatal Python error

2013-05-29 Thread Marcel Rodrigues
I just tried your code with similar results: it does nothing on PyPy 2.0.0-beta2 and Python 2.7.4. But on Python 3.3.1 it caused core dump. It's a little weird but so is the code. You have defined a function that calls itself unconditionally. This will cause a stack overflow, which is a RuntimeErro

Re: Fatal Python error

2013-05-29 Thread Joshua Landau
On 29 May 2013 13:25, Dave Angel wrote: > On 05/29/2013 07:48 AM, Joshua Landau wrote: > >> Hello all, again. Instead of revising like I'm meant to be, I've been >> delving into a bit of Python and I've come up with this code: >> >> > To start with, please post in text mode. By using html, you'v

Re: Fatal Python error

2013-05-29 Thread Oscar Benjamin
On 29 May 2013 12:48, Joshua Landau wrote: > Hello all, again. Instead of revising like I'm meant to be, I've been > delving into a bit of Python and I've come up with this code: Here's a simpler example that gives similar results: $ py -3.3 Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:

Re: Fatal Python error

2013-05-29 Thread Dave Angel
On 05/29/2013 08:45 AM, Oscar Benjamin wrote: On 29 May 2013 12:48, Joshua Landau wrote: Hello all, again. Instead of revising like I'm meant to be, I've been delving into a bit of Python and I've come up with this code: Here's a simpler example that gives similar results: $ py -3.3 Python 3

Re: Fatal Python error

2013-05-29 Thread Joshua Landau
On 29 May 2013 13:30, Marcel Rodrigues wrote: > > I just tried your code with similar results: it does nothing on PyPy 2.0.0-beta2 and Python 2.7.4. But on Python 3.3.1 it caused core dump. > It's a little weird but so is the code. You have defined a function that calls itself unconditionally. Thi

Re: Fatal Python error

2013-05-29 Thread Marcel Rodrigues
I think the issue here has little to do with classes/objects/properties. See, for example, the code posted by Oscar Benjamin. What that code is trying to do is similar to responding to an "Out Of Memory" error with something that might require more memory allocation. Even if we consider the Py3 b

Re: detect key conflict in a JSON file

2013-05-29 Thread Roy Smith
In article , Jabba Laci wrote: > I have a growing JSON file that I edit manually and it might happen > that I repeat a key. If this happens, I would like to get notified. The real answer here is that JSON is probably not the best choice for large files that get hand-edited. For data that you

Re: detect key conflict in a JSON file

2013-05-29 Thread Jabba Laci
> The real answer here is that JSON is probably not the best choice for > large files that get hand-edited. For data that you intend to hand-edit > a lot, YAML might be a better choice. > >> Currently the value of the second key silently overwrites the value of >> the first. Thanks but how would

Re: Fatal Python error

2013-05-29 Thread Joshua Landau
On 29 May 2013 14:02, Dave Angel wrote: > On 05/29/2013 08:45 AM, Oscar Benjamin wrote: > Joshua: Avoid doing anything complex inside an exception handler. Unfortunately, Ranger (the file manager in question) wraps a lot of stuff in one big exception handler. Hence there isn't much choice. The

Re: Output is not coming with defined color

2013-05-29 Thread rusi
On May 29, 5:11 pm, Fábio Santos wrote: > On 29 May 2013 12:25, "Avnesh Shakya" wrote: > > > > > > > > > > > hi, > >    I am trying to display my output with different colour on terminal, > but it's > > coming with that colour code. > > Please help me how is it possible? > > > my code is - > > fr

Re: detect key conflict in a JSON file

2013-05-29 Thread Ervin Hegedüs
Hello, On Wed, May 29, 2013 at 03:41:50PM +0200, Jabba Laci wrote: > > The real answer here is that JSON is probably not the best choice for > > large files that get hand-edited. For data that you intend to hand-edit > > a lot, YAML might be a better choice. > > > >> Currently the value of the se

Re: Short-circuit Logic

2013-05-29 Thread Ahmed Abdulshafy
On Tuesday, May 28, 2013 3:48:17 PM UTC+2, Steven D'Aprano wrote: > On Mon, 27 May 2013 13:11:28 -0700, Ahmed Abdulshafy wrote: > > > > > That may be true for integers, but for floats, testing for equality is > > > not always precise > > > > Incorrect. Testing for equality is always precise,

Re: Short-circuit Logic

2013-05-29 Thread Chris Angelico
On Thu, May 30, 2013 at 12:27 AM, Ahmed Abdulshafy wrote: > Well, this is taken from my python shell> > 0.33455857352426283 == 0.33455857352426282 > True >>> 0.33455857352426283,0.33455857352426282 (0.3345585735242628, 0.3345585735242628) They're not representably different. ChrisA -- ht

Re: Short-circuit Logic

2013-05-29 Thread rusi
On May 29, 7:27 pm, Ahmed Abdulshafy wrote: > On Tuesday, May 28, 2013 3:48:17 PM UTC+2, Steven D'Aprano wrote: > > On Mon, 27 May 2013 13:11:28 -0700, Ahmed Abdulshafy wrote: > > > > That may be true for integers, but for floats, testing for equality is > > > > not always precise > > > Incorrect.

Re: detect key conflict in a JSON file

2013-05-29 Thread rusi
On May 29, 6:41 pm, Jabba Laci wrote: > > The real answer here is that JSON is probably not the best choice for > > large files that get hand-edited.  For data that you intend to hand-edit > > a lot, YAML might be a better choice. > > >> Currently the value of the second key silently overwrites th

Re: Python #ifdef

2013-05-29 Thread Grant Edwards
On 2013-05-28, Carlos Nepomuceno wrote: > How do you have "invalid@invalid.invalid" instead of your email address? I have this in my .slrnrc: set hostname "invalid.invalid" set username "grant" set realname "Grant Edwards" I'm not sure why it doesn't show up as grant@invalid.invalid -- I th

Re: Fatal Python error

2013-05-29 Thread rusi
On May 29, 5:43 pm, Joshua Landau wrote: > On 29 May 2013 13:25, Dave Angel wrote: > > > On 05/29/2013 07:48 AM, Joshua Landau wrote: > > >> Hello all, again. Instead of revising like I'm meant to be, I've been > >> delving into a bit of Python and I've come up with this code: > > > To start with

Re: Python #ifdef

2013-05-29 Thread Grant Edwards
On 2013-05-29, Dan Stromberg wrote: > And in case you still want a preprocessor for Python (you likely don't need > one this time), here's an example of doing this using the venerable m4: > https://pypi.python.org/pypi/red-black-tree-mod . Note the many comments > added to keep line numbers cons

Re: Python #ifdef

2013-05-29 Thread Chris Angelico
On Thu, May 30, 2013 at 12:55 AM, Grant Edwards wrote: > On 2013-05-29, Dan Stromberg wrote: > >> And in case you still want a preprocessor for Python (you likely don't need >> one this time), here's an example of doing this using the venerable m4: >> https://pypi.python.org/pypi/red-black-tree-m

Re: Fatal Python error

2013-05-29 Thread Oscar Benjamin
On 29 May 2013 14:02, Dave Angel wrote: > On 05/29/2013 08:45 AM, Oscar Benjamin wrote: > > More likely a bug in the 2.x interpreter. Once inside an exception handler, > that frame must be held somehow. If not on the stack, then in some separate > list. So the logic will presumably fill memory,

Re: detect key conflict in a JSON file

2013-05-29 Thread Roy Smith
On May 29, 2013, at 9:41 AM, Jabba Laci wrote: >> The real answer here is that JSON is probably not the best choice for >> large files that get hand-edited. For data that you intend to hand-edit >> a lot, YAML might be a better choice. >> >>> Currently the value of the second key silently overwr

Re: Python #ifdef

2013-05-29 Thread Grant Edwards
On 2013-05-29, Chris Angelico wrote: > On Thu, May 30, 2013 at 12:55 AM, Grant Edwards > wrote: >> On 2013-05-29, Dan Stromberg wrote: >> >>> And in case you still want a preprocessor for Python (you likely don't need >>> one this time), here's an example of doing this using the venerable m4: >

Re: detect key conflict in a JSON file

2013-05-29 Thread Chris Rebert
On Wed, May 29, 2013 at 4:16 AM, Jabba Laci wrote: > Hi, > > How can you detect if a key is duplicated in a JSON file? Example: > > { > "something": [...], > ... > "something": [...] > } > > I have a growing JSON file that I edit manually and it might happen > that I repeat a key. If t

Re: Short-circuit Logic

2013-05-29 Thread Ian Kelly
On Wed, May 29, 2013 at 8:33 AM, rusi wrote: > 0.0 == 0.0 implies 5.4 == 5.4 > is not a true statement is what (I think) Steven is saying. > 0 (or if you prefer 0.0) is special and is treated specially. It has nothing to do with 0 being special. A floating point number will always equal itself (

Re: Piping processes works with 'shell = True' but not otherwise.

2013-05-29 Thread Chris Rebert
On Sun, May 26, 2013 at 4:58 PM, Luca Cerone wrote: > Hi Chris, first of all thanks for the help. Unfortunately I can't provide the > actual commands because are tools that are not publicly available. > I think I get the tokenization right, though.. the problem is not that the > programs don't

Re: Piping processes works with 'shell = True' but not otherwise.

2013-05-29 Thread Thomas Rachel
Am 27.05.2013 02:14 schrieb Carlos Nepomuceno: pipes usually consumes disk storage at '/tmp'. Good that my pipes don't know about that. Why should that happen? Thomas -- http://mail.python.org/mailman/listinfo/python-list

Getting a callable for any value?

2013-05-29 Thread Croepha
Is there anything like this in the standard library? class AnyFactory(object): def __init__(self, anything): self.product = anything def __call__(self): return self.product def __repr__(self): return "%s.%s(%r)" % (self.__class__.__module__, self.__class__.__name__, self.product) my use case is:

Re: Getting a callable for any value?

2013-05-29 Thread andrea crotti
On 05/29/2013 06:46 PM, Croepha wrote: Is there anything like this in the standard library? class AnyFactory(object): def __init__(self, anything): self.product = anything def __call__(self): return self.product def __repr__(self): return "%s.%s(%r)" % (self.__class__.__module__, self.__class__

Re: Getting a callable for any value?

2013-05-29 Thread Ned Batchelder
On 5/29/2013 1:46 PM, Croepha wrote: Is there anything like this in the standard library? class AnyFactory(object): def __init__(self, anything): self.product = anything def __call__(self): return self.product def __repr__(self): return "%s.%s(%r)" % (self.__class__.__module__, self.__class__._

Re: Getting a callable for any value?

2013-05-29 Thread Fábio Santos
On 29 May 2013 18:51, "Croepha" wrote: > > Is there anything like this in the standard library? > > class AnyFactory(object): > def __init__(self, anything): > self.product = anything > def __call__(self): > return self.product > def __repr__(self): > return "%s.%s(%r)" % (self.__class__.__module_

Re: Getting a callable for any value?

2013-05-29 Thread Ian Kelly
On Wed, May 29, 2013 at 11:46 AM, Croepha wrote: > Is there anything like this in the standard library? > > class AnyFactory(object): > def __init__(self, anything): > self.product = anything > def __call__(self): > return self.product > def __repr__(self): > return "%s.%s(%r)" % (self.__class__._

The state of pySerial

2013-05-29 Thread Ma Xiaojun
Hi, all. pySerial is probably "the solution" for serial port programming. Physical serial port is dead on PC but USB-to-Serial give it a second life. Serial port stuff won't interest end users at all. But it is still used in the EE world and so on. Arduino uses it to upload programs. Sensors may u

Re: Getting a callable for any value?

2013-05-29 Thread Ian Kelly
On Wed, May 29, 2013 at 12:19 PM, Fábio Santos wrote: > Are you sure you don't want to use a lambda expression? They are pretty > pythonic. > > none_factory = lambda: None > defaultdict_none_factory = lambda: defaultdict(none_factory) > > collections.defaultdict(defaultdict_none_factory) Gah. If

python b'...' notation

2013-05-29 Thread alcyon
This notation displays hex values except when they are 'printable', in which case it displays that printable character. How do I get it to force hex for all bytes? Thanks, Steve -- http://mail.python.org/mailman/listinfo/python-list

Re: How clean/elegant is Python's syntax?

2013-05-29 Thread Ma Xiaojun
A bit more context. If visiting z.cn (Amazon China), one can see that there are plenty of new (published in 2010 or later) books on QBASIC, Visual Basic, Visual Foxpro. This is weird, if one want to do development legally these tools won't be a option for new programmers. However, I also like to

How clean/elegant is Python's syntax?

2013-05-29 Thread Ma Xiaojun
Hi, list. I hope this is not a duplicate of older question. If so, drop me a link is enough. I've used Python here and there, just for the sweet libraries though. For the core language, I have mixed feeling. On one hand, I find that Python has some sweet feature that is quite useful. On the othe

Re: How clean/elegant is Python's syntax?

2013-05-29 Thread Chris Angelico
On Thu, May 30, 2013 at 4:37 AM, Ma Xiaojun wrote: > Yes, Python has much more libraries. But it seems that Python is more > useful and suitable in CLI and Web applications. People are still > discussing whether to replace tkinter with wxPython or not. VB and VFP > people are never bothered with s

Re: python b'...' notation

2013-05-29 Thread Ian Kelly
On Wed, May 29, 2013 at 12:33 PM, alcyon wrote: > This notation displays hex values except when they are 'printable', in which > case it displays that printable character. How do I get it to force hex for > all bytes? Thanks, Steve Is this what you want? >>> ''.join('%02x' % x for x in b'hel

RE: Piping processes works with 'shell = True' but not otherwise.

2013-05-29 Thread Carlos Nepomuceno
> From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de > Subject: Re: Piping processes works with 'shell = True' but not otherwise. > Date: Wed, 29 May 2013 19:39:40 +0200 > To: python-list@python.org > > Am 27.05.2013 02:14 schrieb Carlo

Re: The state of pySerial

2013-05-29 Thread Grant Edwards
On 2013-05-29, Ma Xiaojun wrote: > pySerial is probably "the solution" for serial port programming. > Physical serial port is dead on PC but USB-to-Serial give it a second > life. Serial port stuff won't interest end users at all. But it is > still used in the EE world and so on. Arduino uses it

Re: The state of pySerial

2013-05-29 Thread William Ray Wing
On May 29, 2013, at 2:23 PM, Ma Xiaojun wrote: > Hi, all. > > pySerial is probably "the solution" for serial port programming. > Physical serial port is dead on PC but USB-to-Serial give it a second > life. Serial port stuff won't interest end users at all. But it is > still used in the EE world

Re: How clean/elegant is Python's syntax?

2013-05-29 Thread Walter Hurry
On Thu, 30 May 2013 04:54:44 +1000, Chris Angelico wrote: > GUIs and databasing are two of the areas where I > think Python's standard library could stand to be improved a bit. > There are definitely some rough edges there. Dunno what you mean about "standard library", but I'm very happy with w

Re: How clean/elegant is Python's syntax?

2013-05-29 Thread Mark Janssen
You might try http://wiki.python.org/moin/BeginnersGuide -- MarkJ Tacoma, Washington -- http://mail.python.org/mailman/listinfo/python-list

Re: The state of pySerial

2013-05-29 Thread Terry Jan Reedy
On 5/29/2013 4:00 PM, William Ray Wing wrote: On May 29, 2013, at 2:23 PM, Ma Xiaojun wrote: Hi, all. pySerial is probably "the solution" for serial port programming. Physical serial port is dead on PC but USB-to-Serial give it a second life. Serial port stuff won't interest end users at all.

Re: The state of pySerial

2013-05-29 Thread Terry Jan Reedy
On 5/29/2013 3:47 PM, Grant Edwards wrote: On 2013-05-29, Ma Xiaojun wrote: pySerial is probably "the solution" for serial port programming. Physical serial port is dead on PC but USB-to-Serial give it a second life. Serial port stuff won't interest end users at all. But it is still used in th

Re: How clean/elegant is Python's syntax?

2013-05-29 Thread Cameron Simpson
On 30May2013 02:13, Ma Xiaojun wrote: | For the core language, I have mixed feeling. On one hand, I find that | Python has some sweet feature that is quite useful. On the other hand, | I often find Pyhton snippets around hard to understand. I think you will find that is lack of practice. I find P

Re: python b'...' notation

2013-05-29 Thread Cameron Simpson
On 29May2013 13:14, Ian Kelly wrote: | On Wed, May 29, 2013 at 12:33 PM, alcyon wrote: | > This notation displays hex values except when they are 'printable', in which case it displays that printable character. How do I get it to force hex for all bytes? Thanks, Steve | | Is this what you wa

Re: The state of pySerial

2013-05-29 Thread MRAB
On 29/05/2013 22:38, Terry Jan Reedy wrote: On 5/29/2013 4:00 PM, William Ray Wing wrote: On May 29, 2013, at 2:23 PM, Ma Xiaojun wrote: Hi, all. pySerial is probably "the solution" for serial port programming. Physical serial port is dead on PC but USB-to-Serial give it a second life. Seria

Re: Piping processes works with 'shell = True' but not otherwise.

2013-05-29 Thread Cameron Simpson
On 29May2013 19:39, Thomas Rachel wrote: | Am 27.05.2013 02:14 schrieb Carlos Nepomuceno: | >pipes usually consumes disk storage at '/tmp'. | | Good that my pipes don't know about that. | Why should that happen? It probably doesn't on anything modern. On V7 UNIX at least there was a kernel noti

Re: Short-circuit Logic

2013-05-29 Thread Dave Angel
On 05/29/2013 12:50 PM, Ian Kelly wrote: On Wed, May 29, 2013 at 8:33 AM, rusi wrote: 0.0 == 0.0 implies 5.4 == 5.4 is not a true statement is what (I think) Steven is saying. 0 (or if you prefer 0.0) is special and is treated specially. It has nothing to do with 0 being special. A floating

Re: How clean/elegant is Python's syntax?

2013-05-29 Thread Dan Stromberg
On Wed, May 29, 2013 at 11:13 AM, Ma Xiaojun wrote: > Hi, list. > > For the core language, I have mixed feeling. On one hand, I find that > Python has some sweet feature that is quite useful. On the other hand, > I often find Pyhton snippets around hard to understand. I admit that I > never learn

Re: How clean/elegant is Python's syntax?

2013-05-29 Thread Ma Xiaojun
On Thu, May 30, 2013 at 8:24 AM, Dan Stromberg wrote: > I'm finding it kind of hard to imagine not finding Python's syntax and > semantics pretty graceful. > > About the only thing I don't like is: > >var = 1, > > That binds var to a tuple (singleton) value, instead of 1. > > Oh, and method de

Re: The state of pySerial

2013-05-29 Thread Ma Xiaojun
I've already mailed the author, waiting for reply. For Windows people, downloading a exe get you pySerial 2.5, which list_ports and miniterm feature seems not included. To use 2.6, download the tar.gz and use standard "setup.py install" to install it (assume you have .py associated) . There is no

Re: Short-circuit Logic

2013-05-29 Thread Steven D'Aprano
On Wed, 29 May 2013 10:50:47 -0600, Ian Kelly wrote: > On Wed, May 29, 2013 at 8:33 AM, rusi wrote: >> 0.0 == 0.0 implies 5.4 == 5.4 >> is not a true statement is what (I think) Steven is saying. 0 (or if >> you prefer 0.0) is special and is treated specially. > > It has nothing to do with 0 bei

Re: How clean/elegant is Python's syntax?

2013-05-29 Thread rusi
On May 30, 6:14 am, Ma Xiaojun wrote: > What interest me is a one liner: > print '\n'.join(['\t'.join(['%d*%d=%d' % (j,i,i*j) for i in > range(1,10)]) for j in range(1,10)]) Ha,Ha! The join method is one of the (for me) ugly features of python. You can sweep it under the carpet with a one-line jo

Re: detect key conflict in a JSON file

2013-05-29 Thread Steven D'Aprano
On Wed, 29 May 2013 11:20:59 -0400, Roy Smith wrote: >> How to process (read) YAML files in Python? > > Take a look at http://pyyaml.org/ Beware that pyaml suffers from the same issue as pickle, namely that it can execute arbitrary code when reading untrusted data. -- Steven -- http://mail.

Re: detect key conflict in a JSON file

2013-05-29 Thread Jerry Hill
On Wed, May 29, 2013 at 1:10 PM, Chris Rebert wrote: > On Wed, May 29, 2013 at 4:16 AM, Jabba Laci wrote: > > I have a growing JSON file that I edit manually and it might happen > > that I repeat a key. If this happens, I would like to get notified. > > Currently the value of the second key sile

Re: Short-circuit Logic

2013-05-29 Thread Chris Angelico
On Thu, May 30, 2013 at 12:28 PM, Steven D'Aprano wrote: > * de facto exact equality testing, only slower and with the *illusion* of > avoiding equality, e.g. "abs(x-y) < sys.float_info.epsilon" is just a > long and slow way of saying "x == y" when both numbers are sufficiently > large; > The pro

Re: How clean/elegant is Python's syntax?

2013-05-29 Thread Chris Angelico
On Thu, May 30, 2013 at 7:01 AM, Walter Hurry wrote: > On Thu, 30 May 2013 04:54:44 +1000, Chris Angelico wrote: > > >> GUIs and databasing are two of the areas where I >> think Python's standard library could stand to be improved a bit. >> There are definitely some rough edges there. > > Dunno w

Re: How clean/elegant is Python's syntax?

2013-05-29 Thread Chris Angelico
On Thu, May 30, 2013 at 10:24 AM, Dan Stromberg wrote: > I'm finding it kind of hard to imagine not finding Python's syntax and > semantics pretty graceful. > > About the only thing I don't like is: > >var = 1, > > That binds var to a tuple (singleton) value, instead of 1. I agree, and would

Re: The state of pySerial

2013-05-29 Thread Grant Edwards
On 2013-05-29, Terry Jan Reedy wrote: > On 5/29/2013 3:47 PM, Grant Edwards wrote: >> On 2013-05-29, Ma Xiaojun wrote: [...] >>> Unforunately, pySerial project doesn't seem to have a good state. I >>> find pySerial + Python 3.3 broken on my machine (Python 2.7 is OK) . >>> There are unanswered ou

Building a HPC data assimilation system using Python?

2013-05-29 Thread Matthew Francis
I have a prototype data assimilation code ( an ionospheric nowcast/forecast model driven by GPS data ) that is written in IDL (interactive data language) which is a horrible language choice for scaling the application up to large datasets as IDL is serial and slow (interpreted). I am embarking

Re: Short-circuit Logic

2013-05-29 Thread Steven D'Aprano
On Wed, 29 May 2013 07:27:40 -0700, Ahmed Abdulshafy wrote: > On Tuesday, May 28, 2013 3:48:17 PM UTC+2, Steven D'Aprano wrote: >> On Mon, 27 May 2013 13:11:28 -0700, Ahmed Abdulshafy wrote: >> >> >> >> > That may be true for integers, but for floats, testing for equality >> > is >> >> > not a

Re: Short-circuit Logic

2013-05-29 Thread Chris Angelico
On Thu, May 30, 2013 at 3:10 PM, Steven D'Aprano wrote: > # Wrong, don't do this! > x = 0.1 > while x != 17.3: > print(x) > x += 0.1 > Actually, I wouldn't do that with integers either. There are too many ways that a subsequent edit could get it wrong and go infinite, so I'd *always* use

Re: Short-circuit Logic

2013-05-29 Thread Steven D'Aprano
On Wed, 29 May 2013 20:23:00 -0400, Dave Angel wrote: > Even in a pure decimal system of (say) > 40 digits, I could type in a 42 digit number and it would get quantized. > So just because two 42 digit numbers are different doesn't imply that > the 40 digit internal format would be. Correct, and

Re: Short-circuit Logic

2013-05-29 Thread Steven D'Aprano
On Thu, 30 May 2013 13:45:13 +1000, Chris Angelico wrote: > Let's suppose someone is told to compare floating point numbers by > seeing if the absolute value of the difference is less than some > epsilon. Which is usually the wrong way to do it! Normally one would prefer *relative* error, not a

Re: How clean/elegant is Python's syntax?

2013-05-29 Thread Steven D'Aprano
On Thu, 30 May 2013 02:37:35 +0800, Ma Xiaojun wrote: > For pure procedural paradigm, I haven't seen much advantages of Python. Nice syntax with a minimum of boiler plate -- "executable pseudo-code", as they say. Extensive library support -- "batteries included". These are both good advantages

Re: Getting a callable for any value?

2013-05-29 Thread Steven D'Aprano
On Wed, 29 May 2013 12:46:19 -0500, Croepha wrote: > Is there anything like this in the standard library? > > class AnyFactory(object): > def __init__(self, anything): > self.product = anything > def __call__(self): > return self.product > def __repr__(self): >