Re: Data structures and Algorithms

2020-06-30 Thread DL Neil via Python-list
++ there is a lot of cruft around managing memory and allocating sizes, not to mention additional verbiage. In Python you are far freer to concentrate on the data structures and algorithms themselves. Maybe start here: https://duckduckgo.com/html?q=python%20data%20structures%20and%20algorithms

Re: Data structures and Algorithms

2020-06-30 Thread Richard Damon
less so) in C++ > there is a lot of cruft around managing memory and allocating sizes, not > to mention additional verbiage. In Python you are far freer to > concentrate on the data structures and algorithms themselves. > > Maybe start here: > > > https://d

Re: Data structures and Algorithms

2020-06-30 Thread Cameron Simpson
ing sizes, not to mention additional verbiage. In Python you are far freer to concentrate on the data structures and algorithms themselves. Maybe start here: https://duckduckgo.com/html?q=python%20data%20structures%20and%20algorithms%20tutorials Cheers, Cameron Simpson -- https://mail.python.or

Data structures and Algorithms

2020-06-30 Thread satyaprasad
Hi, I am currently in learning process of python have been worked on some desktop application using pyqt . I want improve my DSA area but i searched so many videos mot sure how to start . 1.Do i really need learn datastructures in c or c++ to get complete logical details. 2 .or shall i start learn

Re: Library for parsing binary structures

2019-03-30 Thread Cameron Simpson
On 30Mar2019 10:29, Paul Moore wrote: On Fri, 29 Mar 2019 at 23:21, Cameron Simpson wrote: On 27Mar2019 18:41, Paul Moore wrote: >I'm looking for a library that lets me parse binary data structures. >The stdlib struct module is fine for simple structures, but when it &g

Re: Library for parsing binary structures

2019-03-30 Thread Paul Moore
On Fri, 29 Mar 2019 at 23:21, Cameron Simpson wrote: > > On 27Mar2019 18:41, Paul Moore wrote: > >I'm looking for a library that lets me parse binary data structures. > >The stdlib struct module is fine for simple structures, but when it > >gets to more complicated

Re: Library for parsing binary structures

2019-03-29 Thread Cameron Simpson
On 30Mar2019 09:44, Cameron Simpson wrote: On 27Mar2019 18:41, Paul Moore wrote: I'm looking for a library that lets me parse binary data structures. The stdlib struct module is fine for simple structures, but when it gets to more complicated cases, you end up doing a lot of the work by

Re: Library for parsing binary structures

2019-03-29 Thread Cameron Simpson
On 27Mar2019 18:41, Paul Moore wrote: I'm looking for a library that lets me parse binary data structures. The stdlib struct module is fine for simple structures, but when it gets to more complicated cases, you end up doing a lot of the work by hand (which isn't that hard, and is

Re: Library for parsing binary structures

2019-03-29 Thread Peter J. Holzer
On 2019-03-29 16:34:35 +, Paul Moore wrote: > On Fri, 29 Mar 2019 at 16:16, Peter J. Holzer wrote: > > > Obviously you need some way to describe the specific binary format you > > want to parse - in other words, a grammar. The library could then use > > the grammar to parse the input - either

Re: Library for parsing binary structures

2019-03-29 Thread Paul Moore
On Fri, 29 Mar 2019 at 16:16, Peter J. Holzer wrote: > Obviously you need some way to describe the specific binary format you > want to parse - in other words, a grammar. The library could then use > the grammar to parse the input - either by interpreting it directly, or > by generating (Python)

Re: Library for parsing binary structures

2019-03-29 Thread Dan Sommers
On 3/29/19 12:13 PM, Peter J. Holzer wrote: Obviously you need some way to describe the specific binary format you want to parse - in other words, a grammar. The library could then use the grammar to parse the input - either by interpreting it directly, or by generating (Python) code from it. Th

Re: Library for parsing binary structures

2019-03-29 Thread Peter J. Holzer
On 2019-03-28 11:07:22 +0100, dieter wrote: > Paul Moore writes: > > My real interest is in whether any libraries exist to do this sort > > of thing (there are plenty of parser libraries for text, pyparsing > > being the obvious one, but far fewer for binary structures).

Re: Library for parsing binary structures

