Re: Guessing the encoding from a BOM

2014-01-15 Thread Ethan Furman
On 01/15/2014 10:55 PM, Steven D'Aprano wrote: On Thu, 16 Jan 2014 14:47:00 +1100, Ben Finney wrote: +1. I'd like a custom exception class, sub-classed from ValueError. Why ValueError? It's not really a "invalid value" error, it's more "my heuristic isn't good enough" failure. (Maybe the file

Re: Is it possible to get string from function?

2014-01-15 Thread Steven D'Aprano
On Wed, 15 Jan 2014 22:46:54 -0500, Roy Smith wrote: > I've got some unit tests that look like: > > class Foo(TestCase): > def test_t1(self): > RECEIPT = "some string" > > def test_t2(self): > RECEIPT = "some other string" > > def test_t3(self): > RECEIPT = "yet a third string

Re: data validation when creating an object

2014-01-15 Thread Cameron Simpson
On 16Jan2014 15:53, Ben Finney wrote: > Roy Smith writes: > > Ben Finney wrote: > > > Who says it's frowned on to do work in the initialiser? Where are they > > > saying it? That seems over-broad, I'd like to read the context of that > > > advice. > > > > There are some people who advocate that

Re: Guessing the encoding from a BOM

2014-01-15 Thread Steven D'Aprano
On Thu, 16 Jan 2014 14:47:00 +1100, Ben Finney wrote: > Steven D'Aprano writes: > >> enc = guess_encoding_from_bom("filename") if enc == something: >> # Can't guess, fall back on an alternative strategy ... >> else: >> f = open("filename", encoding=enc) >> >> >> If I forget to check th

Re: Guessing the encoding from a BOM

2014-01-15 Thread Steven D'Aprano
On Thu, 16 Jan 2014 16:01:56 +1100, Chris Angelico wrote: > On Thu, Jan 16, 2014 at 1:13 PM, Steven D'Aprano > wrote: >> if sig.startswith((b'\xFE\xFF', b'\xFF\xFE')): >> return 'utf_16' >> elif sig.startswith((b'\x00\x00\xFE\xFF', b'\xFF\xFE\x00\x00')): >> return 'utf_32'

Re: Chanelling Guido - dict subclasses

2014-01-15 Thread Devin Jeanpierre
On Wed, Jan 15, 2014 at 8:51 AM, John Ladasky wrote: > On Wednesday, January 15, 2014 12:40:33 AM UTC-8, Peter Otten wrote: >> Personally I feel dirty whenever I write Python code that defeats duck- >> typing -- so I would not /recommend/ any isinstance() check. > > While I am inclined to agree, I

Re: data validation when creating an object

2014-01-15 Thread Cameron Simpson
On 16Jan2014 12:46, Chris Angelico wrote: > On Thu, Jan 16, 2014 at 12:25 PM, Cameron Simpson wrote: > > However, I would also have obvious validity checks in __init__ > > itself on the supplied values. Eg: > > > > def __init__(self, size, lifetime): > > if size < 1: > > raise ValueEr

Re: Is it possible to get string from function?

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 4:40 PM, Roy Smith wrote: >> But you might be able to shortcut it enormously. You say the strings >> are "about 2500 characters long, hex-encoded". What are the chances of >> having another constant, somewhere in the test function, that also >> happens to be roughly that lo

Re: Is it possible to get string from function?

2014-01-15 Thread Roy Smith
In article , Chris Angelico wrote: > On Thu, Jan 16, 2014 at 2:46 PM, Roy Smith wrote: > > So, I figured I would write a meta-test, which used introspection to > > find all the methods in the class, extract the strings from them (they > > are all assigned to a variable named RECEIPT), and check

Re: Guessing the encoding from a BOM

2014-01-15 Thread Ethan Furman
On 01/15/2014 07:47 PM, Ben Finney wrote: Steven D'Aprano writes: (4) Don't return anything, but raise an exception. (But which exception?) +1. I'd like a custom exception class, sub-classed from ValueError. +1 -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-lis

Re: Is it possible to get string from function?

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 2:46 PM, Roy Smith wrote: > So, I figured I would write a meta-test, which used introspection to > find all the methods in the class, extract the strings from them (they > are all assigned to a variable named RECEIPT), and check to make sure > they're all different. In the

Re: Dynamic generation of test cases for each input datum (was: Is it possible to get string from function?)

2014-01-15 Thread Roy Smith
In article , Ben Finney wrote: > Roy Smith writes: > > > I've got some unit tests that look like: > > > > class Foo(TestCase): > > def test_t1(self): > > RECEIPT = "some string" > > > > def test_t2(self): > > RECEIPT = "some other string" > > > > def test_t3(self): > > RECEIP

Re: data validation when creating an object

2014-01-15 Thread Roy Smith
In article , Ben Finney wrote: > Roy Smith writes: > > But, Python is not C++. I suspect the people who argue for __init__() > > not doing much are extrapolating a C++ pattern to other languages > > without fully understanding the reason why. > > Even simpler: They are mistaken in what the con

Dynamic generation of test cases for each input datum (was: Is it possible to get string from function?)

2014-01-15 Thread Ben Finney
Roy Smith writes: > I've got some unit tests that look like: > > class Foo(TestCase): > def test_t1(self): > RECEIPT = "some string" > > def test_t2(self): > RECEIPT = "some other string" > > def test_t3(self): > RECEIPT = "yet a third string" > > and so on. That looks like a p

Re: Guessing the encoding from a BOM

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 1:13 PM, Steven D'Aprano wrote: > if sig.startswith((b'\xFE\xFF', b'\xFF\xFE')): > return 'utf_16' > elif sig.startswith((b'\x00\x00\xFE\xFF', b'\xFF\xFE\x00\x00')): > return 'utf_32' I'd swap the order of these two checks. If the file starts FF FE

Re: data validation when creating an object

2014-01-15 Thread Ben Finney
Roy Smith writes: > Ben Finney wrote: > > > Who says it's frowned on to do work in the initialiser? Where are they > > saying it? That seems over-broad, I'd like to read the context of that > > advice. > > There are some people who advocate that C++ constructors should not do > a lot of work an

Re: Chanelling Guido - dict subclasses

2014-01-15 Thread Gregory Ewing
Daniel da Silva wrote: Just to be pedantic, this /is/ a violation of the Liskov Substution Principle. According to Wikipedia, the principle states: if S is a subtype of T, then objects of type T may be

Re: data validation when creating an object

2014-01-15 Thread Roy Smith
Rita writes: >> I know its frowned upon to do work in the __init__() method and only >> declarations should be there. In article , Ben Finney wrote: > Who says it's frowned on to do work in the initialiser? Where are they > saying it? That seems over-broad, I'd like to read the context of tha

Re: Question about object lifetime and access

2014-01-15 Thread Asaf Las
First of all many thanks to all for their detailed answers on subject. I really appreciate it! > Correct. The global name is a reference, so the reference count will be > > at least 1. In fact, referencing the name from a function or method > doesn't increase the ref count: > -- > > Steven

Is it possible to get string from function?

2014-01-15 Thread Roy Smith
I realize the subject line is kind of meaningless, so let me explain :-) I've got some unit tests that look like: class Foo(TestCase): def test_t1(self): RECEIPT = "some string" def test_t2(self): RECEIPT = "some other string" def test_t3(self): RECEIPT = "yet a third string"

