Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Steven D'Aprano
On Wed, 28 Mar 2012 23:58:53 -0400, Ross Ridge wrote: > How does that in anyway justify Evan Driscoll maliciously lying about > code he's never seen? You are perfectly justified to complain about Evan making sweeping generalisations about your code when he has not seen it; you are NOT justified

Re: unittest: assertRaises() with an instance instead of a type

2012-03-28 Thread Steven D'Aprano
On Thu, 29 Mar 2012 12:55:13 +1100, Ben Finney wrote: > Steven D'Aprano writes: > >> (By the way, I have to question the design of an exception with error >> codes. That seems pretty poor design to me. Normally the exception >> *type* acts as equivalent to an error code.) > > Have a look at Pyt

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Mark Lawrence
On 29/03/2012 04:58, Ross Ridge wrote: Chris Angelico wrote: Actually, he is justified. It's one thing to work in C or assembly and write code that depends on certain bit-pattern representations of data (although even that causes trouble - assuming that sizeof(int)=3D=3Dsizeof(int*) isn't good

CFG for python

2012-03-28 Thread J. Mwebaze
Anyone knows how to create control-flow-graph for python.. After searching around, i found this article, http://www.python.org/dev/peps/pep-0339/#ast-to-cfg-to-bytecode and also a reference to http://doc.pypy.org/en/latest/objspace.html#the-flow-model However, i stil cant figure out what how to

Re: Re: Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Ross Ridge
Chris Angelico wrote: >Actually, he is justified. It's one thing to work in C or assembly and >write code that depends on certain bit-pattern representations of data >(although even that causes trouble - assuming that >sizeof(int)=3D=3Dsizeof(int*) isn't good for portability), but in a high >leve

Re: Re: Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Chris Angelico
On Thu, Mar 29, 2012 at 2:04 PM, Ross Ridge wrote: > Evan Driscoll   wrote: >>People like you -- who write to assumptions which are not even remotely >>guaranteed by the spec -- are part of the reason software sucks. > ... >>This email is a bit harsher than it deserves -- but I feel not by much. >

Re: Re: Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Ross Ridge
Evan Driscoll wrote: >People like you -- who write to assumptions which are not even remotely >guaranteed by the spec -- are part of the reason software sucks. ... >This email is a bit harsher than it deserves -- but I feel not by much. I don't see how you could feel the least bit justified. We

Re: unittest: assertRaises() with an instance instead of a type

2012-03-28 Thread Ben Finney
Steven D'Aprano writes: > (By the way, I have to question the design of an exception with error > codes. That seems pretty poor design to me. Normally the exception *type* > acts as equivalent to an error code.) Have a look at Python's built-in OSError. The various errors from the operating sy

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-28 Thread Chris Angelico
On Thu, Mar 29, 2012 at 11:59 AM, Rodrick Brown wrote: > The best skill any developer can have is the ability to pickup languages very > quickly and know what tools work well for which task. Definitely. Not just languages but all tools. The larger your toolkit and the better you know it, the mor

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-28 Thread Rodrick Brown
At my current firm we hire people who are efficient in one of the following and familiar with any another C#, Java, C++, Perl, Python or Ruby. We then expect developers to quickly pick up any of the following languages we use in house which is very broad. In our source repository not including t

Re: Re: Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Evan Driscoll
On 3/28/2012 14:43, Ross Ridge wrote: > Evan Driscoll wrote: >> So yes, you can say that pretending there's not a mapping of strings to >> internal representation is silly, because there is. However, there's >> nothing you can say about that mapping. > > I'm not the one labeling anything as be

Re: RE: Advise of programming one of my first programs

2012-03-28 Thread Chris Angelico
Thu, Mar 29, 2012 at 9:36 AM, Anatoli Hristov wrote: >> > > Um, at least by my understanding, the use of Pickle is also dangerous >> > > if you are not completely sure what is being passed in: >> > >> > Oh goodness yes. pickle is exactly as unsafe as eval is. Try running >> > this code: >> > >> >

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Steven D'Aprano
On Wed, 28 Mar 2012 15:43:31 -0400, Ross Ridge wrote: > I can in > fact say what the internal byte string representation of strings is any > given build of Python 3. Don't keep us in suspense! Given: Python 3.2.2 (default, Mar 4 2012, 10:50:33) [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-28 Thread Tim Delaney
On 25 March 2012 11:03, Tim Chase wrote: > On 03/24/12 17:08, Tim Delaney wrote: > >> Absolutely. 10 years ago (when I was just a young lad) I'd say that I'd >> *forgotten* at least 20 programming languages. That number has only >> increased. >> > > And in the case of COBOL for me, it wasn't just

