[issue46108] Enum repr() incorrect when mixed with non-__new__ data types

2022-01-17 Thread Ethan Furman
Ethan Furman added the comment: Fixed in 3.11. -- resolution: -> fixed stage: -> resolved status: open -> closed superseder: -> Enum: modify __repr__, __str__; update docs type: -> behavior ___ Python tracker

[issue46108] Enum repr() incorrect when mixed with non-__new__ data types

2021-12-17 Thread Ethan Furman
they can assign it when creating the Enum: class Entries(Foo, Enum): ENTRY = 1 __repr__ = Foo.__repr__ assert repr(Entries.ENTRY1) == 'Entries(a=1)' -- title: Enum repr() incorrect when mixed with dataclasses -> Enum repr() incorrect when mixed with non

ANNOUNCE: Thesaurus and ThesaurusCfg - recursive mapping and cfg file data types

2019-11-13 Thread Dave Cinege
This announcement is for a pre-release that I would like people to comment on structure, naming, etc. (Code review maybe not yet. :-) Before you say "It's all been done before." I suggest you take a closer look and I think you may conclude that what I've revised over 7 years is now

[issue33602] Remove set and queue references from Data Types

2019-09-10 Thread Julien Palard
Change by Julien Palard : -- nosy: -mdk resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue33602] Remove set and queue references from Data Types

2019-09-10 Thread Julien Palard
Julien Palard added the comment: New changeset 816825e192ed430438c613d52a58fb9e1a8d90f4 by Julien Palard (Miss Islington (bot)) in branch '3.7': bpo-33602: Doc: Remove set and queue references from Data Types (GH-7055) (GH-15876) https://github.com/python/cpython/commit

[issue33602] Remove set and queue references from Data Types

2019-09-10 Thread Julien Palard
Julien Palard added the comment: New changeset 58ef7d341c79f649da275bb1d5c11f668d7bac9e by Julien Palard (Miss Islington (bot)) in branch '3.8': bpo-33602: Doc: Remove set and queue references from Data Types (GH-7055) (GH-15875) https://github.com/python/cpython/commit

[issue33602] Remove set and queue references from Data Types

2019-09-10 Thread miss-islington
Change by miss-islington : -- pull_requests: +15516 pull_request: https://github.com/python/cpython/pull/15876 ___ Python tracker ___

[issue33602] Remove set and queue references from Data Types

2019-09-10 Thread miss-islington
Change by miss-islington : -- pull_requests: +15515 pull_request: https://github.com/python/cpython/pull/15875 ___ Python tracker ___

[issue33602] Remove set and queue references from Data Types

2019-09-10 Thread Julien Palard
Julien Palard added the comment: New changeset 912108891db52c2067889be1f4ce5713839807cd by Julien Palard (Andre Delfino) in branch 'master': bpo-33602: Doc: Remove set and queue references from Data Types (GH-7055) https://github.com/python/cpython/commit

Re: What data types does matplotlib pyplot take?

2018-06-15 Thread Peter Pearson
On Wed, 13 Jun 2018 12:53:57 -0400, C W wrote: > Hi everyone, > > I'm curious what data types pyplot takes. It seems that it can take numpy > series, pandas series, and possibly pandas dataframe? How many people data > types are out there? Is that true for all functions in l

What data types does matplotlib pyplot take?

2018-06-13 Thread C W
Hi everyone, I'm curious what data types pyplot takes. It seems that it can take numpy series, pandas series, and possibly pandas dataframe? How many people data types are out there? Is that true for all functions in like hist(), bar(), line(), etc? Is there an official documentation that lists

[issue33602] Remove set and queue references from Data Types

2018-05-22 Thread Andrés Delfino
Change by Andrés Delfino : -- keywords: +patch pull_requests: +6689 stage: -> patch review ___ Python tracker ___

[issue33602] Remove set and queue references from Data Types