Re: Guessing the encoding from a BOM

2014-01-15 Thread Ben Finney
Steven D'Aprano writes: > enc = guess_encoding_from_bom("filename") > if enc == something: > # Can't guess, fall back on an alternative strategy > ... > else: > f = open("filename", encoding=enc) > > > If I forget to check the returned result, I should get an explicit > failure as

Re: data validation when creating an object

2014-01-15 Thread Terry Reedy
On 1/15/2014 8:09 PM, Rita wrote: I know its frowned upon to do work in the __init__() method and only declarations should be there. Dear Python beginners: Don't believe the Python rules people write unless it is by one of the core developers or one of the other experts posting here. Even th

Re: Python declarative

2014-01-15 Thread Terry Reedy
On 1/15/2014 6:09 PM, Chris Angelico wrote: On Thu, Jan 16, 2014 at 9:58 AM, Terry Reedy wrote: class Window: def __init__(self, title, *kwds) # or title='Window title' self.title = title self.__dict__.update(kwds) Does that want a second asterisk, matching the Button

Re: data validation when creating an object

2014-01-15 Thread Rita
Unfortunately, I couldn't find the reference but I know I read it somewhere. Even with a selective search I wasn't able to find it. I think I read it in context of module/class test case writing. I will keep your responses in mind therefore I will put logic in __init__ for data validation. than