Re: RE: Advise of programming one of my first programs

2012-03-28 Thread Anatoli Hristov
> > Um, at least by my understanding, the use of Pickle is also dangerous if > > you > > > are not completely sure what is being passed in: > > > > Oh goodness yes. pickle is exactly as unsafe as eval is. Try running this > > code: > > > > from pickle import loads > > loads("c__builtin__\neval\n(c_

Re: Advise of programming one of my first programs

2012-03-28 Thread Anatoli Hristov
> You are correct it is not. :) You code is overly complex making it harder > to understand. Try and reduce the problem to the least number of tasks you > need. > >From the Zen of Python, "Simple is better than complex." It is a good > programming > mentality. Complex is better than complicated.

Need Help Using list items as output table names in MsACCESS

2012-03-28 Thread Cathy James
Dear Python folks, I need your help on using list items as output table names in MsACCESS-new to Python- simple would be better: import arcpy, os outSpace = "c:\\data\\Info_Database.mdb\\" arcpy.overwriteOutput = True SQL = "Database Connections\\SDE_ReadOnly.sde\\" inFcList = [(SDE + "sde.GIS.Pa

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Terry Reedy
On 3/28/2012 1:43 PM, Peter Daum wrote: The longer story of my question is: I am new to python (obviously), and since I am not familiar with either one, I thought it would be advisory to go for python 3.x. I strongly agree with that unless you have reason to use 2.7. Python 3.3 (.0a1 in nearl

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Neil Cerutti
On 2012-03-28, Ross Ridge wrote: > Evan Driscoll wrote: >> So yes, you can say that pretending there's not a mapping of >> strings to internal representation is silly, because there is. >> However, there's nothing you can say about that mapping. > > I'm not the one labeling anything as being sil

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Mark Lawrence
On 28/03/2012 20:43, Ross Ridge wrote: Evan Driscoll wrote: So yes, you can say that pretending there's not a mapping of strings to internal representation is silly, because there is. However, there's nothing you can say about that mapping. I'm not the one labeling anything as being silly. I

Re: Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Ross Ridge
Evan Driscoll wrote: >So yes, you can say that pretending there's not a mapping of strings to >internal representation is silly, because there is. However, there's >nothing you can say about that mapping. I'm not the one labeling anything as being silly. I'm the one labeling the things as bul

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Grant Edwards
On 2012-03-28, Prasad, Ramit wrote: > >>You can't generally just "deal with the ascii portions" without >>knowing something about the encoding. Say you encounter a byte >>greater than 127. Is it a single non-ASCII character, or is it the >>leading byte of a multi-byte character? If the next ch

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread MRAB
On 28/03/2012 20:02, Prasad, Ramit wrote: >The right way to convert bytes to strings, and vice versa, is via >encoding and decoding operations. If you want to dictate to the original poster the correct way to do things then you don't need to do anything more that. You don't need to pretend

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Grant Edwards
On 2012-03-28, Steven D'Aprano wrote: > On Wed, 28 Mar 2012 19:43:36 +0200, Peter Daum wrote: > >> The longer story of my question is: I am new to python (obviously), and >> since I am not familiar with either one, I thought it would be advisory >> to go for python 3.x. The biggest problem that I

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread John Nagle
On 3/28/2012 10:43 AM, Peter Daum wrote: On 2012-03-28 12:42, Heiko Wundram wrote: Am 28.03.2012 11:43, schrieb Peter Daum: The longer story of my question is: I am new to python (obviously), and since I am not familiar with either one, I thought it would be advisory to go for python 3.x. The

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Ethan Furman
Prasad, Ramit wrote: You can read as bytes and decode as ASCII but ignoring the troublesome non-text characters: print(open('text.txt', 'br').read().decode('ascii', 'ignore')) Das fr ASCII nicht benutzte Bit kann auch fr Fehlerkorrekturzwecke (Parittsbit) auf den Kommunikationsleitungen oder f

RE: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Prasad, Ramit
> >The right way to convert bytes to strings, and vice versa, is via > >encoding and decoding operations. > > If you want to dictate to the original poster the correct way to do > things then you don't need to do anything more that. You don't need to > pretend like Chris Angelico that there's isn

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Albert W. Hopkins
On Wed, 2012-03-28 at 14:05 -0400, Ross Ridge wrote: > Ross Ridge wr= > > Of course it is. =A0Conceptually you're not supposed to think of it that > > way, but a string is stored in memory as a series of bytes. > > Chris Angelico wrote: > >Note that distinction. I said that a string "is not" a

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Ross Ridge
Tim Chase wrote: >Internally, they're a series of bytes, but they are MEANINGLESS >bytes unless you know how they are encoded internally. Those >bytes could be UTF-8, UTF-16, UTF-32, or any of a number of other >possible encodings[1]. If you get the internal byte stream, >there's no way to

Re: Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Evan Driscoll
On 01/-10/-28163 01:59 PM, Ross Ridge wrote: Steven D'Aprano wrote: The right way to convert bytes to strings, and vice versa, is via encoding and decoding operations. If you want to dictate to the original poster the correct way to do things then you don't need to do anything more that. You

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Tim Chase
On 03/28/12 13:05, Ross Ridge wrote: Ross Ridge wr= But a Python Unicode string might be stored in several ways; for all you know, it might actually be stored as a sequence of apples in a refrigerator, just as long as they can be referenced correctly. But it is in fact only stored in one part

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Ethan Furman
Peter Daum wrote: On 2012-03-28 12:42, Heiko Wundram wrote: Am 28.03.2012 11:43, schrieb Peter Daum: ... in my example, the variable s points to a "string", i.e. a series of bytes, (0x61,0x62 ...) interpreted as ascii/unicode characters. No; a string contains a series of codepoints from the un

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Ross Ridge
Steven D'Aprano wrote: >The right way to convert bytes to strings, and vice versa, is via >encoding and decoding operations. If you want to dictate to the original poster the correct way to do things then you don't need to do anything more that. You don't need to pretend like Chris Angelico th

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Steven D'Aprano
On Wed, 28 Mar 2012 19:43:36 +0200, Peter Daum wrote: > The longer story of my question is: I am new to python (obviously), and > since I am not familiar with either one, I thought it would be advisory > to go for python 3.x. The biggest problem that I am facing is, that I am > often dealing with

Re: unittest: assertRaises() with an instance instead of a type

2012-03-28 Thread Terry Reedy
On 3/28/2012 8:28 AM, Ulrich Eckhardt wrote: Hi! I'm currently writing some tests for the error handling of some code. In this scenario, I must make sure that both the correct exception is raised and that the contained error code is correct: try: foo() self.fail('exception not raised') catch M

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Terry Reedy
On 3/28/2012 11:36 AM, Ross Ridge wrote: Chris Angelico wrote: What is a string? It's not a series of bytes. Of course it is. Conceptually you're not supposed to think of it that way, but a string is stored in memory as a series of bytes. *If* it is stored in byte memory. If you execute

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Ian Kelly
On Wed, Mar 28, 2012 at 11:43 AM, Peter Daum wrote: > ... I was under the illusion, that python (like e.g. perl) stored > strings internally in utf-8. In this case the "conversion" would simple > mean to re-label the data. Unfortunately, as I meanwhile found out, this > is not the case (nor the "a

RE: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Prasad, Ramit
> You can read as bytes and decode as ASCII but ignoring the troublesome > non-text characters: > > >>> print(open('text.txt', 'br').read().decode('ascii', 'ignore')) > Das fr ASCII nicht benutzte Bit kann auch fr Fehlerkorrekturzwecke > (Parittsbit) auf den Kommunikationsleitungen oder fr andere

RE: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Prasad, Ramit
> As it seems, this would be far easier with python 2.x. With python 3 > and its strict distinction between "str" and "bytes", things gets > syntactically pretty awkward and error-prone (something as innocently > looking like "s=s+'/'" hidden in a rarely reached branch and a > seemingly correct pro

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Jussi Piitulainen
Peter Daum writes: > ... I was under the illusion, that python (like e.g. perl) stored > strings internally in utf-8. In this case the "conversion" would simple > mean to re-label the data. Unfortunately, as I meanwhile found out, this > is not the case (nor the "apple encoding" ;-), so it would i

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Steven D'Aprano
On Wed, 28 Mar 2012 11:43:52 +0200, Peter Daum wrote: > ... in my example, the variable s points to a "string", i.e. a series of > bytes, (0x61,0x62 ...) interpreted as ascii/unicode characters. No. Strings are not sequences of bytes (except in the trivial sense that everything in computer memor

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Ross Ridge
Ross Ridge wr= > Of course it is. =A0Conceptually you're not supposed to think of it that > way, but a string is stored in memory as a series of bytes. Chris Angelico wrote: >Note that distinction. I said that a string "is not" a series of >bytes; you say that it "is stored" as bytes. The dist

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Heiko Wundram
Am 28.03.2012 19:43, schrieb Peter Daum: As it seems, this would be far easier with python 2.x. With python 3 and its strict distinction between "str" and "bytes", things gets syntactically pretty awkward and error-prone (something as innocently looking like "s=s+'/'" hidden in a rarely reached b

Re: unittest: assertRaises() with an instance instead of a type

2012-03-28 Thread Steven D'Aprano
On Wed, 28 Mar 2012 14:28:08 +0200, Ulrich Eckhardt wrote: > Hi! > > I'm currently writing some tests for the error handling of some code. In > this scenario, I must make sure that both the correct exception is > raised and that the contained error code is correct: > > >try: >foo()

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Steven D'Aprano
On Wed, 28 Mar 2012 11:36:10 -0400, Ross Ridge wrote: > Chris Angelico wrote: >>What is a string? It's not a series of bytes. > > Of course it is. Conceptually you're not supposed to think of it that > way, but a string is stored in memory as a series of bytes. You don't know that. They might

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Peter Daum
On 2012-03-28 12:42, Heiko Wundram wrote: > Am 28.03.2012 11:43, schrieb Peter Daum: >> ... in my example, the variable s points to a "string", i.e. a series of >> bytes, (0x61,0x62 ...) interpreted as ascii/unicode characters. > > No; a string contains a series of codepoints from the unicode plan

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Dave Angel
On 03/28/2012 04:56 AM, Peter Daum wrote: Hi, is there any way to convert a string to bytes without interpreting the data in any way? Something like: s='abcde' b=bytes(s, "unchanged") Regards, Peter You needed to specify that you are using Python 3.x . In pyt

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Grant Edwards
On 2012-03-28, Chris Angelico wrote: > for all you know, it might actually be stored as a sequence of > apples in a refrigerator [...] > There's no logical Python way to turn that into a series of bytes. There's got to be a joke there somewhere about how to eat an apple... -- Grant Edwards

ResponseNotReady in httplib

2012-03-28 Thread Manu
Hi I try to access a web site and it returns me this exception "ResponseNotReady" . I don't know what is the root of the problem and how to sort it out. I am using the excellent python requests library to access the web site but it relies on httplib utlimately. Could someone one explains me th

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Chris Angelico
On Thu, Mar 29, 2012 at 2:36 AM, Ross Ridge wrote: > Chris Angelico   wrote: >>What is a string? It's not a series of bytes. > > Of course it is.  Conceptually you're not supposed to think of it that > way, but a string is stored in memory as a series of bytes. Note that distinction. I said that

Re: Tools for refactoring/obfuscation

2012-03-28 Thread Javier
Yes, in general I follow clear guidelines for writing code. I just use modules with functions in the same directory and clear use of name spaces. I almost never use classes. I wonder if you use some tool for refactoring. I am mainly intersted in scripting tools, no eclipse-style guis. Just let

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Ross Ridge
Chris Angelico wrote: >What is a string? It's not a series of bytes. Of course it is. Conceptually you're not supposed to think of it that way, but a string is stored in memory as a series of bytes. What he's asking for many not be very useful or practical, but if that's your problem here than

Re: errors building python 2.7.3

2012-03-28 Thread David Robinow
On Wed, Mar 28, 2012 at 7:50 AM, Alexey Luchko wrote: > I've tried to build Python 2.7.3rc2 on cygwin and got the following errors: > > $ CFLAGS=-I/usr/include/ncursesw/ CPPFLAGS=-I/usr/include/ncursesw/ > ./configure I haven't tried 2.7.3 yet, so I'll describe my experience with 2.7.2 I use /us

Re: errors building python 2.7.3

2012-03-28 Thread Colton Myers
> > Reporting here, because bugs.python.org refuses connections currently. > bugs.python.org seems to be back up, I'd repost there if you haven't already. -- Colton Myers -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about collections.defaultdict

2012-03-28 Thread Steven W. Orr
On 3/26/2012 11:52 AM, Robert Kern wrote: On 3/26/12 4:33 PM, Steven W. Orr wrote: On 3/26/2012 9:44 AM, Robert Kern wrote: On 3/26/12 2:33 PM, Steven W. Orr wrote: I created a new class called CaseInsensitiveDict (by stealing from code I found on the web, thank you very much). The new class i

RE: RE: Advise of programming one of my first programs

2012-03-28 Thread Prasad, Ramit
> >> The use of eval is dangerous if you are not *completely* sure what is > >> being passed in. Try using pickle instead: > >> http://docs.python.org/release/2.5.2/lib/pickle-example.html > > > > > > Um, at least by my understanding, the use of Pickle is also dangerous if > you > > are not complet

Re: errors building python 2.7.3

2012-03-28 Thread Alexey Luchko
On 28.03.2012 14:50, Alexey Luchko wrote: Hi! I've tried to build Python 2.7.3rc2 on cygwin and got the following errors: $ CFLAGS=-I/usr/include/ncursesw/ CPPFLAGS=-I/usr/include/ncursesw/ ./configure $ make ... gcc -shared -Wl,--enable-auto-image-base build/temp.cygwin-1.7.11-i686-2.7/Python-

Work

2012-03-28 Thread Alicja Krzyżanowska
Hello My name is Alicja Krzyżanowska and I represent Software Press company We are creating a New version of popular magazine PHP Solution (English version), which will be available online. We are looking for a specialist in Python, who will be interested in writing some articles in this subject.

Re: Difference between json.load() and json.loads() [From: RE: question about file handling with "with"]

2012-03-28 Thread Nadir Sampaoli
2012/3/28 ian douglas > > The functions with an s take string parameters. The others take file > streams. > > foo = '{"age": 38}' > my_json = json.loads(foo) > I see, it makes perfectly sense now. Thanks for clearing it up. -- http://mail.python.org/mailman/listinfo/python-list

Re: python segfault

2012-03-28 Thread Kiuhnm
On 3/28/2012 8:16, Michael Poeltl wrote: yeah - of course 'while True' was the first, most obvious best way... ;-) but I was asked if there was a way without 'while True' and so I started the 'recursive function' and quick quick; RuntimeError-Exception -> not thinking much -> just adding two z

Re: Difference between json.load() and json.loads() [From: RE: question about file handling with "with"]

2012-03-28 Thread ian douglas
On Mar 28, 2012 6:54 AM, "Nadir Sampaoli" wrote: > > Hello everyone (my first message in the mailing list), > >> >> > Is the following function correct? >> Yes, though I'd use json.load(f) instead of json.loads(). > > > The docs aren't very clear (at least for me) about the difference between json

Difference between json.load() and json.loads() [From: RE: question about file handling with "with"]

2012-03-28 Thread Nadir Sampaoli
Hello everyone (my first message in the mailing list), > > Is the following function correct? > Yes, though I'd use json.load(f) instead of json.loads(). > The docs aren't very clear (at least for me) about the difference between json.load()

unittest: assertRaises() with an instance instead of a type

2012-03-28 Thread Ulrich Eckhardt
Hi! I'm currently writing some tests for the error handling of some code. In this scenario, I must make sure that both the correct exception is raised and that the contained error code is correct: try: foo() self.fail('exception not raised') catch MyException as e: self

errors building python 2.7.3

2012-03-28 Thread Alexey Luchko
Hi! I've tried to build Python 2.7.3rc2 on cygwin and got the following errors: $ CFLAGS=-I/usr/include/ncursesw/ CPPFLAGS=-I/usr/include/ncursesw/ ./configure $ make ... gcc -shared -Wl,--enable-auto-image-base build/temp.cygwin-1.7.11-i686-2.7/Python-2.7.3rc2/Modules/_io/bufferedio.o build/t

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Stefan Behnel
Peter Daum, 28.03.2012 11:43: > What I am looking for is a general way to just copy the raw data > from a "string" object to a "byte" object without any attempt to > "decode" or "encode" anything ... That's why I asked about your use case - where does the data come from and why is it contained in

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Heiko Wundram
Am 28.03.2012 11:43, schrieb Peter Daum: ... in my example, the variable s points to a "string", i.e. a series of bytes, (0x61,0x62 ...) interpreted as ascii/unicode characters. No; a string contains a series of codepoints from the unicode plane, representing natural language characters (at l

Re: question about file handling with "with"

2012-03-28 Thread Peter Otten
Jabba Laci wrote: > Is the following function correct? Yes, though I'd use json.load(f) instead of json.loads(). > Is the input file closed in order? > > def read_data_file(self): > with open(self.data_file) as f: > return json.loads(f.read()) The file will be closed when the wit

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Peter Daum
On 2012-03-28 11:02, Chris Angelico wrote: > On Wed, Mar 28, 2012 at 7:56 PM, Peter Daum wrote: >> is there any way to convert a string to bytes without >> interpreting the data in any way? Something like: >> >> s='abcde' >> b=bytes(s, "unchanged") > > What is a string? It's not a series of bytes

question about file handling with "with"

2012-03-28 Thread Jabba Laci
Hi, Is the following function correct? Is the input file closed in order? def read_data_file(self): with open(self.data_file) as f: return json.loads(f.read()) Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Stefan Behnel
Peter Daum, 28.03.2012 10:56: > is there any way to convert a string to bytes without > interpreting the data in any way? Something like: > > s='abcde' > b=bytes(s, "unchanged") If you can tell us what you actually want to achieve, i.e. why you want to do this, we may be able to tell you how to d

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Chris Angelico
On Wed, Mar 28, 2012 at 7:56 PM, Peter Daum wrote: > Hi, > > is there any way to convert a string to bytes without > interpreting the data in any way? Something like: > > s='abcde' > b=bytes(s, "unchanged") What is a string? It's not a series of bytes. You can't convert it without encoding those

"convert" string to bytes without changing data (encoding)

2012-03-28 Thread Peter Daum
Hi, is there any way to convert a string to bytes without interpreting the data in any way? Something like: s='abcde' b=bytes(s, "unchanged") Regards, Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to create warning for obsolete functions and call new one

2012-03-28 Thread Gelonida N
Hi Chris, On 03/26/2012 11:50 PM, Chris Angelico wrote: > On Tue, Mar 27, 2012 at 7:26 AM, Gelonida N wrote: >> One option I though of would be: >> >> def obsolete_func(func): >>def call_old(*args, **kwargs): >>print "func is old psl use new one" >>return func(*args, **kwargs)

Re: OAuth 2.0 implementation

2012-03-28 Thread Mark Hammond
On 28/03/2012 1:18 AM, Roy Smith wrote: In article <7909491.0.1332826232743.JavaMail.geo-discussion-forums@pbim5>, Demian Brecht wrote: OAuth 2.0 is still in draft status (draft 25 is the current one I believe) and yes, unfortunately every single server available at this point have varying d

Re: best way to create warning for obsolete functions and call new one

2012-03-28 Thread Gelonida N
Hi Dan, On 03/26/2012 11:24 PM, Dan Sommers wrote: > On Mon, 26 Mar 2012 22:26:11 +0200 > Gelonida N wrote: > >> As these modules are used by quite some projects and as I do not want >> to force everybody to rename immediately I just want to warn users, >> that they call functions, that have bee