Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of

2013-08-28 Thread Ulrich Eckhardt
Am 28.08.2013 13:55, schrieb Ferrous Cranus: Τη Τετάρτη, 28 Αυγούστου 2013 2:32:44 μ.μ. UTC+3, ο χρήστης Dave Angel έγραψε: You really have no directory in which you have write permissions? If so, perhaps you'd better solve that first. of cours ei ahve write permissions. Here:

Re: Basic Python Query

2013-08-23 Thread Ulrich Eckhardt
Am 23.08.2013 05:28, schrieb Steven D'Aprano: On Thu, 22 Aug 2013 13:54:14 +0200, Ulrich Eckhardt wrote: When the Python object goes away, it doesn't necessarily affect thethread or file it represents. That's certainly not true with file objects. When the file object goes out of scope

Re: Basic Python Query

2013-08-22 Thread Ulrich Eckhardt
Am 21.08.2013 20:58, schrieb Johannes Bauer: On 21.08.2013 11:11, Ulrich Eckhardt wrote: That said, there is never a need for deriving from the Thread class, you can also use it to run a function without that. That way is IMHO clearer because the threading.Thread instance is not the thread

Re: Basic Python Query

2013-08-21 Thread Ulrich Eckhardt
Am 21.08.2013 08:50, schrieb chandan kumar: class Test(threading.Thread): def StartThread(self): Lock = threading.Lock() self.start() Inconsistently indented code, this is a killer for Python. Please read PEP8 and use four spaces! That said, there is never a need for

Re: Module for dialoging with intercative programs, sockets, files, etc.

2013-08-06 Thread Ulrich Eckhardt
Am 05.08.2013 21:38, schrieb Olive: I have found telnetlib which make very easy to interact with a telnet server, especially the read_until command. I wonder if something similar exits for other things that a telnet server. It's not Python and I haven't played with it extensively, but there is

Re: outputting time in microseconds or milliseconds