2018-05-22 Thread Andrés Delfino
New submission from Andrés Delfino <adelf...@gmail.com>: Data Types mentions sets (which are now built-in) and synchronized queues (now mentioned in Concurrent Execution). I'm proposing fixing this. PR also adds mention to bytearray. -- assignee: docs@python components: Documen

Re: Learning python data types

2016-10-02 Thread Rustom Mody
On Monday, October 3, 2016 at 3:38:24 AM UTC+5:30, Crane Ugly wrote: > I am not new in scripting in general. > And about a year I create scripts in python, but my approach was always based > on my habits from UNIX shell, where data types are not obvious. > Going deeper with python I s

Learning python data types

2016-10-02 Thread Crane Ugly
I am not new in scripting in general. And about a year I create scripts in python, but my approach was always based on my habits from UNIX shell, where data types are not obvious. Going deeper with python I see necessity to know better data types, differences between them and most importantly

Re: Data Types

2016-09-22 Thread Chris Angelico
On Thu, Sep 22, 2016 at 10:33 PM, BartC wrote: >>> print (10<20)=> True >>> print (type(10<20)) => >> >> >> 10<20 shouldn't be thought of as some alternative value which is a bool, >> any >> more than we should think of 1+1 as being a different value to 2. > > >

Re: Data Types

2016-09-22 Thread BartC
On 22/09/2016 02:40, Steve D'Aprano wrote: On Wed, 21 Sep 2016 10:25 pm, BartC wrote: On 21/09/2016 05:03, Cai Gengyang wrote: Are there any other data types that will give you type(A) or type(B) = besides True and False? No types but any variable or expression containing True or False

Re: Data Types