2019-03-28 Thread dieter
Paul Moore writes: > On Thu, 28 Mar 2019 at 08:15, dieter wrote: > ... > My real interest is in whether any > libraries exist to do this sort of thing (there are plenty of parser > libraries for text, pyparsing being the obvious one, but far fewer for > binary structures)

Re: Library for parsing binary structures

2019-03-28 Thread Paul Moore
very similar to how I'd approach that. My real interest is in whether any libraries exist to do this sort of thing (there are plenty of parser libraries for text, pyparsing being the obvious one, but far fewer for binary structures). Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Library for parsing binary structures

2019-03-28 Thread dieter
Paul Moore writes: > I'm looking for a library that lets me parse binary data structures. > The stdlib struct module is fine for simple structures, but when it > gets to more complicated cases, you end up doing a lot of the work by > hand (which isn't that hard, and is gene

Library for parsing binary structures

2019-03-27 Thread Paul Moore
I'm looking for a library that lets me parse binary data structures. The stdlib struct module is fine for simple structures, but when it gets to more complicated cases, you end up doing a lot of the work by hand (which isn't that hard, and is generally perfectly viable, but I'

Re: Reciprocal data structures

2017-06-19 Thread Christopher Reimer
> On Jun 18, 2017, at 11:02 PM, Chris Angelico wrote: > > On Mon, Jun 19, 2017 at 3:54 PM, Steven D'Aprano wrote: >>> With a list? No, I would say it's a bad idea. >> >> >> Why a bad idea? >> >> As opposed to "can't be done", or "too hard and slow". > > Maintaining a record of list indices i

Re: Reciprocal data structures

2017-06-18 Thread Chris Angelico
On Mon, Jun 19, 2017 at 3:54 PM, Steven D'Aprano wrote: >> With a list? No, I would say it's a bad idea. > > > Why a bad idea? > > As opposed to "can't be done", or "too hard and slow". Maintaining a record of list indices inside an object, with the specific proviso that: > If the list is change

Re: Reciprocal data structures

2017-06-18 Thread Steven D'Aprano
On Mon, 19 Jun 2017 06:04:57 +1000, Chris Angelico wrote: > On Mon, Jun 19, 2017 at 5:27 AM, wrote: >> I am thinking of a list that actively maintains in its items a member >> that contains the item's own index in the list. Basically, the item >> knows its index into the list and the list ensur

Re: Reciprocal data structures

2017-06-18 Thread Chris Angelico
On Mon, Jun 19, 2017 at 5:27 AM, wrote: > I am thinking of a list that actively maintains in its items a member that > contains the item's own index in the list. Basically, the item knows its > index into the list and the list ensures that the index remains in sync. If > the list is changed,

Reciprocal data structures

2017-06-18 Thread pavlovevidence
I'm not sure if "reciprocal" is the right word, or if there is an official term for this. I am thinking of a list that actively maintains in its items a member that contains the item's own index in the list. Basically, the item knows its index into the list and the list ensures that the index

Re: working with ctypes and complex data structures

