Re: Style question -- plural of class name?

2013-05-09 Thread Thomas Rachel
Am 09.05.2013 02:38 schrieb Colin J. Williams: On 08/05/2013 4:20 PM, Roy Smith wrote: "A list of FooEntry's" +1 Go back to school. Both of you... That is NOT the way to build a plural form... Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: object.enable() anti-pattern

2013-05-10 Thread Thomas Rachel
Am 10.05.2013 15:22 schrieb Roy Smith: That's correct. But, as described above, the system makes certain guarantees which allow me to reason about the existence or non-existence os such entries. Nevertheless, your 37 is not a FD yet. Let's take your program: #include #include #include #

Re: Piping processes works with 'shell = True' but not otherwise.

2013-05-29 Thread Thomas Rachel
Am 27.05.2013 02:14 schrieb Carlos Nepomuceno: pipes usually consumes disk storage at '/tmp'. Good that my pipes don't know about that. Why should that happen? Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: A certainl part of an if() structure never gets executed.

2013-06-26 Thread Thomas Rachel
Am 12.06.2013 03:46 schrieb Rick Johnson: On Tuesday, June 11, 2013 8:25:30 PM UTC-5, nagia@gmail.com wrote: is there a shorter and more clear way to write this? i didnt understood what Rick trie to told me. My example included verbatim copies of interactive sessions within the Python co

Re: Is that safe to use ramdom.random() for key to encrypt?

2012-06-19 Thread Thomas Rachel
Am 18.06.2012 01:48 schrieb Paul Rubin: Steven D'Aprano writes: /dev/urandom isn't actually cryptographically secure; it promises not to block, even if it has insufficient entropy. But in your instance... Correct. /dev/random is meant to be used for long-lasting cryptographically-significant

Re: Generator vs functools.partial?

2012-06-21 Thread Thomas Rachel
Am 21.06.2012 13:25 schrieb John O'Hagan: But what about a generator? Yes, but... def some_func(): arg = big_calculation() while 1: i = yield (do_something with arg and i) some_gen = some_func() some_gen.send(None) for i in lots_of_items: some_gen.send(i)

Re: What's wrong with this code?

2012-07-24 Thread Thomas Rachel
Am 23.07.2012 16:50 schrieb Stone Li: I'm totally confused by this code: Code: a = None b = None c = None d = None x = [[a,b], [c,d]] e,f = x[1] print e,f c = 1 d = 2 print e,f e = 1 f = 2 print c,d Output: None None None N

Re: the meaning of r`.......`

2012-07-24 Thread Thomas Rachel
Am 23.07.2012 17:59 schrieb Steven D'Aprano: >> Before you get a language that uses full Unicode, you'll need to have fairly generally available keyboards that have those keys. Or at least keys or key combinations for the stuff you need, which might differ e. g. with the country you live in.

Re: What's wrong with this code?

2012-07-24 Thread Thomas Rachel
Am 24.07.2012 09:47 schrieb Ulrich Eckhardt: [0] Note that in almost all cases, when referring to a tag, Python implicitly operates on the object attached to it. One case (the only one?) where it doesn't is the "del" statement. The del and the =, concerning the left side. But even those don't

Re: On-topic: alternate Python implementations

2012-08-04 Thread Thomas Rachel
Am 04.08.2012 11:10 schrieb Stefan Behnel: As long as you don't use any features of the Cython language, it's plain Python. That makes it a Python compiler in my eyes. Tell that the C++ guys. C++ is mainly a superset of C. But nevertheless, C and C++ are distinct languages and so are Python a

Re: set and dict iteration

2012-09-08 Thread Thomas Rachel
Am 19.08.2012 00:14 schrieb MRAB: Can someone who is more familiar with the cycle detector and cycle breaker, help prove or disprove the above? In simple terms, when you create an immutable object it can contain only references to pre-existing objects, but in order to create a cycle you need t

Re: generators as decorators simple issue