2016-09-22 Thread Steve D'Aprano
On Thu, 22 Sep 2016 01:46 pm, Sayth Renshaw wrote: > What about 0 or 1 they are true and false like no other numbers? what > category do they fall in with regards to booleans? 0 and 1 are ints: py> type(0) py> type(1) just like 2, 3, 4, -1, -999, 1098765432 etc. But just like 1 == 1.0 (a

Re: Data Types

2016-09-22 Thread Lawrence D’Oliveiro
On Thursday, September 22, 2016 at 3:47:27 PM UTC+12, Sayth Renshaw wrote: > What about 0 or 1 they are true and false like no other numbers? >>> isinstance(1, bool) False >>> isinstance(True, int) True -- https://mail.python.org/mailman/listinfo/python-list

Re: Data Types

2016-09-22 Thread Larry Hudson via Python-list
On 09/20/2016 09:03 PM, Cai Gengyang wrote: [snip...] So for example for "bool" , it only applies to True/False and nothing else? (2 data types), i.e. : Not exactly... bool is the data type (or class), True and False are the only two _values_ (not types). type(True)

Re: Data Types

2016-09-21 Thread Sayth Renshaw
> > > >> Are there any other data types that will give you type(A) or type(B) = > >> besides True and False? > > > > No types but any variable or expression containing True or False will be > > a bool type (or class bool): > > "Containin

Re: Data Types

2016-09-21 Thread Steve D'Aprano
On Wed, 21 Sep 2016 10:25 pm, BartC wrote: > On 21/09/2016 05:03, Cai Gengyang wrote: > >> Are there any other data types that will give you type(A) or type(B) = >> besides True and False? > > No types but any variable or expression containing True or False will be >

Re: Data Types

2016-09-21 Thread BartC
On 21/09/2016 05:03, Cai Gengyang wrote: Are there any other data types that will give you type(A) or type(B) = besides True and False? No types but any variable or expression containing True or False will be a bool type (or class bool): A = 10<20 print (type(A)) => pri

Re: Data Types

2016-09-20 Thread Steven D'Aprano
On Wednesday 21 September 2016 14:03, Cai Gengyang wrote: > So for example for "bool" , it only applies to True/False and nothing else? Correct. True and False are the only instances of the type 'bool'. > (2 data types), i.e. : > >>>> type(True) > >>&g

Re: Data Types

2016-09-20 Thread Cai Gengyang
On Wednesday, September 21, 2016 at 11:22:42 AM UTC+8, Steve D'Aprano wrote: > On Wed, 21 Sep 2016 01:00 pm, Cai Gengyang wrote: > > > So I am going through chapter 7.1 (Data Types) of > > http://programarcadegames.com/index.php… What do these terms (input and > > outp

Re: Data Types

2016-09-20 Thread Steve D'Aprano
On Wed, 21 Sep 2016 01:00 pm, Cai Gengyang wrote: > So I am going through chapter 7.1 (Data Types) of > http://programarcadegames.com/index.php… What do these terms (input and > output) mean --- Can someone explain in plain English and layman's terms ? http://www.dictionary.com/bro

Data Types

2016-09-20 Thread Cai Gengyang
So I am going through chapter 7.1 (Data Types) of http://programarcadegames.com/index.php… What do these terms (input and output) mean --- Can someone explain in plain English and layman's terms ? Thanks a lot ... >>> type(3) >>> type(3.145) >>> type("Hi th

Re: Best way to deal with different data types in a list comprehension

2014-09-24 Thread Steven D'Aprano
Larry Martell wrote: I have some code that I inherited: ' '.join([self.get_abbrev()] + [str(f['value') for f in self.filters if f.has_key('value')]).strip() This broke today when it encountered some non-ascii data. It's already broken. It gives a

Best way to deal with different data types in a list comprehension

2014-09-23 Thread Larry Martell
I have some code that I inherited: ' '.join([self.get_abbrev()] + [str(f['value') for f in self.filters if f.has_key('value')]).strip() This broke today when it encountered some non-ascii data. I changed the str(f['value']) line to f['value'].encode('utf-8'),

Re: Best way to deal with different data types in a list comprehension

2014-09-23 Thread Rock Neurotiko
Maybe there are a different way, but you can do this: ' '.join([self.get_abbrev()] + [str(f['value').encode('utf-8') if type(f['value']) is str else str(f['value'] for f in self.filters if f.has_key('value')]).strip() 2014-09-24 0:01 GMT+02:00 Larry Martell

Re: Best way to deal with different data types in a list comprehension

2014-09-23 Thread Chris Kaynor
On Tue, Sep 23, 2014 at 3:01 PM, Larry Martell larry.mart...@gmail.com wrote: I have some code that I inherited: ' '.join([self.get_abbrev()] + [str(f['value') for f in self.filters if f.has_key('value')]).strip() This broke today when it encountered

Re: Best way to deal with different data types in a list comprehension

2014-09-23 Thread Larry Martell
On Tue, Sep 23, 2014 at 6:05 PM, Rock Neurotiko miguelglafue...@gmail.com wrote: 2014-09-24 0:01 GMT+02:00 Larry Martell larry.mart...@gmail.com: I have some code that I inherited: ' '.join([self.get_abbrev()] + [str(f['value') for f in self.filters if

Re: MySQL data types vs Django/Python data types

2013-09-04 Thread Fábio Santos
On 1 Sep 2013 21:54, Gary Roach gary719_li...@verizon.net wrote: Hi all, System: Debian Wheezy Linux Python 2.7 Django 1.5 MySql 5.5 I am new to Python and Django and am having trouble matching Python data types with those of MySQL. MySQL has about 7 basic

MySQL data types vs Django/Python data types

2013-09-01 Thread Gary Roach
Hi all, System: Debian Wheezy Linux Python 2.7 Django 1.5 MySql 5.5 I am new to Python and Django and am having trouble matching Python data types with those of MySQL. MySQL has about 7 basic data types including Blobs, Binaries, etc. It also has a rich

Re: save tuple of simple data types to disk (low memory foot print)

2011-10-29 Thread Gelonida N
(long ints) and floats (double) and the data types for each position within the tuple are fixed. The fastest and simplest way is to pickle the data or to use json. Both formats however are not that optimal. How big are your JSON files? 10KB? 10MB? 10GB? Have you tried using pickle's space

Re: save tuple of simple data types to disk (low memory foot print)

2011-10-29 Thread Gelonida N
On 10/29/2011 01:08 AM, Roy Smith wrote: In article mailman.2293.1319834877.27778.python-l...@python.org, Gelonida N gelon...@gmail.com wrote: I would like to save many dicts with a fixed amount of keys tuples to a file in a memory efficient manner (no random, but only sequential access

Re: save tuple of simple data types to disk (low memory foot print)

2011-10-29 Thread Tim Chase
'compact' ...by compressing out a lot of the duplicate aspects. Which also mitigates some of the verbosity of CSV. It serializes the data to a gzipped CSV file then unserializes it. Just point it at the appropriate data-source, adjust the column-names and data-types -tkc from gzip

save tuple of simple data types to disk (low memory foot print)

2011-10-28 Thread Gelonida N
) and floats (double) and the data types for each position within the tuple are fixed. The fastest and simplest way is to pickle the data or to use json. Both formats however are not that optimal. I could store ints and floats with pack. As strings have variable length I'm not sure how to save them

Re: save tuple of simple data types to disk (low memory foot print)

2011-10-28 Thread Roy Smith
In article mailman.2293.1319834877.27778.python-l...@python.org, Gelonida N gelon...@gmail.com wrote: I would like to save many dicts with a fixed amount of keys tuples to a file in a memory efficient manner (no random, but only sequential access is required) There's two possible scenarios

Re: save tuple of simple data types to disk (low memory foot print)

2011-10-28 Thread Steven D'Aprano
, ints (long ints) and floats (double) and the data types for each position within the tuple are fixed. The fastest and simplest way is to pickle the data or to use json. Both formats however are not that optimal. How big are your JSON files? 10KB? 10MB? 10GB? Have you tried using pickle's

How to pretty-print ctypes composite data types?

2011-10-25 Thread Grant Edwards
I'm using ctypes with a library that requires a handful of structure definitions. The actual definitions and usage aren't a problem. When it comes time to print out the values in a structure or array, there doesn't seem to be simple/general way to do that. Am I missing something? I presume one

Re: python data types in c++ code

2011-03-07 Thread Stefan Behnel
Dan Stromberg, 07.03.2011 03:47: On Sun, Mar 6, 2011 at 10:07 AM, Arthur Mc Coy wrote: You know, they are still using SVN, they are very loosely coupled to the past. about SVN: I'm not sure it's really dying. I hope it will. Yes, a lot of distributed development has moved off of SVN, and

c++ data types in python script

2011-03-06 Thread Arthur Mc Coy
Hi people, I've used SWIG module to embed python inside c++ app. I pass a list of objects (with lots of different properties of types string, float, custom types like URL, Software and finally of list of strings). Now I'm in python. URL and Software has str() method that converts their value to

Re: c++ data types in python script

2011-03-06 Thread Arthur Mc Coy
Great! The solution is to use self.benchmarks = list(object.benchmarks). Now I'm battling with time_t type. C++ time_t converts to python int but it causes memore leaks due to destructor absence. I'm trying to figure it out. If anyone know, please share your thoughts. Be happy :) Arthur --

python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
Hi all, Ok, I managed to work with c++ data types in python and can store serialize c++ objects to store in json. Now the task is backward. I wrote a c++ code to get the list of objects using again python interface. The list of objects is returned. PyList. But I can't see how to convert

Re: python data types in c++ code

2011-03-06 Thread Stefan Behnel
Arthur Mc Coy, 06.03.2011 17:40: Ok, I managed to work with c++ data types in python and can store serialize c++ objects to store in json. Now the task is backward. I wrote a c++ code to get the list of objects using again python interface. The list of objects is returned. PyList. But I can't

Re: python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
Ok people, I do: for (Py_ssize_t i = 0; i PyList_Size(py_list); ++i) { PuObject* obj = PyList_GetItem(py_list, i); if (obj != NULL) { // howto get obj properties of different types (map, list, string, int, bool) ? } } Very clear code. The question

Re: python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
Stefan, great suggestion !! I will definitely bookmark this page and consider later. But my project dictate me use SWIG. I'm almost near the happy subend. Very curios on question I asked in previous message. Dear all, I love you too much :) Arthur --

Re: python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
Stephan, you are lead developer over there :))) It's marketing, however very nice solution.. I will propose my bosses to rediscover their world assumptions. You know, they are still using SVN, they are very loosely coupled to the past. I have to wash their brains... Meantime still battling with

Re: python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
In short, the answer is to use PyObject dictionary ? -- http://mail.python.org/mailman/listinfo/python-list

Re: python data types in c++ code

2011-03-06 Thread Stefan Behnel
Arthur Mc Coy, 06.03.2011 19:07: Stephan, you are lead developer over there :))) It's marketing, Let's say, as a core developer of Cython, I'm well aware of it's virtues, and I can tell you that my suggestion is actually well backed by the user feedback we get. You will find some of it on

Re: python data types in c++ code

2011-03-06 Thread Miki Tebeka
// howto get obj properties of different types (map, list, string, int, bool) ? Python's C API is very well documented. You can use http://docs.python.org/c-api/object.html?highlight=pyobject#PyObject_GetAttr to get attributes or

Re: python data types in c++ code

2011-03-06 Thread Dan Stromberg
On Sun, Mar 6, 2011 at 10:07 AM, Arthur Mc Coy 1984docmc...@gmail.comwrote: You know, they are still using SVN, they are very loosely coupled to the past. Cython's very nice if you don't plan to do more than C/C++ with Python. SWIG might be better if you intend to do more VHLL's than Python

[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

2010-12-13 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Drat, missed this one when I was reviewing my issues for feature requests because I didn't change the type :( -- versions: +Python 3.3 -Python 3.2 ___ Python tracker rep...@bugs.python.org

[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

2010-12-13 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: -BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6302 ___ ___

[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

2010-10-04 Thread Barry A. Warsaw
Barry A. Warsaw ba...@python.org added the comment: In email6, can we at least make tuple returning methods return namedtuples instead? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6302

[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

2010-10-04 Thread Barry A. Warsaw
Barry A. Warsaw ba...@python.org added the comment: I agree that it makes sense to have consistent types in the output. As for whether to add a new method or fix the existing one, I'm a bit torn, but I'd probably opt for fixing the existing function rather than adding a new one, just because

[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

2010-10-04 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I agree that it makes sense to have consistent types in the output. As for whether to add a new method or fix the existing one, I'm a bit torn, but I'd probably opt for fixing the existing function rather than adding a new one, just because I

[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

2010-10-04 Thread Barry A. Warsaw
Barry A. Warsaw ba...@python.org added the comment: The point of a new method is to return the header as a human-readable string, rather than a list of tuples. It has added value besides leaving the old method alone ;) +1 then! :) -- ___ Python

[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

2010-10-03 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I think nttplib's use case can be satisfied via the issue 4661 patch coupled with the decode_header bytes-recovery enhancement. I don't really understand how that could. nntplib needs to decode (in the decode_header sense) headers containing

[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

2010-10-03 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Yes, that was a late night post and as I was falling asleep I realized that I was wrong. Certainly decode_header_as_string is a function most people using the email package will want and will re-implement in one form or another, so I

[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

2010-10-02 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Here is a patch that makes the output consistently (bytes, string) pairs. This is definitely a potential backward compatibility issue, but in general code which compensates for the old behavior should work fine with the new behavior,

[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

2010-10-02 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: -- versions: -Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6302 ___ ___

[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

2010-07-10 Thread Mark Lawrence
Mark Lawrence breamore...@yahoo.co.uk added the comment: Anyone got any comments to make on this? Should 2.7 also be included? -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6302

[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

2010-07-10 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: No, this is a 3.x only problem. And my main comment is that decode_headers ought to go away as an API :) But I'll try to fix the inconsistent data types problem before 3.2. -- assignee: - r.david.murray

Re: Pyserial and pysqlite data types, need advice

2010-05-18 Thread jon vs. python
The best thing I've found is this: http://eli.thegreenplace.net/2009/05/29/storing-blobs-in-a-sqlite-db-with-pythonpysqlite/ On Mon, May 17, 2010 at 5:05 PM, jon vs. python jonvspyt...@gmail.comwrote: Hi, I'm trying to store frames received via serial port (using Pyserial) into a sqlite

Pyserial and pysqlite data types, need advice

2010-05-17 Thread jon vs. python
Hi, I'm trying to store frames received via serial port (using Pyserial) into a sqlite database (using Pysqlite) in order to perform off-line processing. Thus I could use both SQL's power and Python's magic to make everything easier. I'd like my code to be generic and work both for binary and

Re: Feeding differeent data types to a class instance?

2010-03-18 Thread Christian
On Mar 14, 2:16 pm, kuru maymunbe...@gmail.com wrote: Hi Thank you so much for all these great suggestions. I will have time today to try all these and see which one works best for me Answers to your question have spread onto the Python blogosphere as well.

Re: Feeding differeent data types to a class instance?

2010-03-14 Thread Steve Holden
) This works well However I also want to be able to do vect=[1,2,3] myvec=Vec(vect) I want this class to accept multiple data types but process them as they are same when the classs deals with the instances. thanks With your existing class you can use Python's ability to transform a list

Re: Feeding differeent data types to a class instance?

2010-03-14 Thread kuru
Hi Thank you so much for all these great suggestions. I will have time today to try all these and see which one works best for me cheers -- http://mail.python.org/mailman/listinfo/python-list

Feeding differeent data types to a class instance?

2010-03-13 Thread kuru
want to be able to do vect=[1,2,3] myvec=Vec(vect) I want this class to accept multiple data types but process them as they are same when the classs deals with the instances. thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Feeding differeent data types to a class instance?

2010-03-13 Thread Rhodri James
On Sun, 14 Mar 2010 00:34:55 -, kuru maymunbe...@gmail.com wrote: Hi I have couple classes in the form of class Vector: def __init__(self,x,y,z): self.x=x self.y=y self.z=z This works fine for me. However I want to be able to provide a list, tuple as well as individual

Re: Feeding differeent data types to a class instance?

2010-03-13 Thread Steven D'Aprano
On Sat, 13 Mar 2010 16:34:55 -0800, kuru wrote: I want this class to accept multiple data types but process them as they are same when the classs deals with the instances. The usual term for this is polymorphism. myvec=Vector(1,2,3) vect=[1,2,3] myvec=Vec(vect) I assume you mean Vector

[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

2009-06-17 Thread R. David Murray
it says it returns strings. The example is also wrong, since the actual output is: [(b'p\xf6stal', 'iso-8859-1')] -- components: Library (Lib) messages: 89488 nosy: r.david.murray priority: normal severity: normal stage: test needed status: open title: email.header.decode_header data types

Re: Byte oriented data types in python

2009-01-25 Thread Ravi
Take a look at the struct and ctypes modules. struct is really not the choice. it returns an expanded string of the data and this means larger latency over bluetooth. ctypes is basically for the interface with libraries written in C (this I read from the python docs) --

Re: Byte oriented data types in python

2009-01-25 Thread Ravi
On Jan 25, 12:52 am, Martin v. Löwis mar...@v.loewis.de wrote: packet_type (1 byte unsigned) || packet_length (1 byte unsigned) || packet_data(variable) How to construct these using python data types, as int and float have no limits and their sizes are not well defined. In Python 2.x

Re: Byte oriented data types in python

2009-01-25 Thread Steve Holden
data types and character strings. Thus each native data type occupies only as many bytes as are required to store it in its native form (modulo any alignments needed). ctypes is basically for the interface with libraries written in C (this I read from the python docs) I believe it *is* the struct

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Ravi ra.ravi@gmail.com wrote: Take a look at the struct and ctypes modules. struct is really not the choice. it returns an expanded string of the data and this means larger latency over bluetooth. I don't know what you mean by returns an expanded string of the data. I do

Re: Byte oriented data types in python

2009-01-25 Thread Stephen Hansen
On Sun, Jan 25, 2009 at 7:27 AM, Ravi ra.ravi@gmail.com wrote: Take a look at the struct and ctypes modules. struct is really not the choice. it returns an expanded string of the data and this means larger latency over bluetooth. Noo... struct really IS the choice; that is the

Re: Byte oriented data types in python

2009-01-25 Thread Martin v. Löwis
Take a look at the struct and ctypes modules. struct is really not the choice. it returns an expanded string of the data and this means larger latency over bluetooth. I don't know what you mean by returns an expanded string of the data. I do know that struct does exactly what you

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Martin v. Löwis mar...@v.loewis.de wrote: Take a look at the struct and ctypes modules. struct is really not the choice. it returns an expanded string of the data and this means larger latency over bluetooth. I don't know what you mean by returns an expanded string of the

Re: Byte oriented data types in python

2009-01-25 Thread Martin v. Löwis
I disagree. He has a format (type, length, value), with the value being variable-sized. How do you do that in the struct module? You construct a format string for the value portion based on the type/length header. Can you kindly provide example code on how to do this? I don't see how

Re: Byte oriented data types in python

2009-01-25 Thread John Machin
On Jan 26, 2:28 am, Ravi ra.ravi@gmail.com wrote: On Jan 25, 12:52 am, Martin v. Löwis mar...@v.loewis.de wrote: packet_type (1 byte unsigned) || packet_length (1 byte unsigned) || packet_data(variable) How to construct these using python data types, as int and float have

Re: Byte oriented data types in python

2009-01-25 Thread Martin v. Löwis
Looks to me like there was already a reasonable way of getting a bytes object containing a variable number of zero bytes. Any particular reason why bytes(n) was given this specialised meaning? I think it was because bytes() was originally mutable, and you need a way to create a buffer of n

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Martin v. Löwis mar...@v.loewis.de wrote: You construct a format string for the value portion based on the type/length header. Can you kindly provide example code on how to do this? OK, something like this to handle received data where there is an initial 8-bit type field that

Re: Byte oriented data types in python

2009-01-25 Thread Martin v. Löwis
dtype = ord(rawdata[0]) dcount = struct.unpack(!H,rawdata[1:3]) if dtype == 1: fmtstr = ! + H*dcount elif dtype == 2: fmtstr = ! + f*dcount rlen = struct.calcsize(fmtstr) data = struct.unpack(fmtstr,rawdata[3:3+rlen]) leftover = rawdata[3+rlen:]

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
On 2009-01-25, Martin v. Löwis mar...@v.loewis.de wrote: dtype = ord(rawdata[0]) dcount = struct.unpack(!H,rawdata[1:3]) if dtype == 1: fmtstr = ! + H*dcount elif dtype == 2: fmtstr = ! + f*dcount rlen = struct.calcsize(fmtstr) data =

Re: Byte oriented data types in python

2009-01-25 Thread Martin v. Löwis
Unfortunately, that does not work in the example. We have a message type (an integer), and a variable-length string. So how do you compute the struct format for that? I'm confused. Are you asking for an introductory tutorial on programming in Python? Perhaps. I honestly do not know how to

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
of various data types to/from raw byte-strings. and yes, he doesn't need the struct module. Hence I'm puzzled why people suggest that he uses the struct module. We all assumed that packet_data might contain values of various types such as 16 or 32 bit integers, floating point values

Re: Byte oriented data types in python

2009-01-25 Thread Martin v. Löwis
It deals with variable sized fields just fine: dtype = 18 dlength = 32 format = !BB%ds % dlength rawdata = struct.pack(format, (dtype,dlength,data)) I wouldn't call this just fine, though - it involves a % operator to even compute the format string. IMO, it is *much* better not to use

Re: Byte oriented data types in python

2009-01-25 Thread Grant Edwards
to deal with arbitrary data types, then that's what the struct and ctypes modules are designed to do. The protocols I've implemented always required the ability to deal with integers greater than 8 bits wide as well as various other data types. -- Grant -- http://mail.python.org/mailman/listinfo

Re: Byte oriented data types in python

2009-01-25 Thread Stephen Hansen
and This can be used in handling binary data stored in files or from network connections The struct module is very useful when generating or interpreting a stream of binary data which has a set structured format, in bytes and with set kinds of data types. # I have following packet format which I

Re: Byte oriented data types in python

2009-01-25 Thread John Machin
On Jan 26, 10:53 am, Martin v. Löwis mar...@v.loewis.de wrote: It deals with variable sized fields just fine: dtype = 18 dlength = 32 format = !BB%ds % dlength rawdata = struct.pack(format, (dtype,dlength,data)) I wouldn't call this just fine, though - it involves a % operator to

Byte oriented data types in python

2009-01-24 Thread Ravi
I have following packet format which I have to send over Bluetooth. packet_type (1 byte unsigned) || packet_length (1 byte unsigned) || packet_data(variable) How to construct these using python data types, as int and float have no limits and their sizes are not well defined. -- http

Re: Byte oriented data types in python

2009-01-24 Thread Stephen Hansen
I have following packet format which I have to send over Bluetooth. packet_type (1 byte unsigned) || packet_length (1 byte unsigned) || packet_data(variable) How to construct these using python data types, as int and float have no limits and their sizes are not well defined. Check out

Re: Byte oriented data types in python

2009-01-24 Thread Martin v. Löwis
packet_type (1 byte unsigned) || packet_length (1 byte unsigned) || packet_data(variable) How to construct these using python data types, as int and float have no limits and their sizes are not well defined. In Python 2.x, use the regular string type: chr(n) will create a single byte

Re: Byte oriented data types in python

2009-01-24 Thread skip
Ravi packet_type (1 byte unsigned) || packet_length (1 byte unsigned) || Ravi packet_data(variable) Ravi How to construct these using python data types, as int and float have Ravi no limits and their sizes are not well defined. Take a look at the struct and ctypes modules

SQLAlchmey - new data types for PostgreSQL

2008-07-12 Thread Kless
It would be very interesting if the python community could to access since SQLAlchemy to more features of the PostgreSQL 8.3 RDBMS powerful, as are any new data types as: enumerated (ENUM) [1], XML [2], Universally Unique Identifiers (UUID) [3], and monetary [4]. For if anybody is interested

Re: Extending Python by Adding Keywords Data types

2007-08-01 Thread Marc 'BlackJack' Rintsch
On Wed, 01 Aug 2007 01:42:38 +, Maximus Decimus wrote: Since, I am an amateur in using python, could you please be more specific. For new data types, you had asked to implement the classes. I intend to use C for implementing these data types. So where do i need to implement these classes

Re: Extending Python by Adding Keywords Data types

2007-08-01 Thread Bjoern Schliessmann
you try to realise. For new data types, you had asked to implement the classes. I intend to use C for implementing these data types. So where do i need to implement these classes ie under which file or module in the python package. Please do yourself a favor and read. Feel free to ask again

  1   2   >