2016-10-06 Thread Michael Felt
On 04-Oct-16 04:48, eryk sun wrote: On Mon, Oct 3, 2016 at 9:27 PM, Michael Felt wrote: int perfstat_subsystem_total( perfstat_id_t *name, perfstat_subsystem_total_t *userbuff, int sizeof_struct, int desired_number); ... +79 class cpu_total: +80 def __init__(self

Re: working with ctypes and complex data structures

2016-10-05 Thread eryk sun
On Wed, Oct 5, 2016 at 9:03 PM, Michael Felt wrote: > >> +80 args = (1, "name", None), (2, "buff", None), (1, "size", >> 0), (1, "count", 1) > > error #1. paramater type 2 (the buffer might be where data is being put, but > for the call, the pointer is INPUT) An output parameter (type 2)

Re: working with ctypes and complex data structures

2016-10-05 Thread Michael Felt
Never said thank you - so, thanks! What I need to do was add the .v at the end so I was accessing the value of the structure. Unlilke Linux, AIX - for reasons unknown to all, they have the time_t definition that is specific to the ABI size, at least for these performance libraries that proba

Re: working with ctypes and complex data structures

2016-10-05 Thread Michael Felt
On 05-Oct-16 22:29, Emile van Sebille wrote: Thanks for the reply! After a shirt coffeebreak - back into the fray - and I found the following: +76 class cpu_total: +77 def __init__(self): +78 __perfstat__ = CDLL("libperfstat.a(shr_64.o)") +79 prototype = CFUNC

Re: working with ctypes and complex data structures

2016-10-05 Thread Emile van Sebille
On 10/05/2016 01:06 PM, Michael Felt wrote: On 02-Oct-16 19:50, Michael Felt wrote: I am trying to understand the documentation re: ctypes and interfacing with existing libraries. I am reading the documentation, and also other sites that have largely just copied the documentation - as well as

Re: working with ctypes and complex data structures

2016-10-05 Thread Michael Felt
On 02-Oct-16 19:50, Michael Felt wrote: I am trying to understand the documentation re: ctypes and interfacing with existing libraries. I am reading the documentation, and also other sites that have largely just copied the documentation - as well as the "free chapter" at O'Reilly (Python Co

Re: working with ctypes and complex data structures

2016-10-03 Thread eryk sun
On Mon, Oct 3, 2016 at 9:27 PM, Michael Felt wrote: > > int perfstat_subsystem_total( >perfstat_id_t *name, >perfstat_subsystem_total_t *userbuff, >int sizeof_struct, >int desired_number); > ... >+79 class cpu_total: >+80 def __init__(self): >+81 __perfst

Re: working with ctypes and complex data structures

2016-10-03 Thread Michael Felt
use, should be NULL perfstat_subsystem_total_t *userbuff A pointer to a memory area with enough space for the returned structure int sizeof_struct Should be set to sizeof(perfstat_subsystem_t) int desired_number Reserved for future use, must be set to 0 or 1 The return value wil

Re: working with ctypes and complex data structures

2016-10-03 Thread Michael Felt
On 03-Oct-16 16:35, Michael Felt wrote: I'd alias the type instead of defining a struct, e.g. `time_t = c_long`. This preserves automatic conversion of the simple type. The reason for the not using alias is because a) I was trying to be more inline with the text of the include file. I will hav

Re: working with ctypes and complex data structures

2016-10-03 Thread eryk sun
On Mon, Oct 3, 2016 at 2:35 PM, Michael Felt wrote: > On 02-Oct-16 23:44, eryk sun wrote: >> On Sun, Oct 2, 2016 at 5:50 PM, Michael Felt >> wrote: >> >>> b) what I am not understanding - as the basic documentation shows >>> FOO.value as the way to set/get the value of a _field_ >> >> You may b

Re: working with ctypes and complex data structures

2016-10-03 Thread Michael Felt
On 02-Oct-16 23:44, eryk sun wrote: On Sun, Oct 2, 2016 at 5:50 PM, Michael Felt wrote: a) where is documentation on "CField"'s? It's undocumented. So I do not feel so bad about not finding anything :) A CField is a data descriptor that accesses a struct field with the given type, size,

Re: working with ctypes and complex data structures

2016-10-03 Thread Michael Felt
On 02-Oct-16 23:44, eryk sun wrote: On Sun, Oct 2, 2016 at 5:50 PM, Michael Felt wrote: > >a) where is documentation on "CField"'s? I will reply more later - just a quick thanks. Not using maxsize will be good, also in a different patch - also specific to AIX. This "thing" I am working

Re: working with ctypes and complex data structures

2016-10-02 Thread eryk sun
On Sun, Oct 2, 2016 at 5:50 PM, Michael Felt wrote: > > a) where is documentation on "CField"'s? It's undocumented. A CField is a data descriptor that accesses a struct field with the given type, size, and offset. Like most descriptors, it's meant to be accessed as an attribute of an instance, n

working with ctypes and complex data structures

2016-10-02 Thread Michael Felt
I am trying to understand the documentation re: ctypes and interfacing with existing libraries. I am reading the documentation, and also other sites that have largely just copied the documentation - as well as the "free chapter" at O'Reilly (Python Cookbook). I am missing anything on CFields

Re: PEP Request: Advanced Data Structures

2016-07-17 Thread Rustom Mody
On Sunday, July 17, 2016 at 3:45:04 AM UTC+5:30, Shrey Desai wrote: > I have found it slightly frustrating that Python does not have built-in > support for advanced data structures (Linked Lists, Stacks/Queues, BST) in > its distribution. Many computer science students, developers, and