Re: Chanelling Guido - dict subclasses

2014-01-15 Thread Daniel da Silva
On Tue, Jan 14, 2014 at 8:27 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > > But reading Guido, I think he's saying that wouldn't be a good idea. I > don't get it -- it's not a violation of the Liskov Substitution > Principle, because it's more restrictive, not less. What am

Guessing the encoding from a BOM

2014-01-15 Thread Steven D'Aprano
I have a function which guesses the likely encoding used by text files by reading the BOM (byte order mark) at the beginning of the file. A simplified version: def guess_encoding_from_bom(filename, default): with open(filename, 'rb') as f: sig = f.read(4) if sig.startswith((b'\x

Re: data validation when creating an object

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 12:25 PM, Cameron Simpson wrote: > However, I would also have obvious validity checks in __init__ > itself on the supplied values. Eg: > > def __init__(self, size, lifetime): > if size < 1: > raise ValueError("size must be >= 1, received: %r" % (size,)) > if

Re: Bind event is giving me a bug.

2014-01-15 Thread Terry Reedy
On 1/15/2014 3:16 PM, eneskri...@gmail.com wrote: While working with tkinter in python 3.3, I had the following problem. Please paste working code that people can experiment with. from tkinter import * def get_text(event): If this were a method, (which the indent of the body suggests it on

Re: Python declarative

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 11:48 AM, Tim Chase wrote: > On 2014-01-16 10:09, Chris Angelico wrote: >> myWindow = Window( >> title="Hello World", >> children=[Button( >> label="I'm a button", >> onClick=exit >> )] >> ) > > This also solves the problem that **kwargs are

Re: data validation when creating an object

2014-01-15 Thread Mark Lawrence
On 16/01/2014 01:09, Rita wrote: I would like to do some data validation when its going to a class. class Foo(object): def __init__(self): pass I know its frowned upon to do work in the __init__() method and only declarations should be there. In the 10+ years that I've been using Pyth

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 11:43 AM, Steven D'Aprano wrote: > Worse, linguists sometimes disagree as to what counts as a grapheme. For > instance, some authorities consider the English "sh" to be a separate > grapheme. As a native English speaker, I'm not sure about that. Certainly > it isn't a separ

Re: data validation when creating an object

2014-01-15 Thread Cameron Simpson
On 15Jan2014 20:09, Rita wrote: > I would like to do some data validation when its going to a class. > > class Foo(object): > def __init__(self): > pass > > I know its frowned upon to do work in the __init__() method and only > declarations should be there. This rule of thumb does not mea

Re: data validation when creating an object

2014-01-15 Thread Ben Finney
Rita writes: > I would like to do some data validation when its going to a class. > > class Foo(object): > def __init__(self): > pass > > I know its frowned upon to do work in the __init__() method and only > declarations should be there. Who says it's frowned on to do work in the initiali

data validation when creating an object

2014-01-15 Thread Rita
I would like to do some data validation when its going to a class. class Foo(object): def __init__(self): pass I know its frowned upon to do work in the __init__() method and only declarations should be there. So, should i create a function called validateData(self) inside foo? I would ca

Re: python-list@python.org

2014-01-15 Thread Ben Finney
Steven D'Aprano writes: > On Wed, 15 Jan 2014 02:25:34 +0100, Florian Lindner wrote: > >> On 2014-01-14 16:37, Florian Lindner wrote: > >> > I'm using python 3.2.3 on debian wheezy. My script is called from > >> > my mail delivery agent (MDA) maildrop (like procmail) through > >> > it's xfilter d

Re: Python declarative

2014-01-15 Thread Tim Chase
On 2014-01-16 10:09, Chris Angelico wrote: > myWindow = Window( > title="Hello World", > children=[Button( > label="I'm a button", > onClick=exit > )] > ) This also solves the problem that **kwargs are just a dict, which is inherently unordered. So with the previo

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread Steven D'Aprano
On Wed, 15 Jan 2014 12:00:51 +, Robin Becker wrote: > so two 'characters' are 3 (or 2 or more) codepoints. Yes. > If I want to isolate so called graphemes I need an algorithm even > for python's unicode Correct. Graphemes are language dependent, e.g. in Dutch "ij" is usually a single gra

Re: python-list@python.org

2014-01-15 Thread Steven D'Aprano
On Wed, 15 Jan 2014 02:25:34 +0100, Florian Lindner wrote: > Am Dienstag, 14. Januar 2014, 17:00:48 schrieb MRAB: >> On 2014-01-14 16:37, Florian Lindner wrote: >> > Hello! >> > >> > I'm using python 3.2.3 on debian wheezy. My script is called from my >> > mail delivery agent (MDA) maildrop (like

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread Steven D'Aprano
On Thu, 16 Jan 2014 02:14:38 +1100, Chris Angelico wrote: > On Thu, Jan 16, 2014 at 1:55 AM, wrote: >> Le mercredi 15 janvier 2014 13:13:36 UTC+1, Ned Batchelder a écrit : >> >> >>> ... more than one codepoint makes up a grapheme ... >> >> No > > Yes. > http://www.unicode.org/faq/char_combmark

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread Terry Reedy
On 1/15/2014 11:55 AM, Robin Becker wrote: The fact that unicoders want to take over the meaning of encoding is not relevant. I agree with you that 'encoding' should not be limited to 'byte encoding of a (subset of) unicode characters. For instance, .jpg and .png are byte encodings of images

Re: Question about object lifetime and access

2014-01-15 Thread Steven D'Aprano
On Wed, 15 Jan 2014 05:14:59 -0800, Asaf Las wrote: > I have read somewhere that global objects are referenced from module > namespace will never have reference count down to 0 even if they are not > referenced from functions or class methods. Is this true? Correct. The global name is a referenc

Re: Python declarative

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 9:58 AM, Terry Reedy wrote: > class Window: > def __init__(self, title, *kwds) # or title='Window title' > self.title = title > self.__dict__.update(kwds) Does that want a second asterisk, matching the Button definition? >> Possible, but potentially m

Re: Python declarative

2014-01-15 Thread Terry Reedy
On 1/15/2014 12:33 PM, Chris Angelico wrote: On Thu, Jan 16, 2014 at 4:02 AM, Sergio Tortosa Benedito wrote: Hi I'm developing a sort of language extension for writing GUI programs called guilang, right now it's written in Lua but I'm considreing Python instead (because it's more tailored to al

Re: proposal: bring nonlocal to py2.x

2014-01-15 Thread Terry Reedy
On 1/15/2014 7:07 AM, Robin Becker wrote: On 13/01/2014 15:28, Chris Angelico wrote: .. It's even worse than that, because adding 'nonlocal' is not a bugfix. So to be committed to the repo, it has to be approved for either 2.7 branch (which is in bugfix-only maintenance mode) or 2.8 bra

Re: Chanelling Guido - dict subclasses

2014-01-15 Thread Cameron Simpson
On 15Jan2014 05:03, Tim Chase wrote: > On 2014-01-15 01:27, Steven D'Aprano wrote: > > class TextOnlyDict(dict): > > def __setitem__(self, key, value): > > if not isinstance(key, str): > > raise TypeError > > super().__setitem__(key, value) > > # need to overrid

Re: Bind event is giving me a bug.

2014-01-15 Thread Peter Otten
MRAB wrote: > This will make it call 'get_text' when the button is clicked: > >> Button(root, text = "Submit", command = get_text).pack() ...and then produce a TypeError because of the missing `event` argument. To avoid that you can provide a default with def get_text(event=None): ... --

Re: Bind event is giving me a bug.

2014-01-15 Thread eneskristo
Thank you, I thought Enter was Enter, but I still have this problem, when I press the Button, this appears: Exception in Tkinter callback Traceback (most recent call last): File "C:\Python33\lib\tkinter\__init__.py", line 1475, in __call__ return self.func(*args) TypeError: get_text() missin

Re: Bind event is giving me a bug.

2014-01-15 Thread MRAB
On 2014-01-15 20:16, eneskri...@gmail.com wrote: While working with tkinter in python 3.3, I had the following problem. def get_text(event): self.number_of_competitors = entered_text.get() try: self.number_of_competitors = int(self.number_of_competitors)

Re: Python Scalability TCP Server + Background Game

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 5:37 AM, wrote: > 3) The game server has a player limit of 5. My requirement/desire is to > be able to serve 50k requests per second (without any caching layer, although > the game server will cache data), so people don't get a poor user experience > during high pea

Re: Bind event is giving me a bug.

2014-01-15 Thread Peter Otten
eneskri...@gmail.com wrote: > While working with tkinter in python 3.3, I had the following problem. > root = Tk() > label = Label(root, text = "Enter the number of competitors.") > label.pack(side = TOP) > entered_text = Entry(root) > entered_text.pack() > Button(root, text = "Submit", command =

Re: Learning python networking

2014-01-15 Thread William Ray Wing
On Jan 15, 2014, at 7:52 AM, Chris Angelico wrote: [megabyte] > One of the fundamentals of the internet is that connections *will* > break. A friend of mine introduced me to Magic: The Gathering via a > program that couldn't handle drop-outs, and it got extremely > frustrating - we couldn't get

Bind event is giving me a bug.

2014-01-15 Thread eneskristo
While working with tkinter in python 3.3, I had the following problem. def get_text(event): self.number_of_competitors = entered_text.get() try: self.number_of_competitors = int(self.number_of_competitors) except: pass

Python Scalability TCP Server + Background Game

2014-01-15 Thread phiwer
My problem is as follows: I'm developing an online game with the requirement of being able to handle thousands of requests every second. The frontend consists of web server(s) exposing a rest api. These web servers in turn communicate with a game server over TCP. When a message arrives at the

Re: Chanelling Guido - dict subclasses

2014-01-15 Thread Peter Otten
John Ladasky wrote: > On Wednesday, January 15, 2014 12:40:33 AM UTC-8, Peter Otten wrote: >> Personally I feel dirty whenever I write Python code that defeats duck- >> typing -- so I would not /recommend/ any isinstance() check. > > While I am inclined to agree, I have yet to see a solution to t

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread Ian Kelly
On Wed, Jan 15, 2014 at 9:55 AM, Robin Becker wrote: > The fact that unicoders want to take over the meaning of encoding is not > relevant. A virus is a small infectious agent that replicates only inside the living cells of other organisms. In the context of computing however, that definition is

Re: Communicate between Python and Node.js

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 4:12 AM, Manish wrote: > At first I thought to use the requests library to GET/POST data to node, but > I googled around and it seems lots of people think TCP sockets are the way to > go. I tried implementing my own using several examples I have found online. > It *kind

Re: Python 3.x adoption

2014-01-15 Thread Christopher Welborn
On 01/14/2014 01:33 PM, Staszek wrote: Hi What's the problem with Python 3.x? It was first released in 2008, but web hosting companies still seem to offer Python 2.x rather. For example, Google App Engine only offers Python 2.7. What's wrong?... My last two hosts have offered multiple versi

Re: Python declarative

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 4:02 AM, Sergio Tortosa Benedito wrote: > Hi I'm developing a sort of language extension for writing GUI programs > called guilang, right now it's written in Lua but I'm considreing Python > instead (because it's more tailored to alone applications). My question > it's if I

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread Robin Becker
On 15/01/2014 17:14, Chris Angelico wrote: On Thu, Jan 16, 2014 at 3:55 AM, Robin Becker wrote: I think about these as encodings, because that's what they are mathematically, logically & practically. I can encode the target grapheme sequence as a sequence of bytes using a particular 'unicode en

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 3:55 AM, Robin Becker wrote: > I think about these as encodings, because that's what they are > mathematically, logically & practically. I can encode the target grapheme > sequence as a sequence of bytes using a particular 'unicode encoding' eg > utf8 or a sequence of code

Communicate between Python and Node.js

2014-01-15 Thread Manish
I've been tasked to write a module that sends data from Django to a Node.js server running on the same machine. Some magic happens in node and I recv the results back, which are then rendered using Django templates. At first I thought to use the requests library to GET/POST data to node, but I

Python declarative

2014-01-15 Thread Sergio Tortosa Benedito
Hi I'm developing a sort of language extension for writing GUI programs called guilang, right now it's written in Lua but I'm considreing Python instead (because it's more tailored to alone applications). My question it's if I can achieve this declarative-thing in python. Here's an example: Window

Re: Learning python networking

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 3:43 AM, William Ray Wing wrote: > I was assuming another user picking up the connection using sniffed > credentials (and yes, despite all the work on ssh, not all man-in-the-middle > attacks have been killed). If that can happen, then I would much prefer that it kick my

Re: Python 3.x adoption

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 3:46 AM, Mark Lawrence wrote: > On 15/01/2014 16:14, Chris Angelico wrote: >> >> On Thu, Jan 16, 2014 at 2:43 AM, Travis Griggs >> wrote: >>> >>> Personally, I wish they’d start python4, sure would take the heat out of >>> the 3 vs 2 debates. And maybe there’d be a program

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread Robin Becker
On 15/01/2014 16:28, Travis Griggs wrote: of a sequence of graphemes I can use either a sequence of bytes or a sequence of codepoints. They are both encodings of the graphemes; what unicode says is an encoding doesn't define what encodings are ie mappings from some source alphabet to a

Re: Chanelling Guido - dict subclasses

2014-01-15 Thread John Ladasky
On Wednesday, January 15, 2014 12:40:33 AM UTC-8, Peter Otten wrote: > Personally I feel dirty whenever I write Python code that defeats duck- > typing -- so I would not /recommend/ any isinstance() check. While I am inclined to agree, I have yet to see a solution to the problem of flattening nes

Re: Python 3.x adoption

2014-01-15 Thread Mark Lawrence
On 15/01/2014 16:14, Chris Angelico wrote: On Thu, Jan 16, 2014 at 2:43 AM, Travis Griggs wrote: Personally, I wish they’d start python4, sure would take the heat out of the 3 vs 2 debates. And maybe there’d be a program called twentyfour as a result. Learn All Current Versions of Python in

Re: Learning python networking

2014-01-15 Thread William Ray Wing
On Jan 15, 2014, at 11:31 AM, Chris Angelico wrote: > On Thu, Jan 16, 2014 at 3:25 AM, William Ray Wing wrote: >> On Jan 15, 2014, at 7:52 AM, Chris Angelico wrote: >>> One of the fundamentals of the internet is that connections *will* >>> break. A friend of mine introduced me to Magic: The Gat

Re: Learning python networking

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 3:31 AM, Chris Angelico wrote: > I'm assuming an authentication system > that stipulates one single active connection per authenticated user Incidentally, in an environment where everything's trusted (LAN or localhost), the "authentication system" can be as simple as "type

Re: Learning python networking

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 3:25 AM, William Ray Wing wrote: > On Jan 15, 2014, at 7:52 AM, Chris Angelico wrote: >> One of the fundamentals of the internet is that connections *will* >> break. A friend of mine introduced me to Magic: The Gathering via a >> program that couldn't handle drop-outs, and

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread Travis Griggs
On Jan 15, 2014, at 4:50 AM, Robin Becker wrote: > On 15/01/2014 12:13, Ned Batchelder wrote: > >>> On my utf8 based system >>> >>> robin@everest ~: $ cat ooo.py if __name__=='__main__': import sys s='A̅B' print('version_info=%s\nlen(%s)=%d' % (s

Re: Python 3.x adoption

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 2:43 AM, Travis Griggs wrote: > Personally, I wish they’d start python4, sure would take the heat out of the > 3 vs 2 debates. And maybe there’d be a program called twentyfour as a result. Learn All Current Versions of Python in Twenty-Four Hours? ChrisA -- https://mail

Re: Python 3.x adoption

2014-01-15 Thread Travis Griggs
Here we go again… On Jan 14, 2014, at 11:33 AM, Staszek wrote: > Hi > > What's the problem with Python 3.x? It was first released in 2008, but > web hosting companies still seem to offer Python 2.x rather. > > For example, Google App Engine only offers Python 2.7. > > What's wrong?... Maybe

Re: Learning python networking

2014-01-15 Thread Chris Angelico
On Wed, Jan 15, 2014 at 11:52 PM, Chris Angelico wrote: > One of the fundamentals of the internet is that connections *will* > break. A friend of mine introduced me to Magic: The Gathering via a > program that couldn't handle drop-outs, and it got extremely > frustrating - we couldn't get a game g

Re: setup.py issue - some files are included as intended, but one is not

2014-01-15 Thread Piet van Oostrum
Dan Stromberg writes: > On Sat, Jan 11, 2014 at 2:04 PM, Dan Stromberg wrote: >> Hi folks. >> >> I have a setup.py problem that's driving me nuts. > > Anyone? I've received 0 responses. I can't even install your code because there's a bug in it. m4_treap.m4 contains this instruction twice:

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 1:55 AM, wrote: > Le mercredi 15 janvier 2014 13:13:36 UTC+1, Ned Batchelder a écrit : > >> >> ... more than one codepoint makes up a grapheme ... > > No Yes. http://www.unicode.org/faq/char_combmark.html >> In Unicode terms, an encoding is a mapping between codepoints

Re:Question about object lifetime and access

2014-01-15 Thread Dave Angel
Asaf Las Wrote in message: > Hi community > Welcome. > > Multithreading will be enabled in uwsgi and 'p' will be used for read only. > > Questions are: > - what is the lifetime for global object (p in this example). The name will be visible in this module until the application shuts down

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread wxjmfauth
Le mercredi 15 janvier 2014 13:13:36 UTC+1, Ned Batchelder a écrit : > > ... more than one codepoint makes up a grapheme ... No > In Unicode terms, an encoding is a mapping between codepoints and bytes. No jmf -- https://mail.python.org/mailman/listinfo/python-list

Re: Learning python networking

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 12:31 AM, Frank Millman wrote: > I think you may have omitted a line there - > > def gets(): > while '\n' not in buffer: > data = sock.recv(1024) > if not data: > # Client is disconnected, handle it gracefully > return None # or s

ANN: Wing IDE 5.0.2 released

2014-01-15 Thread Wingware
Hi, Wingware has released version 5.0.2 of Wing IDE, our integrated development environment designed specifically for the Python programming language. Wing IDE includes a professional quality code editor with vi, emacs, and other key bindings, auto-completion, call tips, refactoring, context-aw

Re: Learning python networking

2014-01-15 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmpb6yr-VpWypbJQn0a=pnjvnv2cchvbzak+v_5josq...@mail.gmail.com... > You just run a loop like this: > > buffer = b'' > > def gets(): >while '\n' not in buffer: >data = sock.recv(1024) >if not data: ># Client is disconnecte

Re: Question about object lifetime and access

2014-01-15 Thread Asaf Las
Thanks! On Wednesday, January 15, 2014 3:05:43 PM UTC+2, Chris Angelico wrote: > > > > Questions are: > > > - what is the lifetime for global object (p in this example). > > > - will the p always have value it got during module loading > > > - if new thread will be created will p be accessible

Re: Question about object lifetime and access

2014-01-15 Thread Asaf Las
Thanks a lot for detailed answer! i plan to assign object to name only when module loads, that means outside of function or class method. Then object will be accessed from functions only for read purpose. I have read somewhere that global objects are referenced from module namespace will nev

Re: proposal: bring nonlocal to py2.x

2014-01-15 Thread Chris Angelico
On Wed, Jan 15, 2014 at 11:07 PM, Robin Becker wrote: > On 13/01/2014 15:28, Chris Angelico wrote: > .. > >> >> It's even worse than that, because adding 'nonlocal' is not a bugfix. >> So to be committed to the repo, it has to be approved for either 2.7 >> branch (which is in bugfix-only m

Re: Question about object lifetime and access

2014-01-15 Thread Chris Angelico
On Wed, Jan 15, 2014 at 11:13 PM, Asaf Las wrote: > Questions are: > - what is the lifetime for global object (p in this example). > - will the p always have value it got during module loading > - if new thread will be created will p be accessible to it > - if p is accessible to new thread will ne

Re: Trying to wrap my head around futures and coroutines

2014-01-15 Thread Oscar Benjamin
On Mon, Jan 06, 2014 at 09:15:56PM -0600, Skip Montanaro wrote: > From the couple responses I've seen, I must have not made myself > clear. Let's skip specific hypothetical tasks. Using coroutines, > futures, or other programming paradigms that have been introduced in > recent versions of Python 3.

Re: Question about object lifetime and access

2014-01-15 Thread Ned Batchelder
On 1/15/14 7:13 AM, Asaf Las wrote: Hi community i am beginner in Python and have possibly silly questions i could not figure out answers for. Below is the test application working with uwsgi to test json-rpc. from multip

Re: Learning python networking

2014-01-15 Thread Chris Angelico
On Wed, Jan 15, 2014 at 9:37 PM, Paul Pittlerson wrote: > I'm sorry if this is a bit late of a response, but here goes. > > Big thanks to Chris Angelico for his comprehensive reply, and yes, I do have > some questions! Best way to learn! And the thread's not even a week old, this isn't late. Som

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread Robin Becker
On 15/01/2014 12:13, Ned Batchelder wrote: On my utf8 based system robin@everest ~: $ cat ooo.py if __name__=='__main__': import sys s='A̅B' print('version_info=%s\nlen(%s)=%d' % (sys.version_info,s,len(s))) robin@everest ~: $ python ooo.py version_info=sys.version_info(ma

ANN: Python Meeting Düsseldorf - 21.01.2014

2014-01-15 Thread eGenix Team: M.-A. Lemburg
[This announcement is in German since it targets a local user group meeting in Düsseldorf, Germany] ANKÜNDIGUNG Python Meeting Düsseldorf http://pyddf.de/ Ein Treffen v

Question about object lifetime and access

2014-01-15 Thread Asaf Las
Hi community i am beginner in Python and have possibly silly questions i could not figure out answers for. Below is the test application working with uwsgi to test json-rpc. from multiprocessing import Process from werkze

Re: Python 3 __bytes__ method

2014-01-15 Thread Thomas Rachel
Am 12.01.2014 01:24 schrieb Ethan Furman: I must admit I'm not entirely clear how this should be used. Is anyone using this now? If so, how? I am not, as I currently am using Py2, but if I would, I would do it e. g. for serialization of objects in order to send them over the line or to sav

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread Ned Batchelder
On 1/15/14 7:00 AM, Robin Becker wrote: On 12/01/2014 07:50, wxjmfa...@gmail.com wrote: sys.version 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] s = 'Straße' assert len(s) == 6 assert s[5] == 'e' jmf On my utf8 based system robin@everest ~: $ cat ooo.py if __name

Re: proposal: bring nonlocal to py2.x

2014-01-15 Thread Robin Becker
On 13/01/2014 15:28, Chris Angelico wrote: .. It's even worse than that, because adding 'nonlocal' is not a bugfix. So to be committed to the repo, it has to be approved for either 2.7 branch (which is in bugfix-only maintenance mode) or 2.8 branch (which does not exist). Good luck. :)

Re: 'Straße' ('Strasse') and Python 2

2014-01-15 Thread Robin Becker
On 12/01/2014 07:50, wxjmfa...@gmail.com wrote: sys.version 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] s = 'Straße' assert len(s) == 6 assert s[5] == 'e' jmf On my utf8 based system robin@everest ~: $ cat ooo.py if __name__=='__main__': import sys s='A̅B

Re: Learning python networking

2014-01-15 Thread Denis McMahon
On Wed, 15 Jan 2014 02:37:05 -0800, Paul Pittlerson wrote: >> One extremely critical point about your protocol. TCP is a stream - you >> don't have message boundaries. You can't depend on one send() becoming >> one recv() at the other end. It might happen to work when you do one >> thing at a time

Re: Chanelling Guido - dict subclasses

2014-01-15 Thread Tim Chase
On 2014-01-15 01:27, Steven D'Aprano wrote: > class TextOnlyDict(dict): > def __setitem__(self, key, value): > if not isinstance(key, str): > raise TypeError > super().__setitem__(key, value) > # need to override more methods too > > > But reading Guido, I thin

Re: Learning python networking

2014-01-15 Thread Paul Pittlerson
I'm sorry if this is a bit late of a response, but here goes. Big thanks to Chris Angelico for his comprehensive reply, and yes, I do have some questions! > On Thursday, January 9, 2014 1:29:03 AM UTC+2, Chris Angelico wrote: > Those sorts of frameworks would be helpful if you need to scale to

Re: Trying to wrap my head around futures and coroutines

2014-01-15 Thread Phil Connell
On Mon, Jan 06, 2014 at 06:56:00PM -0600, Skip Montanaro wrote: > So, I'm looking for a little guidance. It seems to me that futures, > coroutines, and/or the new Tulip/asyncio package might be my salvation, but > I'm having a bit of trouble seeing exactly how that would work. Let me > outline a si

Re: Chanelling Guido - dict subclasses

2014-01-15 Thread Mark Lawrence
On 15/01/2014 01:27, Steven D'Aprano wrote: Over on the Python-Dev mailing list, there is an ENORMOUS multi-thread discussion involving at least two PEPs, about bytes/str compatibility. But I don't want to talk about that. (Oh gods, I *really* don't want to talk about that...) + trillions In

  1   2   >