2012-09-11 Thread Thomas Rachel
Am 12.09.2012 04:28 schrieb j.m.dagenh...@gmail.com: I'm trying to call SetName on an object to prevent me from ever having to call it explictly again on that object. Best explained by example. def setname(cls): '''this is the proposed generator to call SetName on the object''' try:

Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py

2012-09-11 Thread Thomas Rachel
Am 11.09.2012 05:46 schrieb Steven D'Aprano: Good for you. (Sorry, that comes across as more condescending than it is intended as.) Monkey-patching often gets used for quick scripts and tiny pieces of code because it works. Just beware that if you extend that technique to larger bodies of code,

Re: Decorators not worth the effort

2012-09-15 Thread Thomas Rachel
[Sorry, my Firefox destroyed the indent... Am 14.09.2012 22:29 schrieb Terry Reedy: In other words def make_wrapper(func, param): def wrapper(*args, **kwds): for i in range(param): func(*args, **kwds) return wrapper def f(x): print(x) f = make_wrapper(f, 2) f('simple') # is simpler, at least

Re: using text file to get ip address from hostname

2012-09-17 Thread Thomas Rachel
Am 15.09.2012 18:20 schrieb Dan Katorza: hello again friends, thanks for everyone help on this. i guess i figured it out in two ways. the second one i prefer the most. i will appreciate if someone can give me some tips. thanks again so... ---

Re: Decorators not worth the effort

2012-09-18 Thread Thomas Rachel
Am 15.09.2012 16:18 schrieb 8 Dihedral: The concept of decorators is just a mapping from a function ... or class ... > to another function ... or any other object ... > with the same name in python. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: 'indent'ing Python in windows bat

2012-09-19 Thread Thomas Rachel
Am 18.09.2012 15:03 schrieb David Smith: I COULD break down each batch file and write dozens of mini python scripts to be called. I already have a few, too. Efficiency? Speed is bad, but these are bat files, after all. The cost of trying to work with a multitude of small files is high, though, a

Re: Using dict as object

2012-09-19 Thread Thomas Rachel
Am 19.09.2012 12:24 schrieb Pierre Tardy: One thing that is cooler with java-script than in python is that dictionaries and objects are the same thing. It allows browsing of complex hierarchical data syntactically easy. For manipulating complex jsonable data, one will always prefer writing: b

Re: which a is used?

2012-09-24 Thread Thomas Rachel
Am 25.09.2012 03:47 schrieb Dwight Hutto: But within a class this is could be defined as self.x within the functions and changed, correct? class a(): def __init__(self,a): self.a = a def f(self): print self.a def g(self):

Re: which a is used?

2012-09-24 Thread Thomas Rachel
Am 25.09.2012 04:37 schrieb Dwight Hutto: I honestly could not care less what you think about me, but don't use that term. This isn't a boys' club and we don't need your hurt ego driving people away from here. OH. stirrin up shit and can't stand the smell. Where did he so? Thoma

Re: python file API

2012-09-24 Thread Thomas Rachel
Am 25.09.2012 04:28 schrieb Steven D'Aprano: By the way, the implementation of this is probably trivial in Python 2.x. Untested: class MyFile(file): @property def pos(self): return self.tell() @pos.setter def pos(self, p): if p< 0: self.seek(p

Re: python file API

2012-09-24 Thread Thomas Rachel
Am 25.09.2012 00:37 schrieb Ian Kelly: On Mon, Sep 24, 2012 at 4:14 PM, Chris Angelico wrote: file.pos = 42 # Okay, you're at position 42 file.pos -= 10 # That should put you at position 32 foo = file.pos # Presumably foo is the integer 32 file.pos -= 100 # What should this do? Since ints are

Re: which a is used?

2012-09-24 Thread Thomas Rachel
Am 25.09.2012 07:22 schrieb Dwight Hutto: No, not really. If you wanna talk shit, I can reflect that, and if you wanna talk politely I can reflect that. I go t attacked first., But not in this thread. Some people read only selectively and see only your verbal assaults, without noticing that

Re: For Counter Variable

2012-09-24 Thread Thomas Rachel
Am 25.09.2012 01:39 schrieb Dwight Hutto: It's not the simpler solution I'm referring to, it's the fact that if you're learning, then you should be able to design the built-in, not just use it. In some simpler cases you are right here. But the fact that you are able to design it doesn't neces

Re: python file API

2012-09-25 Thread Thomas Rachel
Am 25.09.2012 10:13 schrieb Dennis Lee Bieber: Or some bit setting registers, like on ATxmega: OUT = 0x10 sets bit 7 and clears all others, OUTSET = 0x10 only sets bit 7, OUTTGL = 0x10 toggles it and OUTCLR = 0x10 clears it. Umpfzg. s/bit 7/bit 4/. I don't think I'd want to work with

Re: python file API

2012-09-25 Thread Thomas Rachel
Am 25.09.2012 09:28 schrieb Steven D'Aprano: The whole concept is incomplete at one place: self.seek(10, 2) seeks beyond EOF, potentially creating a sparse file. This is a thing you cannot achieve. On the contrary, since the pos attribute is just a wrapper around seek, you can seek beyond EOF

Re: data attributes override method attributes?

2012-09-25 Thread Thomas Rachel
Am 25.09.2012 16:08 schrieb Peter Otten: Jayden wrote: In the Python Tutorial, Section 9.4, it is said that "Data attributes override method attributes with the same name." The tutorial is wrong here. That should be "Instance attributes override class attributes with the same name." I jum

Re: fastest data structure for retrieving objects identified by (x, y) tuple?

2012-10-04 Thread Thomas Rachel
Am 04.10.2012 03:58 schrieb Steven D'Aprano: alist = [[None]*2400 for i in range(2400)] from random import randrange for i in range(1000): x = randrange(2400) y = randrange(2400) adict[(x, y)] = "something" alist[x][y] = "something" The actual sizes printed will depend on h

Re: overriding equals operation

2012-10-16 Thread Thomas Rachel
Am 16.10.2012 15:51 schrieb Pradipto Banerjee: I am trying to define class, where if I use a statement a = b, then instead of "a" pointing to the same instance as "b", it should point to a copy of "b", but I can't get it right. This is not possible. Currently, I have the following:

Re: Python does not take up available physical memory

2012-10-19 Thread Thomas Rachel
Am 19.10.2012 21:03 schrieb Pradipto Banerjee: Thanks, I tried that. What is "that"? It would be helpful to quote in a reasonable way. Look how others do it. Still got MemoryError, but at least this time python tried to use the physical memory. What I noticed is that before it gave me the e

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
Am 25.10.2012 01:39 schrieb Ian Kelly: On Wed, Oct 24, 2012 at 5:08 PM, Paul Rubin wrote: from itertools import dropwhile j = dropwhile(lambda j: j in selected, iter(lambda: int(random() * n), object())) .next() kind of ugly, makes me wish for a few more iterto

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
Am 25.10.2012 00:26 schrieb Cameron Simpson: If I could write this as: if re_FUNKYPATTERN.match(test_string) as m: do stuff with the results of the match, using "m" then some cascading parse decisions would feel a bit cleaner. Where I current have this: m = re_CONSTRUCT1.match(line

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
Am 25.10.2012 06:50 schrieb Terry Reedy: Keep in mind that any new syntax has to be a substantial improvement in some sense or make something new possible. There was no new syntax in 3.2 and very little in 3.3. I would consinder this at least as new substantial than yield_from it as oppo

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
Am 25.10.2012 09:21 schrieb Thomas Rachel: I think # iterate ad inf., because partial never returns None: i1 = iter(partial(randrange, n), None) # take the next value, make it None for breaking: i2 = (j if j in selected else None for j in i1) # and now, break on None: i3 = iter(lambda: next(i2

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
Am 25.10.2012 12:50 schrieb Steven D'Aprano: Then I think you have misunderstood the purpose of "yield from". Seems so. As I have not yet switched to 3.x, I haven't used it till now. [quote] However, if the subgenerator is to interact properly with the caller in the case of calls to send(),

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
Am 25.10.2012 16:15 schrieb Grant Edwards: I guess that depends on what sort of programs you write. In my experience, EXPR is usually a read from a file/socket/pipe that returns '' on EOF. If VAR is not '', then you process, then you process it inside the loop. Right. The same as in if regex

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
Am 25.10.2012 18:36 schrieb Ian Kelly: On Thu, Oct 25, 2012 at 1:21 AM, Thomas Rachel wrote: j = next(j for j in iter(partial(randrange, n), None) if j not in selected) This generator never ends. If it meets a non-matching value, it just skips it and goes on. next() only returns one value

Re: a.index(float('nan')) fails

2012-10-27 Thread Thomas Rachel
Am 27.10.2012 06:48 schrieb Dennis Lee Bieber: I don't know about the more modern calculators, but at least up through my HP-41CX, HP calculators didn't do (binary) "floating point"... They did a form of BCD with a fixed number of significant /decimal/ digits Then, what about sqrt(x)**

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

2012-10-27 Thread Thomas Rachel
Am 26.10.2012 09:49 schrieb 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

Re: Immutability and Python

2012-11-07 Thread Thomas Rachel
Am 29.10.2012 16:20 schrieb andrea crotti: Now on one hand I would love to use only immutable data in my code, but on the other hand I wonder if it makes so much sense in Python. You can have both. Many mutable types distinguish between them with their operators. To pick up your example,

Re: Obnoxious postings from Google Groups

2012-11-09 Thread Thomas Rachel
Am 31.10.2012 06:39 schrieb Robert Miles: For those of you running Linux: You may want to look into whether NoCeM is compatible with your newsreader and your version of Linux. This sounds as if it was intrinsically impossible to evaluate NoCeMs in Windows. If someone writes a software for

Re: Printing characters outside of the ASCII range

2012-11-11 Thread Thomas Rachel
Am 09.11.2012 18:17 schrieb danielk: I'm using this character as a delimiter in my application. Then you probably use the *byte* 254 as opposed to the *character* 254. So it might be better to either switch to byte strings, or output the representation of the string instead of itself. So d

Re: stackoverflow quote on Python

2012-11-13 Thread Thomas Rachel
Am 13.11.2012 14:21 schrieb wxjmfa...@gmail.com: * strings are now proper text strings (Unicode), not byte strings; Let me laugh. Do so. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-13 Thread Thomas Rachel
Am 09.11.2012 02:12 schrieb Hans Mulder: That's what 'xargs' will do for you. All you need to do, is invoke xargs with arguments containing '{}'. I.e., something like: cmd1 = ['tar', '-czvf', 'myfile.tgz', '-c', mydir, 'mysubdir'] first_process = subprocess.Popen(cmd1, stdout=subprocess.PIPE)

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-13 Thread Thomas Rachel
Am 12.11.2012 19:30 schrieb Hans Mulder: This will break if there are spaces in the file name, or other characters meaningful to the shell. If you change if to xargsproc.append("test -f '%s/{}'&& md5sum '%s/{}'" % (mydir, mydir)) , then it will only bre

Re: Python garbage collector/memory manager behaving strangely

2012-11-15 Thread Thomas Rachel
Am 17.09.2012 04:28 schrieb Jadhav, Alok: Thanks Dave for clean explanation. I clearly understand what is going on now. I still need some suggestions from you on this. There are 2 reasons why I was using self.rawfile.read().split('|\n') instead of self.rawfile.readlines() - As you have seen, t

Re: os.popen and the subprocess module

2012-11-29 Thread Thomas Rachel
Am 27.11.2012 19:00 schrieb Andrew: I'm looking into os.popen and the subprocess module, implementing os.popen is easy but i hear it is depreciating however I'm finding the implemantation of subprocess daunting can anyone help This is only the first impression. subprocess is much more powerfu

Re: Confused compare function :)

2012-12-06 Thread Thomas Rachel
Am 06.12.2012 09:49 schrieb Bruno Dupuis: The point is Exceptions are made for error handling, not for normal workflow. I hate when i read that for example: try: do_stuff(mydict[k]) except KeyError: pass I as well, but for other reasons (see below). But basically t

Re: forking and avoiding zombies!

2012-12-11 Thread Thomas Rachel
Am 11.12.2012 14:34 schrieb peter: On 12/11/2012 10:25 AM, andrea crotti wrote: Ah sure that makes sense! But actually why do I need to move away from the current directory of the parent process? In my case it's actually useful to be in the same directory, so maybe I can skip that part, or othe

Re: what’s the difference between socket.send() and socket.sendall() ?

2013-01-07 Thread Thomas Rachel
Am 07.01.2013 11:35 schrieb iMath: what’s the difference between socket.send() and socket.sendall() ? It is so hard for me to tell the difference between them from the python doc so what is the difference between them ? and each one is suitable for which case ? The docs are your friend. See

Re: How to modify this script?

2013-01-08 Thread Thomas Rachel
Am 06.01.2013 15:30 schrieb Kurt Hansen: Den 06/01/13 15.20, Chris Angelico wrote: On Mon, Jan 7, 2013 at 1:03 AM, Kurt Hansen wrote: I'm sorry to bother you, Chris, but applying the snippet with your code in Gedit still just deletes the marked, tab-separated text in the editor. Ah, whoops.

Re: How to modify this script?

2013-01-08 Thread Thomas Rachel
Am 07.01.2013 18:56 schrieb Gertjan Klein: (Watch out for line wraps! I don't know how to stop Thunderbird from inserting them.) Do "insert as quotation" (in German Thunderbird: "Als Zitat einfügen"), or Strg-Shift-O. Then it gets inserted with a ">" before and in blue. Just remove the > an

Re: please i need explanation

2013-01-11 Thread Thomas Rachel
Am 11.01.2013 17:33 schrieb kwakukwat...@gmail.com: def factorial(n): if n<2: return 1 f = 1 while n>= 2: f *= n f -= 1 return f please it works. I doubt this. If you give n = 4, you run into an endless loop. but don’t get why the ret

Re: i can't understand decorator

2013-01-15 Thread Thomas Rachel
Am 15.01.2013 15:20 schrieb contro opinion: >>> def deco(func): ... def kdeco(): ... print("before myfunc() called.") ... func() ... print(" after myfunc() called.") ... return kdeco ... >>> @deco ... def myfunc(): ... print(" myfunc() called.") ...

Re: Parsing a serial stream too slowly

2012-01-23 Thread Thomas Rachel
Am 23.01.2012 22:48 schrieb M.Pekala: Hello, I am having some trouble with a serial stream on a project I am working on. I have an external board that is attached to a set of sensors. The board polls the sensors, filters them, formats the values, and sends the formatted values over a serial bus.

FYI: Making python.exe capable to work with 3GiB address space

2012-01-24 Thread Thomas Rachel
Hi, I just added some RAM to my PC @ work and now wanted Python to be capable to make use of it. My boot.ini has been containing the /3GB switch for quite a while, but nevertheless I only could allocate 2 GB in Python. So I changed python.exe with the imagecfg.exe which I obtained from htt

Re: Parsing a serial stream too slowly

2012-01-24 Thread Thomas Rachel
Am 24.01.2012 00:13 schrieb Thomas Rachel: [sorry, my Thunderbird kills the indentation] And finally, you can make use of re.finditer() resp. sensorre.finditer(). So you can do sensorre = re.compile(r'\$(.)(.*?)\$') # note the change theonebuffer = '$A1234$$B-10$$C

Re: Popen in main and subprocess

2012-01-28 Thread Thomas Rachel
Am 28.01.2012 11:19 schrieb pistacchio: the following code (in the main thread) works well, I grep some files and the search until the first 100 results are found (writing the results to a file), then exit: command = 'grep -F "%s" %s*.txt' % (search_string, DATA_PATH) p = Popen(['/bin

Re: copy on write

2012-02-02 Thread Thomas Rachel
Am 13.01.2012 13:30 schrieb Chris Angelico: It seems there's a distinct difference between a+=b (in-place addition/concatenation) and a=a+b (always rebinding), There is indeed. a = a + b is a = a.__add__(b), while a += b is a = a.__iadd__(b). __add__() is supposed to leave the original obje

Re: atexit.register in case of errors

2012-02-15 Thread Thomas Rachel
Am 15.02.2012 14:52 schrieb Devin Jeanpierre: On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilson wrote: The usual way to do what you're asking is if __name__ == '__main__': main() goodbye() and write main so that it returns after it's done all the things it's supposed to do. If you've sprin

Re: Just curious: why is /usr/bin/python not a symlink?

2012-02-23 Thread Thomas Rachel
Am 23.02.2012 20:54 schrieb Jerry Hill: If I recall correctly, for directories, that's the number of entries in the directory. No. It is the number of subdirectories (it counts their ".." entries) plus 2 (the parent directory and the own "." entry). Even with that, it's hard to tell what

Re: Python is readable

2012-03-15 Thread Thomas Rachel
Am 15.03.2012 11:44 schrieb Kiuhnm: Let's try that. Show me an example of "list comprehensions" and "with" (whatever they are). with open("filename", "w") as f: f.write(stuff) with lock: do_something_exclusively() Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is readable

2012-03-15 Thread Thomas Rachel
Am 15.03.2012 12:48 schrieb Kiuhnm: On 3/15/2012 12:14, Thomas Rachel wrote: Am 15.03.2012 11:44 schrieb Kiuhnm: Let's try that. Show me an example of "list comprehensions" and "with" (whatever they are). with open("filename", "w") as f: f.writ

contextlib.nested deprecated

2012-03-23 Thread Thomas Rachel
Hi, I understand why contextlib.nested is deprecated. But if I write a program for an old python version w/o the multiple form of with, I have (nearly) no other choice. In order to avoid the following construct to fail: with nested(open("f1"), open("f2")) as (f1, f2): (f1 wouldn't be cl

Re: Documentation, assignment in expression.

2012-03-26 Thread Thomas Rachel
Am 25.03.2012 15:03 schrieb Tim Chase: Perhaps a DB example works better. With assignment allowed in an evaluation, you'd be able to write while data = conn.fetchmany(): for row in data: process(row) whereas you have to write while True: data = conn.fetchmany() if not data:

Re: Documentation, assignment in expression.

2012-03-26 Thread Thomas Rachel
Am 26.03.2012 00:59 schrieb Dennis Lee Bieber: If you use the longer form con = db.connect() cur = con.cursor() the cursor object, in all that I've worked with, does function for iteration I use this form regularly with MySQLdb and am now surprised to see that this is optional according to

Re: getaddrinfo NXDOMAIN exploit - please test on CentOS 6 64-bit

2012-04-01 Thread Thomas Rachel
Am 01.04.2012 06:31 schrieb John Nagle: In any case, this seems more appropriate for a Linux or a CentOS newsgroup/mailing list than a Python one. Please do not reply to this post in comp.lang.python. -o I expected that some noob would have a reply like that. You are unable to provide appro

Re: No os.copy()? Why not?

2012-04-02 Thread Thomas Rachel
Am 02.04.2012 23:11 schrieb HoneyMonster: One way: import os os.system ("cp src sink") Yes. The worst way you could imagine. Why not the much much better from subprocess subprocess.call(['cp', 'src', 'sink']) ? Then you can call it with (really) arbitrary file names: def call_cp(from, t

Re: No os.copy()? Why not?

2012-04-04 Thread Thomas Rachel
Am 03.04.2012 11:34 schrieb John Ladasky: I use subprocess.call() for quite a few other things. I just figured that I should use the tidier modules whenever I can. Of course. I only wanted to point out that os.system() is an even worse approach. shutils.copy() is by far better, of course. --

Re: ordering with duck typing in 3.1

2012-04-07 Thread Thomas Rachel
Am 07.04.2012 14:23 schrieb andrew cooke: class IntVar(object): def __init__(self, value=None): if value is not None: value = int(value) self.value = value def setter(self): def wrapper(stream_in, thunk): self.value = thunk() retur

Re: python module

2012-04-16 Thread Thomas Rachel
Am 16.04.2012 12:23 schrieb Kiuhnm: I'd like to share a module of mine with the Python community. I'd like to encourage bug reports, suggestions, etc... Where should I upload it to? Kiuhnm There are several ways to do this. One of them would be bitbucket. Thomas -- http://mail.python.org/mai

Re: why () is () and [] is [] work in other way?

2012-04-24 Thread Thomas Rachel
Am 24.04.2012 08:02 schrieb rusi: On Apr 23, 9:34 am, Steven D'Aprano wrote: "is" is never ill-defined. "is" always, without exception, returns True if the two operands are the same object, and False if they are not. This is literally the simplest operator in Python. Circular definition: In

Re: why () is () and [] is [] work in other way?

2012-04-25 Thread Thomas Rachel
Am 24.04.2012 15:25 schrieb rusi: Identity, sameness, equality and the verb to be are all about the same concept(s) and their definitions are *intrinsically* circular; see http://plato.stanford.edu/entries/identity/#2 Mybe in real life language. In programming and mathematics there are severa

Re: python3 raw strings and \u escapes

2012-05-30 Thread Thomas Rachel
Am 30.05.2012 08:52 schrieb ru...@yahoo.com: This breaks a lot of my code because in python 2 re.split (ur'[\u3000]', u'A\u3000A') ==> [u'A', u'A'] but in python 3 (the result of running 2to3), re.split (r'[\u3000]', 'A\u3000A' ) ==> ['A\u3000A'] I can remove the "r" prefix from

Re: post init call

2012-06-18 Thread Thomas Rachel
Am 18.06.2012 09:10 schrieb Prashant: class Shape(object): def __init__(self, shapename): self.shapename = shapename def update(self): print "update" class ColoredShape(Shape): def __init__(self, color): Shape.__init__(self, color) self.color =

Re: Multiprocessing.connection magic

2011-06-03 Thread Thomas Rachel
Am 03.06.2011 08:28 schrieb Claudiu Popa: Hello guys, While working at a dispatcher using multiprocessing.connection.Listener module I've stumbled upon some sortof magic trick that amazed me. How is this possible and what does multiprocessing library doing in backg

Re: Multiprocessing.connection magic

2011-06-03 Thread Thomas Rachel
Am 03.06.2011 08:59 schrieb Chris Angelico: I don't know how effective the pickling of functions actually is. Someone else will doubtless be able to fill that in. Trying to do so, I get (with several protocol versions): >>> import pickle >>> pickle.dumps(pickle.dumps) 'cpickle\ndumps\np0\n.'

Re: Something is rotten in Denmark...

2011-06-03 Thread Thomas Rachel
Am 03.06.2011 01:43 schrieb Gregory Ewing: It's not the lambda that's different from other languages, it's the for-loop. In languages that encourage a functional style of programming, the moral equivalent of a for-loop is usually some construct that results in a new binding of the control variab

Re: datetime.datetime and mysql different after python2.3

2011-06-03 Thread Thomas Rachel
Am 01.06.2011 20:42 schrieb Tobiah: I'm grabbing two fields from a MySQLdb connection. One is a date type, and one is a time type. So I put the values in two variables and print them: import datetime date, time = get_fields() # for example print str(type(date)), str((type(time))) print str(date

Re: Generator Frustration

2011-06-06 Thread Thomas Rachel
Am 04.06.2011 20:27 schrieb TommyVee: I'm using the SimPy package to run simulations. Anyone who's used this package knows that the way it simulates process concurrency is through the clever use of yield statements. Some of the code in my programs is very complex and contains several repeating se

Re: Call python function from Matlab

2011-06-08 Thread Thomas Rachel
Am 08.06.2011 07:12 schrieb nazmul.is...@gmail.com: I need to call a python function from a Matlab environment. Is it possible? Let's assume, I have the following python code: def squared(x): y = x * x return y I want to call squared(3) from Matlab workspace/code and get 9. Thanks f

Re: Call python function from Matlab

2011-06-08 Thread Thomas Rachel
Am 08.06.2011 09:19 schrieb Adam Przybyla: nazmul.is...@gmail.com wrote: I need to call a python function from a Matlab environment. Is it possible? Let's assume, I have the following python code: def squared(x): y = x * x return y I want to call squared(3) from Matlab workspace/code

Re: How good is security via hashing

2011-06-08 Thread Thomas Rachel
Am 08.06.2011 11:13 schrieb Robin Becker: we have been using base62 ie 0-9A-Za-z just to reduce the name length. Ugly concerning calculation. Then maybe better use radix32 - 0..9a..v, case-insensitive. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Unsupported operand type(s) for +: 'float' and 'tuple'

2011-06-12 Thread Thomas Rachel
Am 11.06.2011 03:02 schrieb Gabriel Genellina: Perhaps those names make sense in your problem at hand, but usually I try to use more meaningful ones. Until here we agree. > 0 and O look very similar in some fonts. That is right - but who would use such fonts for programming? Thomas -- htt

Re: Trying to chain processes together on a pipeline

2011-06-28 Thread Thomas Rachel
Am 28.06.2011 07:57 schrieb Andrew Berg: I'm working on an audio/video converter script (moving from bash to Python for some extra functionality), and part of it is chaining the audio decoder (FFmpeg) either into SoX to change the volume and then to the Nero AAC encoder or directly into the Nero

Re: keeping local state in an C extension module

2011-06-30 Thread Thomas Rachel
Am 30.06.2011 12:07 schrieb Daniel Franke: Here, of course, the functions PyObjectFromRawPointer(void*) and void* PyRawPointerFromPyObject(PyObject*) are missing. Is there anything like this in the Python C-API? If not, how could it be implemented? You could implement it as a separate class wh

Re: Does hashlib support a file mode?

2011-07-05 Thread Thomas Rachel
Am 06.07.2011 07:54 schrieb Phlip: Pythonistas: Consider this hashing code: import hashlib file = open(path) m = hashlib.md5() m.update(file.read()) digest = m.hexdigest() file.close() If the file were huge, the file.read() would allocate a big string and thrash memory. (Yes,

Re: parsing packets

2011-07-11 Thread Thomas Rachel
Am 10.07.2011 22:59 schrieb Littlefield, Tyler: Hello all: I'm working on a server that will need to parse packets sent from a client, and construct it's own packets. Are these packets sent as separate UDP packets or embedded in a TCP stream? In the first case, you already have packets and onl

Re: How to write a file generator

2011-07-12 Thread Thomas Rachel
Am 12.07.2011 16:46 schrieb Billy Mays: I want to make a generator that will return lines from the tail of /var/log/syslog if there are any, but my function is reopening the file each call ... I have another solution: an object which is not an iterator, but an iterable. class Follower(objec

Re: Code hosting services

2011-07-13 Thread Thomas Rachel
Am 13.07.2011 08:54 schrieb Andrew Berg: BTW, I'll likely be sticking with Mercurial for revision control. TortoiseHg is a wonderful tool set and I managed to get MercurialEclipse working well. In this case, I would recommend bitbucket. Thomas -- http://mail.python.org/mailman/listinfo/pytho

Re: Possible File iteration bug

2011-07-15 Thread Thomas Rachel
Am 14.07.2011 21:46 schrieb Billy Mays: I noticed that if a file is being continuously written to, the file generator does not notice it: Yes. That's why there were alternative suggestions in your last thread "How to write a file generator". To repeat mine: an object which is not an iterator

Re: Possible File iteration bug

2011-07-15 Thread Thomas Rachel
Am 15.07.2011 14:26 schrieb Billy Mays: I was thinking that a convenient solution to this problem would be to introduce a new Exception call PauseIteration, which would signal to the caller that there is no more data for now, but not to close down the generator entirely. Alas, an exception thr

Re: Possible File iteration bug

2011-07-15 Thread Thomas Rachel
Am 15.07.2011 14:52 schrieb Billy Mays: Also, in the python docs, file.next() mentions there being a performance gain for using the file generator (iterator?) over the readline function. Here, the question is if this performance gain is really relevant AKA "feelable". The file object seems to

Re: Possible File iteration bug

2011-07-15 Thread Thomas Rachel
Am 15.07.2011 16:42 schrieb Billy Mays: A sentinel does provide a work around, but it also passes the problem onto the caller rather than the callee: That is right. BTW, there is another, maybe easier way to do this: for line in iter(f.readline, ''): do_stuff(line) This provides an ite

Re: Possible File iteration bug

2011-07-17 Thread Thomas Rachel
Am 16.07.2011 05:42 schrieb Steven D'Aprano: You are right - it is a very big step for a very small functionality. Or you can look at the various recipes on the Internet for writing tail-like file viewers in Python, and solve the problem the boring old fashioned way. It is not only about thi

Re: Question about timeit

2011-07-22 Thread Thomas Rachel
Am 22.07.2011 08:59 schrieb Frank Millman: My guess is that it is something to do with the console, but I don't know what. If I get time over the weekend I will try to get to the bottom of it. I would guess that in the first case, python (resp. timeit.py) gets the intended code for execution:

Re: PEP 8 and extraneous whitespace

2011-07-22 Thread Thomas Rachel
Am 22.07.2011 00:45 schrieb Terry Reedy: Whether or not they are intended, the rationale is that lining up does not work with proportional fonts. Who on earth would use proportional fonts in programming?! -- http://mail.python.org/mailman/listinfo/python-list

Re: Only Bytecode, No .py Files

2011-07-27 Thread Thomas Rachel
Am 26.07.2011 17:19 schrieb Eldon Ziegler: Is there a way to have the Python processor look only for bytecode files, not .py files? We are seeing huge numbers of Linux audit messages on production system on which only bytecode files are stored. The audit subsystem is recording each open failure.

Re: Only Bytecode, No .py Files

2011-07-27 Thread Thomas Rachel
Am 27.07.2011 14:18 schrieb John Roth: Two comments. First, your trace isn't showing attempts to open .py files, it's showing attempts to open the Curses library in the bash directory. Of course. My goal was to show that the OP's "problem" is not a python one, but occurs all over several prog

Re: Is it bad practise to write __all__ like that

2011-07-28 Thread Thomas Rachel
Am 28.07.2011 13:32 schrieb Karim: Hello, __all__ = 'api db input output tcl'.split() or __all__ = """ api db input output tcl """.split() for lazy boy ;o). It is readable as well. What do you think? Why not? But you could even do class AllList(list): """list which can be called in or

  1   2   3   >