Re: PEP Request: Advanced Data Structures

2016-07-17 Thread Marko Rauhamaa
MRAB : > Given that Python has dict, there's not much need for a binary search tree. Dicts don't have the concept of key order. I use my own AVL tree to implement timers. A balanced tree data structure is the only major data structure I've missed in Python. It is there in Java and C++, for example

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Tim Chase
On 2016-07-17 08:19, Chris Angelico wrote: > Why do you need a linked list? That's an implementation detail; why > not simply use a regular list? > > Not trolling, genuinely asking. Is there something that you > specifically need those exact structures for? I know there ha

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Steven D'Aprano
On Sun, 17 Jul 2016 08:14 am, shrey.de...@gmail.com wrote: > I have found it slightly frustrating that Python does not have built-in > support for advanced data structures (Linked Lists, Stacks/Queues, BST) in > its distribution. They are hardly "advanced" data structures. Th

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Chris Angelico
s fine at doing that - the concepts of a linked list translate nicely into Python objects and attributes - even though it'll never actually be something Python needs. Once you've learned what the different fundamental structures are, you'll have a better understanding of what's goin

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread cs
On 17Jul2016 12:43, Chris Angelico wrote: On Sun, Jul 17, 2016 at 12:33 PM, Paul Rubin wrote: Chris Angelico writes: keep a reference to an element deep in the list, and insert a new element in O(1) time at that point. at the C level, wouldn't tracing the links cost massively more than the

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread MRAB
On 2016-07-17 03:33, Paul Rubin wrote: Chris Angelico writes: keep a reference to an element deep in the list, and insert a new element in O(1) time at that point. at the C level, wouldn't tracing the links cost massively more than the occasional insertion too? I'm not sure O(1) is of value at

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Chris Angelico
On Sun, Jul 17, 2016 at 12:33 PM, Paul Rubin wrote: > Chris Angelico writes: >>> keep a reference to an element deep in the list, and insert a new >>> element in O(1) time at that point. >> at the C level, wouldn't tracing the links cost massively more than >> the occasional insertion too? I'm no

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Paul Rubin
Chris Angelico writes: >> keep a reference to an element deep in the list, and insert a new >> element in O(1) time at that point. > at the C level, wouldn't tracing the links cost massively more than > the occasional insertion too? I'm not sure O(1) is of value at any > size, if the costs of all

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Chris Angelico
On Sun, Jul 17, 2016 at 10:54 AM, wrote: > Well, in a larger context you can keep a reference to an element deep in the > list, and insert a new element in O(1) time at that point. > I'd like to know how many elements your list needs before that actually becomes faster than CPython's heavily-opt

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread cs
thing. - Development: the use of correct data structures is important when developing applications, especially for issues like scaling and efficiency. For instance, when working with polynomials, Linked Lists provide a great interface to access and edit them. What does having links gai

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread MRAB
On 2016-07-17 01:10, Terry Reedy wrote: On 7/16/2016 6:14 PM, shrey.de...@gmail.com wrote: I have found it slightly frustrating that Python does not have built-in support for advanced data structures (Linked Lists, You and I have different ideas of 'advanced data structures' ;

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Terry Reedy
On 7/16/2016 6:14 PM, shrey.de...@gmail.com wrote: I have found it slightly frustrating that Python does not have built-in support for advanced data structures (Linked Lists, You and I have different ideas of 'advanced data structures' ;-). To me, linked list are limited structur

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread breamoreboy
On Saturday, July 16, 2016 at 11:15:04 PM UTC+1, Shrey Desai wrote: > I have found it slightly frustrating that Python does not have built-in > support for advanced data structures (Linked Lists, Stacks/Queues, BST) in > its distribution. Many computer science students, developers, and

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Paul Rubin
shrey.de...@gmail.com writes: > As a computer science undergraduate student, I don't want to spend > time writing the module but instead I want to work with it, play > around with it, and do problems with it. For educational purposes, I think writing the module yourself is part of the idea. Also,

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Chris Angelico
On Sun, Jul 17, 2016 at 8:33 AM, Shrey Desai wrote: > Hi Chris, thanks for the reply. There's a couple of reasons why I would need > a Linked List (and other data structures): > - Education: the Linked List is a core data structure that CS undergraduates > (among others) use an

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Shrey Desai
On Saturday, July 16, 2016 at 3:19:56 PM UTC-7, Chris Angelico wrote: > On Sun, Jul 17, 2016 at 8:14 AM, wrote: > > I have found it slightly frustrating that Python does not have built-in > > support for advanced data structures (Linked Lists, Stacks/Queues, BST) in > > i

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Chris Angelico
On Sun, Jul 17, 2016 at 8:14 AM, wrote: > I have found it slightly frustrating that Python does not have built-in > support for advanced data structures (Linked Lists, Stacks/Queues, BST) in > its distribution. Many computer science students, developers, and software > engineers r

PEP Request: Advanced Data Structures

2016-07-16 Thread shrey . desai
I have found it slightly frustrating that Python does not have built-in support for advanced data structures (Linked Lists, Stacks/Queues, BST) in its distribution. Many computer science students, developers, and software engineers rely on these data structures; having the data structures be a

Re: Interactive, test-driven coding challenges (algorithms and data structures)

2015-07-21 Thread Orochi
nges. I will > continue to add to the repo on a regular basis. I'm hoping you find it useful > as a fun, hands-on way to learn or to sharpen your skills on algorithms and > data structures, while helping yourself prep for coding interviews and coding > challenges. > >

Interactive, test-driven coding challenges (algorithms and data structures)

2015-07-13 Thread donne . martin
ay to learn or to sharpen your skills on algorithms and data structures, while helping yourself prep for coding interviews and coding challenges. Let me know if you have any questions or comments. Contributions are welcome! -Donne -- https://mail.python.org/mailman/listinfo/python-list

Re: nested dictionaries and functions in data structures.

2014-01-09 Thread Sean Murphy
Thanks for that. I will have a play and see how I can apply your example. On 07/01/2014, at 11:19 PM, Jean-Michel Pichavant wrote: > - Original Message - >> Thanks for that. It resolved the issue and it was so simple compared >> to everything else I saw on the net. >> >> Only outstandi

Re: nested dictionaries and functions in data structures.

2014-01-07 Thread Jean-Michel Pichavant
- Original Message - > Thanks for that. It resolved the issue and it was so simple compared > to everything else I saw on the net. > > Only outstanding thing I have to work out is how to execute functions > from a dictionary. I will continue searching on the net. > > > Sean This may hel

Re: nested dictionaries and functions in data structures.

2014-01-07 Thread Frank Millman
"Sean Murphy" wrote in message news:0cf6151e-e063-4252-9ac3-4fd4698eb...@gmail.com... > Hello all. > > I have some questions again. :-) > > I wish to be able to place a function within a data structure. I would > like to use a dictionary because I could pass it a key and then the > function co