2013-08-05 Thread Ulrich Eckhardt
Am 02.08.2013 15:17, schrieb matt.doolittl...@gmail.com: so you are saying that self.logfile.write('%s\t'%(str(time( should be: self.logfile.write('%s\t'%(str(time.time( No, I'm not saying that. What I wanted to make clear is that your code is impossible to understand as it

Re: Python script help

2013-08-02 Thread Ulrich Eckhardt
Am 01.08.2013 18:02, schrieb cool1...@gmail.com: I know I should be testing out the script myself but I did, I tried and since I am new in python and I work for a security firm that ask me to scan hundreds of documents a day for unsafe links (by opening them) I thought writing a script will be

Re: outputting time in microseconds or milliseconds

2013-08-02 Thread Ulrich Eckhardt
Am 02.08.2013 12:54, schrieb matt.doolittl...@gmail.com: I am using 2.7 on Ubuntu 12.10. All I need to do is to print time with the microseconds.[...] # write date and time and microseocnds self.logfile.write('%s\t'%(str(strftime(%Y-%m-%d,

Re: Bitwise Operations

2013-07-30 Thread Ulrich Eckhardt
Am 30.07.2013 01:34, schrieb Devyn Collier Johnson: Typing 101 010 or x = (int(101, 2) int(010, 2)) only gives errors. What errors? Check out Eric Raymond's essay on asking smart questions, it's a real eye-opener! ;) That said, use 0b as prefix for binary number literals (0b1000 is

Re: Python script help

2013-07-30 Thread Ulrich Eckhardt
Am 30.07.2013 16:49, schrieb cool1...@gmail.com: Hello, I am looking for a script that will be able to search an online document (by giving the script the URL) and find all the downloadable links in the document and then download them automatically. Well, that's actually pretty simple. Using

Re: Callable or not callable, that is the question!

2013-07-12 Thread Ulrich Eckhardt
Am 11.07.2013 16:11, schrieb Peter Otten: Ulrich Eckhardt wrote: Bug or feature? No bug. Missing feature if you come up with a convincing use-case. class Parser: def _handle_bool(input): # ... pass types = {'bool': _handle_bool, 'boolean': _handle_bool

Re: Kivy for Python 3.3

2013-07-11 Thread Ulrich Eckhardt
Welcome to Python! Am 11.07.2013 11:09, schrieb fronag...@gmail.com: I'm looking to write a program in Python, (and have in fact written most of it by now,) and am trying to put together a GUI for it. Kivy looks very nice, particularly with the fact that it's supposed to be compatible with most

Callable or not callable, that is the question!

2013-07-11 Thread Ulrich Eckhardt
Hello! I just stumbled over a case where Python (2.7 and 3.3 on MS Windows) fail to detect that an object is a function, using the callable() builtin function. Investigating, I found out that the object was indeed not callable, but in a way that was very unexpected to me: class X:

Re: How to clean up socket connection to printer

2013-07-09 Thread Ulrich Eckhardt
Am 09.07.2013 11:39, schrieb loial: I have a socket application that is connecting to a HP printer via port 9100. Occassionally I get a Connection reset by peer error which I am trapping and exiting the script with an error message. Strange. Why does the remote terminate the connection?

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-04 Thread Ulrich Eckhardt
Am 04.07.2013 10:37, schrieb Νίκος: I just started to have this error without changing nothing Well, undo the nothing that you didn't change. ;) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte [Thu Jul 04 11:35:14 2013] [error] [client

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-04 Thread Ulrich Eckhardt
Am 04.07.2013 12:38, schrieb Νίκος: Στις 4/7/2013 12:50 μμ, ο/η Ulrich Eckhardt έγραψε: Am 04.07.2013 10:37, schrieb Νίκος: Why cant it decode the starting byte? what starting byte is that? It's the 0xb6 but it's expecting the starting byte of a UTF-8 sequence. Please do some research on UTF

Re: Writing Extensions for Python 3 in C

2013-06-19 Thread Ulrich Eckhardt
Am 18.06.2013 12:24, schrieb Aditya Avinash: Hi. This is the last place where I want to ask a question. You are probably not saying what you mean here. The meaning of your sentence is more like Here is the forum that I dislike more than any other forum, but still I have to ask a question

Re: A few questiosn about encoding

2013-06-12 Thread Ulrich Eckhardt
Am 12.06.2013 13:23, schrieb Νικόλαος Κούρας: So, how many bytes does UTF-8 stored for codepoints 127 ? What has your research turned up? I personally consider it lazy and respectless to get lots of pointers that you could use for further research and ask for more info before you even

Re: Receing a form variable as a list instead of as a string

2013-06-11 Thread Ulrich Eckhardt
Am 11.06.2013 12:38, schrieb Νικόλαος Κούρας: File /home/nikos/public_html/cgi-bin/metrites.py, line 28, in module, referer: http://xxxredactedxxx/ page = page.replace( '/home/nikos/public_html/', '' ), referer: http://xxxredactedxxx/ AttributeError: 'list' object has no attribute

Re: Sorting a set works, sorting a dictionary fails ?

2013-06-10 Thread Ulrich Eckhardt
Am 10.06.2013 10:29, schrieb Νικόλαος Κούρας: for key in sorted( months.values() ): ^^^ ^^ KeyError 1 ??!! All i did was to tell python to sort the dictionary values, which are just integers. ...and which you then proceed to use as key, which is obviously wrong.

Re: Sorting a set works, sorting a dictionary fails ?

2013-06-10 Thread Ulrich Eckhardt
Am 10.06.2013 10:04, schrieb Νικόλαος Κούρας: months = { 'Ιανουάριος':1, 'Φεβρουάριος':2, 'Μάρτιος':3, 'Απρίλιος':4, 'Μάϊος':5, 'Ιούνιος':6, \ 'Ιούλιος':7, 'Αύγουστος':8, 'Σεπτέμβριος':9, 'Οκτώβριος':10, 'Νοέμβριος':11, 'Δεκέμβριος':12 } for key in sorted( months.keys() ):

Re: Reply to post 'Tryign to add a valkue to a set'

2013-06-10 Thread Ulrich Eckhardt
Am 10.06.2013 12:57, schrieb Νικόλαος Κούρας: Τη Δευτέρα, 10 Ιουνίου 2013 12:40:01 μ.μ. UTC+3, ο χρήστης Ulrich Eckhardt έγραψε: for key in sorted( months.keys() ): print(''' option value=%s %s /option ''' % (months[key], key) ) this in fact works, it sorts

Re: Sorting a set works, sorting a dictionary fails ?

2013-06-10 Thread Ulrich Eckhardt
Am 10.06.2013 11:48, schrieb Νικόλαος Κούρας: After many tried this did the job: for key in sorted(months.items(),key=lambda num : num[1]): print(''' option value=%s %s /option ''' % (key[1], key[0]) ) This code is still sending a misleading message. What you

Re: Reply to post 'Tryign to add a valkue to a set'

2013-06-10 Thread Ulrich Eckhardt
Am 10.06.2013 15:37, schrieb Νικόλαος Κούρας: Τη Δευτέρα, 10 Ιουνίου 2013 4:14:33 μ.μ. UTC+3, ο χρήστης Ulrich Eckhardt έγραψε: Am 10.06.2013 12:57, schrieb Νικόλαος Κούρας: Τη Δευτέρα, 10 Ιουνίου 2013 12:40:01 μ.μ. UTC+3, ο χρήστης Ulrich Eckhardt έγραψε: for key in sorted

Re: I want to know how to implement concurrent threads in Python

2013-05-28 Thread Ulrich Eckhardt
Am 26.05.2013 21:10, schrieb Daniel Gagliardi: I want to know how to implement concurrent threads in Python Have you tried searching the web or maybe looked on docs.python.org? Seriously, show at least some effort before asking here. Uli --

Re: subclassing from unittest

2013-05-23 Thread Ulrich Eckhardt
Am 22.05.2013 17:32, schrieb Charles Smith: I'd like to subclass from unittest.TestCase. I observed something interesting and wonder if anyone can explain what's going on... some subclasses create null tests. I can perhaps guess what's going on, though Terry is right: Your question isn't

Re: Fractal

2013-05-16 Thread Ulrich Eckhardt
Am 16.05.2013 02:00, schrieb alex23: My favourite is this one: http://preshing.com/20110926/high-resolution-mandelbrot-in-obfuscated-python Not only is this blog entry an interesting piece of art, there's other interesting things to read there, too. Thanks! Uli --

percent faster than format()? (was: Re: optomizations)

2013-04-23 Thread Ulrich Eckhardt
Am 23.04.2013 06:00, schrieb Steven D'Aprano: If it comes down to micro-optimizations to shave a few microseconds off, consider using string % formatting rather than the format method. Why? I don't see any obvious difference between the two... Greetings! Uli --

Re: Running simultaneuos FOR loops

2013-04-23 Thread Ulrich Eckhardt
Am 23.04.2013 09:13, schrieb inshu chauhan: This statement is giving me the following error Statement: for p, k, j in zip(sorted(segments.iterkeys(), class_count.iterkeys(), pixel_count.iterkeys())): Error: Traceback (most recent call last): File

Re: percent faster than format()?

2013-04-23 Thread Ulrich Eckhardt
Am 23.04.2013 10:26, schrieb Chris “Kwpolska” Warrick: On Tue, Apr 23, 2013 at 9:46 AM, Ulrich Eckhardt ulrich.eckha...@dominolaser.com wrote: Am 23.04.2013 06:00, schrieb Steven D'Aprano: If it comes down to micro-optimizations to shave a few microseconds off, consider using string

Re: name lookup failure using metaclasses with unittests

2013-04-12 Thread Ulrich Eckhardt
Am 11.04.2013 10:19, schrieb Steven D'Aprano: if sys.version = '3': Use sys.version_info = (3,), otherwise your code breaks when upgrading to Python 10 and greater. ;^) The second question that came up was if there is a way to keep a metaclass defined inside the class or if the only way

Re: name lookup failure using metaclasses with unittests

2013-04-11 Thread Ulrich Eckhardt
Am 10.04.2013 11:52, schrieb Peter Otten: Ulrich Eckhardt wrote: [...] It looks like this particular invocation relies on class attribute and function __name__ being identical. Please file a bug report. Thanks for confirming this and reducing the test case even more. Now, concerning

Re: name lookup failure using metaclasses with unittests

2013-04-11 Thread Ulrich Eckhardt
Am 10.04.2013 11:52, schrieb Peter Otten: It looks like this particular invocation relies on class attribute and function __name__ being identical. Please file a bug report. http://bugs.python.org/issue17696 Uli -- http://mail.python.org/mailman/listinfo/python-list

[issue17696] lookup fails for renamed functions

2013-04-11 Thread Ulrich Eckhardt
New submission from Ulrich Eckhardt: When you rename a test function, you can't explicitly specify it on the commandline any more. During normal test runs, it is automatically discovered though. The error is that the old name was not found, even though the new name was specified. The attached

name lookup failure using metaclasses with unittests

2013-04-10 Thread Ulrich Eckhardt
Hi! I'm having problems using a metaclass to generate test functions. This works when I try to run all tests from the module or test case, but it fails when I'm trying to specify a single test function. My environment is Python 2.7.3 on MS Windows 7 at the moment. It should be upgraded to at

Re: Sudoku

2013-03-27 Thread Ulrich Eckhardt
Am 27.03.2013 06:44, schrieb Eric Parry: I downloaded the following program from somewhere using a link from Wikipedia and inserted the “most difficult Sudoku puzzle ever” string into it and ran it. It worked fine and solved the puzzle in about 4 seconds. However I cannot understand how it

Re: Triple nested loop python (While loop insde of for loop inside of while loop)

2013-03-04 Thread Ulrich Eckhardt
Am 01.03.2013 17:28, schrieb Isaac Won: What I really want to get from this code is m1 as I told. For this purpose, for instance, values of fpsd upto second loop and that from third loop should be same, but they are not. Actually it is my main question. You are not helping yourself... In

Re: Triple nested loop python (While loop insde of for loop inside of while loop)

2013-03-01 Thread Ulrich Eckhardt
Am 01.03.2013 09:59, schrieb Isaac Won: try to make my triple nested loop working. My code would be: c = 4 [...] while c 24: c = c + 1 This is bad style and you shouldn't do that in python. The question that comes up for me is whether something else is modifying c in that loop,

[issue4331] Can't use _functools.partial() created function as method

2013-02-25 Thread Ulrich Eckhardt
Ulrich Eckhardt added the comment: There is at least one thing that is missing in the patch, it lacks the necessary tests. The partialbug.py demonstrates the issue, it could be used as a base. However, even then, there is still one thing that is problematic: The fact that partial() returns

[issue11470] Flag inappropriate uses of callable class attributes

2013-02-25 Thread Ulrich Eckhardt
Changes by Ulrich Eckhardt ulrich.eckha...@dominolaser.com: -- nosy: +eckhardt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11470 ___ ___ Python

Re: Awsome Python - chained exceptions

2013-02-15 Thread Ulrich Eckhardt
Am 15.02.2013 08:51, schrieb Rick Johnson: How could a line in the try block ever be considered offensive? My suggestion of offensive does not imply ignorance on /my/ part[...] Well, it seems to imply that you are not aware of the subtle difference between offending and offensive. The

Re: Awsome Python - chained exceptions

2013-02-14 Thread Ulrich Eckhardt
Am 13.02.2013 um 17:14 schrieb Rick Johnson: Q1: How could a line in the try block ever be considered offensive? Because it throws an error? try: rrick.go_and_fuck_yourself() finally: rrick.get_lost() See, wasn't that difficult, was it? :D Are you serious? No, I just

Re: which situations should we use thread. join() ?

2013-02-08 Thread Ulrich Eckhardt
Am 08.02.2013 07:29, schrieb Chris Angelico: On Fri, Feb 8, 2013 at 3:32 PM, iMath redstone-c...@163.com wrote: which situations should we use thread. join() ? http://bpaste.net/show/yBDGfrlU7BDDpvEZEHmo/ why do we not put thread. join() in this code ? I've no idea why you don't put

Re: Is Python programming language?

2013-02-08 Thread Ulrich Eckhardt
Am 08.02.2013 14:03, schrieb gmspro: One said, Python is not programming language, rather scripting language, is that true? That depends on your definition of scripting language and programming language. Python's not a language but an animal. Uli --

Re: puzzled by name binding in local function

2013-02-07 Thread Ulrich Eckhardt
Heureka! Am 06.02.2013 15:37, schrieb Dave Angel: def myfunc2(i): def myfunc2b(): print (myfunc2 is using, i) return myfunc2b Earlier you wrote: There is only one instance of i, so it's not clear what you expect. Since it's not an argument to test(), it has to be found in

[issue4331] Can't use _functools.partial() created function as method

2013-02-07 Thread Ulrich Eckhardt
Ulrich Eckhardt added the comment: Just for the record, the behaviour is documented, unfortunately in the very last line of the functools documentation: Also, partial objects defined in classes behave like static methods and do not transform into bound methods during instance attribute look

Re: puzzled by name binding in local function

2013-02-06 Thread Ulrich Eckhardt
Dave and Terry, Thanks you both for your explanations! I really appreciate the time you took. Am 05.02.2013 19:07, schrieb Dave Angel: If you need to have separate function objects that already know a value for i, you need to somehow bind the value into the function object. One way to do

Re: Opinion on best practice...

2013-02-05 Thread Ulrich Eckhardt
Am 05.02.2013 05:14, schrieb Anthony Correia: I need to pick up a language that would cover the Linux platform. I use Powershell for a scripting language on the Windows side of things. Very simple copy files script. Is this the best way to do it? import os objdir = (C:\\temp2) Drop

Re: autoflush on/off

2013-02-05 Thread Ulrich Eckhardt
Am 05.02.2013 01:09, schrieb Jabba Laci: I like the context manager idea There is a helper library for constructing context managers, see http://docs.python.org/2/library/contextlib.html. That would have made your code even shorter. setting the sys.stdout back to the original value

Re: Opinion on best practice...

2013-02-05 Thread Ulrich Eckhardt
Am 05.02.2013 11:35, schrieb Peter Otten: Ulrich Eckhardt wrote: [...] use os.path.walk(), because that doesn't first build a list and then iterate over the list but iterates over the single elements directly. [...] Not true. os.walk() uses os.listdir() internally. Oh. 8| Thanks

puzzled by name binding in local function

2013-02-05 Thread Ulrich Eckhardt
Hello Pythonistas! Below you will find example code distilled from a set of unit tests, usable with Python 2 or 3. I'm using a loop over a list of parameters to generate tests with different permutations of parameters. Instead of calling util() with values 0-4 as I would expect, each call

Re: autoflush on/off

2013-02-04 Thread Ulrich Eckhardt
Am 04.02.2013 18:12, schrieb Jabba Laci: autoflush_on = False def unbuffered(): Switch autoflush on. global autoflush_on # reopen stdout file descriptor with write mode # and 0 as the buffer size (unbuffered) if not autoflush_on: sys.stdout =

Re: monolithic apps

2013-01-24 Thread Ulrich Eckhardt
Am 24.01.2013 18:06, schrieb tamn...@gmail.com: Any suggestions for study?..: Is is possible to take a large executable with GUI and real time data and images, to extract modules, and it can run as if it looks like a monolithic application (windows over main windows, or images over other images)

Re: Memory error with quadratic interpolation

2013-01-23 Thread Ulrich Eckhardt
Am 23.01.2013 05:06, schrieb Isaac Won: I have tried to use different interpolation methods with Scipy. My code seems just fine with linear interpolation, but shows memory error with quadratic. I am a novice for python. I will appreciate any help. #code f = open(filin, r) Check out the with

Re: need explanation

2013-01-21 Thread Ulrich Eckhardt
Am 21.01.2013 17:06, schrieb kwakukwat...@gmail.com: please I need some explanation on sys.stdin and sys.stdout, and piping out http://www.catb.org/esr/faqs/smart-questions.html Uli -- http://mail.python.org/mailman/listinfo/python-list

Re: unit selection problem

2013-01-15 Thread Ulrich Eckhardt
Am 14.01.2013 21:29, schrieb Paul Pittlerson: map_textures = get_sprites( (48, 48) ,spritesheet.png , (0, 0) ) You forgot to include spritesheet.png in your message. Seriously, condense your code down to a minimal example. This might help you finding the problem yourself, otherwise

Re: interrupt the file sending if the file size over the quota...some errors here...

2013-01-15 Thread Ulrich Eckhardt
Am 15.01.2013 10:46, schrieb Levi Nie: i want to interrupt the file sending. but i can't change the client. so i need change the server. All things go well, but the message i wanna response seem not work. Ahem, what? It doesn't work, so does it sit on the couch all day? is the

Re: new to python and programming at large

2013-01-09 Thread Ulrich Eckhardt
Am 09.01.2013 22:05, schrieb kwakukwat...@gmail.com: pls I want to write a function that can compute for the sqrt root of any number.bt it not working pls help. Whenever describing an error, be precise. In this particular case, we have some sourcecode (which is good!) but what is still

Re: Problem with calling function from dll

2012-12-13 Thread Ulrich Eckhardt
Am 13.12.2012 08:40, schrieb deep...@poczta.fm: I have problem with using function from dll. import ctypes b = ctypes.windll.LoadLibrary(kernel32) a = b.GetComputerNameA(a,20) GetComputerNameA takes a pointer to a writable char string. You give it a pointer to an immutable string. You

Re: Error .. Please Help

2012-12-12 Thread Ulrich Eckhardt
Am 12.12.2012 16:00, schrieb inshu chauhan: color = image[y,x] if color == (0.0,0.0,0.0): continue else : if color == (0.0,255.0,0.0): classification = 1 elif color == (128.0, 0.0, 255.0):

Re: amazing scope?

2012-11-30 Thread Ulrich Eckhardt
Am 30.11.2012 12:11, schrieb andrea crotti: I wrote a script, refactored it and then introducing a bug as below: def record_things(): out.write(Hello world) This is a function. Since out is not a local variable, it is looked up in the surrounding namespace at the time the function is

Re: How to create an executable from python script in windows

2012-11-28 Thread Ulrich Eckhardt
Am 28.11.2012 07:43, schrieb Prakash: copying C:\Python24\lib\site-packages\py2exe\run_w.exe Python 2.4 was released 8 years ago and shouldn't be used for new development or learning any longer. The first step I would take is to upgrade to 2.7, which is the last in the

Re: Web Frameworks Excessive Complexity

2012-11-21 Thread Ulrich Eckhardt
Am 21.11.2012 02:43, schrieb Steven D'Aprano: On Tue, 20 Nov 2012 20:07:54 +, Robert Kern wrote: The source of bugs is not excessive complexity in a method, just excessive lines of code. Taken literally, that cannot possibly the case. def method(self, a, b, c): do_this(a)

Re: Point of idle curiosity

2012-11-19 Thread Ulrich Eckhardt
Am 18.11.2012 12:45, schrieb Chris Angelico: (if you'll forgive the pun) Nevarr! Is IDLE named after Eric of that name, or is it pure coincidence? Maybe. Interestingly, there is also http://eric-ide.python-projects.org/, just to add some more unfounded conspiracy theories to this

Re: editing conf file

2012-11-16 Thread Ulrich Eckhardt
Am 16.11.2012 13:06, schrieb chip9munk: I would like to use conf file to get all the variables in my code. And it works great. I use the following (simple example): execfile(example.conf, config) print config[value1] and it works like a charm. This works, but in general importing

Re: debugging in eclipse

2012-11-15 Thread Ulrich Eckhardt
Am 15.11.2012 13:29, schrieb chip9m...@gmail.com: I have a python module, lets call it debugTest.py. and it contains: def test(): a=1 b=2 c=a+b c so as simple as possible. Should that be return c instead of c on a line? Now I would like to debug it in eclipse.. (I have

Re: Supported Platforms for Python

2012-11-14 Thread Ulrich Eckhardt
Am 14.11.2012 10:51, schrieb Kiran N Mallekoppa: 1. Is this information available somewhere? 2. I was pointed to PEP-11, which documents the platforms that are not supported. So, can we take that all active versions of Python (2.7.3 and 3.3, i believe) are supported on all the OS flavors that

Re: List comprehension for testing **params

2012-11-12 Thread Ulrich Eckhardt
Am 11.11.2012 23:24, schrieb Cantabile: I'm writing a small mail library for my own use, and at the time I'm testing parameters like this: Let's ignore the facts that there is an existing mail library, that you should use real parameters if they are required and that exit() is completely

Re: Strange object identity problem

2012-11-12 Thread Ulrich Eckhardt
Am 12.11.2012 14:12, schrieb F.R.: Once in a while I write simple routine stuff and spend the next few hours trying to understand why it doesn't behave as I expect. Here is an example holding me up: [...snip incomplete code...] Trying something similar with a simpler class works as expected:

Re: int.__init__ incompatible in Python 3.3

2012-11-12 Thread Ulrich Eckhardt
Am 09.11.2012 12:37, schrieb Steven D'Aprano: In Python 3.3: py class X(int): ... def __init__(self, *args): ... super().__init__(*args) # does nothing, call it anyway ... py x = X(22) Traceback (most recent call last): File stdin, line 1, in module File stdin, line 3, in

Re: int.__init__ incompatible in Python 3.3

2012-11-09 Thread Ulrich Eckhardt
Am 08.11.2012 21:29, schrieb Terry Reedy: On Thu, Nov 8, 2012 at 8:55 AM, Ulrich Eckhardt ulrich.eckha...@dominolaser.com wrote: On 3.3, it gives me a TypeError: object.__init__() takes no parameters. To some extent, this makes sense to me, because the int subobject is not initialized

Re: int.__init__ incompatible in Python 3.3

2012-11-09 Thread Ulrich Eckhardt
Am 09.11.2012 12:37, schrieb Steven D'Aprano: On Fri, 09 Nov 2012 08:56:22 +0100, Ulrich Eckhardt wrote: Or, do you suggest I don't call super().__init__()? That would seem unclean to me. On the contrary: calling super().__init__ when the superclass does something you don't want (i.e. raises

isinstance(.., file) for Python 3

2012-11-08 Thread Ulrich Eckhardt
Hi! I have two problems that are related and that I'd like to solve together. Firstly, I have code that allows either a file or a string representing its content as parameter. If the parameter is a file, the content is read from the file. In Python 2, I used isinstance(p, file) to determine

int.__init__ incompatible in Python 3.3

2012-11-08 Thread Ulrich Eckhardt
Hi! Preparing for an upgrade from 2.7 to 3, I stumbled across an incompatibility between 2.7 and 3.2 on one hand and 3.3 on the other: class X(int): def __init__(self, value): super(X, self).__init__(value) X(42) On 2.7 and 3.2, the above code works. On 3.3, it gives me a

Re: accepting file path or file object?

2012-11-05 Thread Ulrich Eckhardt
Am 05.11.2012 11:54, schrieb andrea crotti: Quite often I find convenient to get a filename or a file object as argument of a function, and do something as below: def grep_file(regexp, filepath_obj): Check if the given text is found in any of the file lines, take a path to a file or

surprising += for lists

2012-11-04 Thread Ulrich Eckhardt
Hi everybody! I was just smacked by some very surprising Python 2.7 behaviour. I was assembling some 2D points into a list: points = [] points += (3, 5) points += (4, 6) What I would have expected is to have [(3, 5), (4, 6)], instead I got [3, 5, 4, 6]. My interpretations thereof is that

Re: Organisation of python classes and their methods

2012-11-02 Thread Ulrich Eckhardt
Am 02.11.2012 09:08, schrieb Martin Hewitson: On 2, Nov, 2012, at 08:38 AM, Paul Rubin no.email@nospam.invalid wrote: Martin Hewitson martinhewit...@mac.com writes: So, is there a way to put these methods in their own files and have them 'included' in the class somehow? ... Is there an

Re: Organisation of python classes and their methods

2012-11-02 Thread Ulrich Eckhardt
Am 02.11.2012 09:20, schrieb Martin Hewitson: Well, here we disagree. Suppose I have a class which encapsulates time-series data. Below is a list of the absolute minimum methods one would have to process that data. [...] 'abs' 'acos' 'asin' 'atan' 'atan2' 'average' 'cohere' 'conv' 'corr'

Re: Proper place for everything

2012-11-02 Thread Ulrich Eckhardt
Am 02.11.2012 12:20, schrieb Jason Benjamin: Anybody know of the appropriate place to troll and flame about various Python related issues? I'm kind of mad about some Python stuff and I need a place to vent where people may or may not listen, but at at least respond. Thought this would be a

Re: calling one staticmethod from another

2012-10-31 Thread Ulrich Eckhardt
Am 30.10.2012 18:23, schrieb Jean-Michel Pichavant: - Original Message - [snip] I haven't figured out the justification for staticmethod, http://en.wikipedia.org/wiki/Namespace + Namespaces are one honking great idea -- let's do more of those! Someone may successfully use only

calling one staticmethod from another

2012-10-30 Thread Ulrich Eckhardt
Hi! I can call a staticmethod f() of class C like C.f() or with an instance like C().f(). Inside that staticmethod, I have neither the class (at least not the original one) nor do I have an instance, so I can't call a different staticmethod from the same class. The obvious solution is to

Re: calling one staticmethod from another

2012-10-30 Thread Ulrich Eckhardt
Am 30.10.2012 14:47, schrieb Dave Angel: I'd think the obvious solution is to move both the functions outside of the class. I haven't figured out the justification for staticmethod, except for java or C++ converts. Although I come from a C++ background, I think static functions have solid

Re: Help understanding an Object Oriented Program example

2012-10-29 Thread Ulrich Eckhardt
Am 29.10.2012 00:30, schrieb goldtech: class Contact: all_contacts = [] def __init__(self, name, email): self.name = name self.email = email Contact.all_contacts.append(self) Okay, a class that automatically registers all instances in a central list. OK,

better way for ' '.join(args) + '\n'?

2012-10-26 Thread Ulrich Eckhardt
Hi! General advise when assembling strings is to not concatenate them repeatedly but instead use string's join() function, because it avoids repeated reallocations and is at least as expressive as any alternative. What I have now is a case where I'm assembling lines of text for driving a

bad httplib latency due to IPv6 use

2012-10-17 Thread Ulrich Eckhardt
Hi! I noticed yesterday that a single HTTP request to localhost takes roughly 1s, regardless of the actually served data, which is way too long. After some digging, I found that the problem lies in socket.create_connection(), which first tries the IPv6 ::1 and only then tries the IPv4

Re: bad httplib latency due to IPv6 use

2012-10-17 Thread Ulrich Eckhardt
Some updates on the issue: The etc/hosts file contains the following lines: # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost As I understand it, those effectively mean that localhost is not resolved via this hosts

portable unicode literals

2012-10-15 Thread Ulrich Eckhardt
Hi! I need a little nudge in the right direction, as I'm misunderstanding something concerning string literals in Python 2 and 3. In Python 2.7, b'' and '' are byte strings, while u'' is a unicode literal. In Python 3.2, b'' is a byte string and '' is a unicode literal, while u'' is a syntax

Re: an error in python lib?

2012-10-12 Thread Ulrich Eckhardt
Am 12.10.2012 00:06, schrieb Wenhua Zhao: On Wed, Oct 10, 2012 at 12:21 PM, Ian Kelly ian.g.ke...@gmail.com wrote: Can you demonstrate an API bug that is caused by this? A simple demo of this error is: [...] print in main cv._is_owned: , cv._is_owned() That is kind of cheating,

Re: Generating C++ code

2012-10-10 Thread Ulrich Eckhardt
Am 09.10.2012 18:00, schrieb Jean-Michel Pichavant: I'm trying to generate C++ code from an XML file. I'd like to use a template engine, which imo produce something readable and maintainable. [...] Here's my flow: XML file - nice python app - C++ code There is one question that you should

Re: an error in python lib?

2012-10-10 Thread Ulrich Eckhardt
Am 10.10.2012 02:32, schrieb Wenhua Zhao: I just noticed that in /usr/lib/python2.7/threading.py class _Condition(_Verbose): ... def _is_owned(self): # Return True if lock is owned by current_thread. # This method is called only if __lock doesn't have #

Re: an error in python lib?

2012-10-10 Thread Ulrich Eckhardt
Am 10.10.2012 03:16, schrieb MRAB: On 2012-10-10 01:32, Wenhua Zhao wrote: Hi list, I just noticed that in /usr/lib/python2.7/threading.py class _Condition(_Verbose): ... def _is_owned(self): # Return True if lock is owned by current_thread. # This method is called

Re: Creating a dictionary

2012-10-09 Thread Ulrich Eckhardt
Am 09.10.2012 13:59, schrieb arg...@gmail.com: below is the text file i have How to create Facility as a key and then assign multiple values to it The value part of a dict element can be any kind of object, like e.g. a tuple, namedtuple or even a dict. Uli --

Re: string contains and special characters

2012-10-09 Thread Ulrich Eckhardt
Am 09.10.2012 16:02, schrieb loial: I am trying to match a string that containing the and characters, using the string contains function, but it never seems to find the lines containing the string e.g if mystring.contains(TAG) : I can't locate a 'contains' function anywhere, what type is

Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ?

2012-10-08 Thread Ulrich Eckhardt
Am 08.10.2012 16:07, schrieb iMath: To get the accurate value of 1 - 0.999 ,how to implement the python algorithm ? Algorithms are generally language-agnostic, so what is your question BTW ,Windows’s calculator get the accurate value ,anyone who knows how to implement it ?

Re: error bluetooth

2012-10-05 Thread Ulrich Eckhardt
Am 05.10.2012 10:51, schrieb Luca Sanna: the code is output the error of the ubuntu from bluetooth import * [...] nearby_devices = discover_devices() [...] the error luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py Traceback (most recent call last): File

unit testing class hierarchies

2012-10-02 Thread Ulrich Eckhardt
Greetings! I'm trying to unittest a class hierachy using Python 2.7. I have a common baseclass Base and derived classes D1 and D2 that I want to test. The baseclass in not instantiatable on its own. Now, the first approach is to have test cases TestD1 and TestD2, both derived from class

Re: unit testing class hierarchies

2012-10-02 Thread Ulrich Eckhardt
Am 02.10.2012 16:06, schrieb Thomas Bach: On Tue, Oct 02, 2012 at 02:27:11PM +0200, Ulrich Eckhardt wrote: As you see, the code for test_base() is redundant, so the idea is to move it to a baseclass: class TestBase(unittest.TestCase): def test_base(self): ... class TestD1

Re: unit testing class hierarchies

2012-10-02 Thread Ulrich Eckhardt
Am 02.10.2012 16:06, schrieb Thomas Bach: On Tue, Oct 02, 2012 at 02:27:11PM +0200, Ulrich Eckhardt wrote: As you see, the code for test_base() is redundant, so the idea is to move it to a baseclass: class TestBase(unittest.TestCase): def test_base(self): ... class TestD1

Re: parse an environment file

2012-10-01 Thread Ulrich Eckhardt
Am 01.10.2012 02:11, schrieb Jason Friedman: $ crontab -l * * * * * env This produces mail with the following contents: [...] SHELL=/bin/sh ^^^ [...] On the other hand $ env produces about 100 entries, most of which are provided by my .bashrc; bash != sh Instead of

Re: python file API

2012-09-25 Thread Ulrich Eckhardt
Am 24.09.2012 23:49, schrieb Dave Angel: And what approach would you use for positioning relative to end-of-file? That's currently done with an optional second parameter to seek() method. Negative indices. ;) Uli -- http://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   >