Re: nested dictionaries and functions in data structures.

2014-01-07 Thread Steven D'Aprano
Sean Murphy wrote: > Only outstanding thing I have to work out is how to execute functions from > a dictionary. I will continue searching on the net. I don't quite understand this question. Do you mean something like this? def spam(n): return "spam"*n def eggs(n): return "eggs"*n d =

Re: nested dictionaries and functions in data structures.

2014-01-07 Thread Sean Murphy
Thanks for that. It resolved the issue and it was so simple compared to everything else I saw on the net. Only outstanding thing I have to work out is how to execute functions from a dictionary. I will continue searching on the net. Sean On 07/01/2014, at 9:21 PM, Jean-Michel Pichavant wrote

Re: nested dictionaries and functions in data structures.

2014-01-07 Thread Jean-Michel Pichavant
- Original Message - > Hello all. > > I have some questions again. :-) > > I wish to be able to place a function within a data structure. I > would like to use a dictionary because I could pass it a key and > then the function could be called. I couldn't find anything on the > net to s

nested dictionaries and functions in data structures.

2014-01-07 Thread Sean Murphy
Hello all. I have some questions again. :-) I wish to be able to place a function within a data structure. I would like to use a dictionary because I could pass it a key and then the function could be called. I couldn't find anything on the net to show me how to do this. More then likely, not

Re: Unpacking the structures

2013-12-18 Thread Dan Stromberg
On Wed, Dec 18, 2013 at 8:32 PM, wrote: > > Hi all, >While performing the packing/unpacking of xdr structures of rpc I get an > error as following. > > > x = struct.unpack('>L', data)[0] struct.error: unpack requires a string > argument of length 4. &

Unpacking the structures

2013-12-18 Thread smilesonisamal
Hi all, While performing the packing/unpacking of xdr structures of rpc I get an error as following. x = struct.unpack('>L', data)[0] struct.error: unpack requires a string argument of length 4. Can anybody help me in this regard? I checked the following link: http://docs

Re: Constructing JSON data structures from non-string key python dictionaries

2012-11-22 Thread saikari78
Thanks for all these very clarifying and useful replies -- http://mail.python.org/mailman/listinfo/python-list

Re: Constructing JSON data structures from non-string key python dictionaries

2012-11-22 Thread Paul Kölle
Am 21.11.2012 17:04, schrieb hfo...@gmail.com: Thanks for your reply, but the javascript function expects option names to be unquoted, otherwise it won't work. Others have shown you how to solve this, but I would like to note that the function does NOT expect JSON but a simple javascript object

Re: Constructing JSON data structures from non-string key python dictionaries

2012-11-21 Thread Chris Rebert
On Wed, Nov 21, 2012 at 7:48 AM, MRAB wrote: > On 2012-11-21 14:59, saikari78 wrote: >> >> Hi, >> >> I'm using the json module to create a JSON string, then inserting that >> string into a html template containing a javascript function (from the >> highcharts library: http://www.highcharts.com/)

Re: Constructing JSON data structures from non-string key python dictionaries

2012-11-21 Thread MRAB
On 2012-11-21 16:27, MRAB wrote:> On 2012-11-21 16:04, hfo...@gmail.com wrote: >> On Wednesday, November 21, 2012 3:48:07 PM UTC, MRAB wrote: >>> On 2012-11-21 14:59, saikari78 wrote: Hi, I'm using the json module to create a JSON string, then inserting that string into a ht

Re: Constructing JSON data structures from non-string key python dictionaries

2012-11-21 Thread MRAB
On 2012-11-21 16:04, hfo...@gmail.com wrote: On Wednesday, November 21, 2012 3:48:07 PM UTC, MRAB wrote: On 2012-11-21 14:59, saikari78 wrote: Hi, I'm using the json module to create a JSON string, then inserting that string into a html template containing a javascript >>> function (from th

Re: Constructing JSON data structures from non-string key python dictionaries

2012-11-21 Thread Grant Edwards
On 2012-11-21, MRAB wrote: >> However, I don't know how to do that because dictionary keys in >> python need to be strings. If I try to do the following, Python,of >> course, complains that y,color,drilldown, etc are not defined. > > Just quote them: > > data = [ { 'y':55.11, 'color':colors[0], '

Re: Constructing JSON data structures from non-string key python dictionaries

2012-11-21 Thread hfolch
Thanks for your reply, but the javascript function expects option names to be unquoted, otherwise it won't work. On Wednesday, November 21, 2012 3:48:07 PM UTC, MRAB wrote: > On 2012-11-21 14:59, saikari78 wrote: > > > Hi, > > > > > > I'm using the json module to create a JSON string, then

Re: Constructing JSON data structures from non-string key python dictionaries

2012-11-21 Thread MRAB
On 2012-11-21 14:59, saikari78 wrote: Hi, I'm using the json module to create a JSON string, then inserting that string into a html template containing a javascript function (from the highcharts library: http://www.highcharts.com/) The json string I'm trying to create is to initialize a data

Constructing JSON data structures from non-string key python dictionaries

2012-11-21 Thread saikari78
Hi, I'm using the json module to create a JSON string, then inserting that string into a html template containing a javascript function (from the highcharts library: http://www.highcharts.com/) The json string I'm trying to create is to initialize a data variable in the javascript function, th

ctypes, strange structures of PKCS11

2012-09-05 Thread Cornelius Kölbel
Hi there, I am trying to use a pkcs11 library (with python 2.7) and address this library with ctypes. Alas, I am neither the python black belt guru and C is not my preferred language. Till now, I do not want to use pykcs11, since I want to keep my dependencies low. I initialized the library, log

Re: Spacing and timing for comparing algorithms and data-structures

2012-03-01 Thread Chris Rebert
On Thu, Mar 1, 2012 at 8:55 PM, Alec Taylor wrote: > What would you recommend I use to compare data-structures and > algorithms on space and time? (runtime) For the latter metric, one of the profiling modules: http://docs.python.org/library/debug.html I'd start with timeit and go

Spacing and timing for comparing algorithms and data-structures

2012-03-01 Thread Alec Taylor
What would you recommend I use to compare data-structures and algorithms on space and time? (runtime) Thanks for all suggestions, Alec Taylor -- http://mail.python.org/mailman/listinfo/python-list

Re: complex data structures in python

2011-05-02 Thread Chris Rebert
On Mon, May 2, 2011 at 7:46 PM, Rita wrote: > Hello, > I was wondering if anyone has any documentation/recipes for implementing > complex data structures. For instance, if you had a dictionary with a list > inside a list inside a set. Er, there's no special magic. The da

complex data structures in python

2011-05-02 Thread Rita
Hello, I was wondering if anyone has any documentation/recipes for implementing complex data structures. For instance, if you had a dictionary with a list inside a list inside a set. -- --- Get your facts first, then you can distort them as you please.-- -- http://mail.python.org/mailman

Re: Nested structures question

2011-01-13 Thread Jean-Michel Pichavant
Physics Python wrote: Hello, I am teaching myself python using the book: Python Programming for Absolute Beginners, 2nd edition by Michael Dawson. I am using python 2.7.1. In chapter 3 we are learning to use structures (while, if, elif) to write a program that has the user guess a number

Re: Nested structures question

2011-01-12 Thread DevPlayer
looping = True while looping: guess = int(raw_input("Take a guess: ")) tries += 1 if guess > the_number: print "Lower..." elif guess < the_number: print "Higher..." else: print "You guessed it! The number was", the_number print "And it only took y

Re: Nested structures question

2011-01-12 Thread Tim Harig
In case you still need help: - # Set the initial values - the_number= random.randrange(100) + 1 - tries = 0 - guess = None - - # Guessing loop - while guess != the_number and tries < 7: - guess = int(raw_input("Take a guess: ")) - if guess > the_number: - print "Lower..." -

Re: Nested structures question

2011-01-12 Thread Tim Harig
On 2011-01-12, Jason Staudenmayer wrote: > Return False instead of break should work > > else: > print "You guessed it! The number was", the_number > print "And it only took you", tries, "tries!\n" > return False Since he isn't in a function, that isn't any good. He wo

Re: Nested structures question

2011-01-12 Thread Tim Harig
[wrapped lines to <80 characters per RFC 1855] On 2011-01-12, Physics Python wrote: > Is this an indentation problem then? That depends how you look at it. I was not clear from your code exactly where you wanted to handle things. > How do I update the sentinel within the secondary while loop. I

RE: Nested structures question

2011-01-12 Thread Jason Staudenmayer
gt; python-list-bounces+jasons=adventureaquarium@python.org > [mailto:python-list-bounces+jasons=adventureaquarium@pytho > n.org] On Behalf Of Physics Python > Sent: Wednesday, January 12, 2011 2:53 PM > To: python-list@python.org > Subject: Re: Nested structures question >

Re: Nested structures question

2011-01-12 Thread Physics Python
Thanks, Is this an indentation problem then? How do I update the sentinel within the secondary while loop. I am trying to avoid using breaks by the way, as I can program this example using breaks: --- start--- import random print "\tWelcome to 'Guess my number'!:" print "\nI'm thinking of a numb

Re: Nested structures question

2011-01-12 Thread Tim Harig
On 2011-01-12, Physics Python wrote: > while guess != the_number: = > while tries > 7: > if guess > the_number: > print "Lower..." > else: > print "Higher..." > guess = int(raw_input("Take a guess:

Nested structures question

2011-01-12 Thread Physics Python
Hello, I am teaching myself python using the book: Python Programming for Absolute Beginners, 2nd edition by Michael Dawson. I am using python 2.7.1. In chapter 3 we are learning to use structures (while, if, elif) to write a program that has the user guess a number between 1 and 100. Here is

Re: ctypes: nested structures and pointers

2010-01-18 Thread Gabriele Modena
uot; and "disconnect" in > separate structures and reference them within  pyDEV_CALLBACKS? Solved. The answer was in the doc: http://docs.python.org/library/ctypes.html#structured-data-types (_fields_ & _pack_). -- http://mail.python.org/mailman/listinfo/python-list

ctypes: nested structures and pointers

2010-01-18 Thread Gabriele Modena
rap "connect", "transceive" and "disconnect" in separate structures and reference them within pyDEV_CALLBACKS? The (stub) code I wrote for now looks like this: class pyDEV_CALLBACKS(Structure): _fields_ = [("acDriver", c_char_p), ("connect", c_void_

Re: parallel class structures for AST-based objects

2009-11-22 Thread Steve Howell
On Nov 22, 7:55 am, Simon Forman wrote: > On Sun, Nov 22, 2009 at 4:50 AM, Diez B. Roggisch wrote: > > > > > Steve Howell schrieb: > > >> On Nov 21, 4:07 pm, MRAB wrote: > > >>> I don't see the point of EvalNode and PrettyPrintNode. Why don't you > >>> just give Integer, Sum and Product 'eval' a

Re: parallel class structures for AST-based objects

2009-11-22 Thread Simon Forman
On Sun, Nov 22, 2009 at 4:50 AM, Diez B. Roggisch wrote: > Steve Howell schrieb: >> >> On Nov 21, 4:07 pm, MRAB wrote: >>> >>> I don't see the point of EvalNode and PrettyPrintNode. Why don't you >>> just give Integer, Sum and Product 'eval' and 'pprint' methods? >> >> That's a good question, and

Re: parallel class structures for AST-based objects

2009-11-22 Thread Diez B. Roggisch
Steve Howell schrieb: On Nov 21, 4:07 pm, MRAB wrote: I don't see the point of EvalNode and PrettyPrintNode. Why don't you just give Integer, Sum and Product 'eval' and 'pprint' methods? That's a good question, and it's the crux of my design dilemma. If ALL I ever wanted to to with Integer/S

Re: parallel class structures for AST-based objects

2009-11-21 Thread Gregory Ewing
Steve Howell wrote: My objection to the interface you describe is that Node defines the type of operations that can be done to it by third-party code, which is something that I cannot predict I think you have the right idea with a mapping from node classes to implementations of operations, but

Re: parallel class structures for AST-based objects

2009-11-21 Thread Steve Howell
etic expressions. My particular problem involves a mini-language that describes how you want to descend Python data structures. > But maybe that's not what you need. No need to overengineer if it is > though, keep it simple, simple is better than complex. Yep! I am trying to keep thin

Re: parallel class structures for AST-based objects

2009-11-21 Thread Richard Thomas
On 22 Nov, 00:07, MRAB wrote: > Steve Howell wrote: > > I have been writing some code that parses a mini-language, and I am > > running into what I know is a pretty common design pattern problem, > > but I am wondering the most Pythonic way to solve it. > > > Basically, I have a bunch of really si

Re: parallel class structures for AST-based objects

2009-11-21 Thread Steve Howell
On Nov 21, 4:07 pm, MRAB wrote: > > I don't see the point of EvalNode and PrettyPrintNode. Why don't you > just give Integer, Sum and Product 'eval' and 'pprint' methods? That's a good question, and it's the crux of my design dilemma. If ALL I ever wanted to to with Integer/Sum/Product was to ev

Re: parallel class structures for AST-based objects

2009-11-21 Thread MRAB
Steve Howell wrote: I have been writing some code that parses a mini-language, and I am running into what I know is a pretty common design pattern problem, but I am wondering the most Pythonic way to solve it. Basically, I have a bunch of really simple classes that work together to define an exp

parallel class structures for AST-based objects

2009-11-21 Thread Steve Howell
I have been writing some code that parses a mini-language, and I am running into what I know is a pretty common design pattern problem, but I am wondering the most Pythonic way to solve it. Basically, I have a bunch of really simple classes that work together to define an expression--in my oversim

Re: ANN: a mini-language for encapsulating deep-copy operations on Python data structures

2009-11-18 Thread Steve Howell
eave in the square brackets for __getitem__ > lookups on these: > > >                     .person 'name', > >                     .person 'location' as city, > Yep, I agree. The square brackets were not a deliberate omission. They were just slightly more t

  1   2   3   4   >