Re: Can Python function return multiple data?

2015-06-03 Thread Thomas Rachel
Am 03.06.2015 um 01:56 schrieb Chris Angelico: and it's pretty convenient. In C, the nearest equivalent is passing a number of pointers as parameters, and having the function fill out values. Python's model is a lot closer to what you're saying than C's model is :) At least, C functions can re

Re: subprocess.Popen zombie

2015-05-20 Thread Thomas Rachel
Am 20.05.2015 um 18:44 schrieb Robin Becker: not really, it's just normal to keep event routines short; the routine which beeps is after detection of the cat's entrance into the house and various recognition schemes have pronounced intruder :) You could add a timed "cleanup" routine which .wai

Re: Why does the first loop go wrong with Python3

2015-05-19 Thread Thomas Rachel
Am 19.05.2015 um 15:16 schrieb Oscar Benjamin: However the normal way to do this is to iterate over stdout directly: Depends. There may be differences when it comes to buffering etc... Thomas -- https://mail.python.org/mailman/listinfo/python-list

Re: Rule of order for dot operators?

2015-05-18 Thread Thomas Rachel
Am 16.05.2015 um 21:20 schrieb C.D. Reimer: Does python perform the dot operators from left to right or according to a rule of order (i.e., multiplication/division before add/subtract)? In this case, it does the only thing it can do: title = slug.replace('-',' ').title() is performed as * t

Re: Basic misunderstanding on object creation

2015-05-13 Thread Thomas Rachel
Am 13.05.2015 um 15:25 schrieb andrew cooke: class Foo: ... def __new__(cls, *args, **kargs): ... print('new', args, kargs) ... super().__new__(cls, *args, **kargs) new (1,) {} Traceback (most recent call last): File "", line 1, in File "", line 4, in __new__ TypeE

Re: Python Worst Practices

2015-03-06 Thread Thomas Rachel
Am 26.02.2015 01:37 schrieb Chris Angelico: My bad. I was talking in a context of Python programming, specifically with APIs where you would use some kind of true/false flag as either a function parameter or a return value. Oh. Then take subprocess.Popen.wait()... :-P Thomas -- https://mail.

Re: Md5 is different in Windows and Linux

2015-03-02 Thread Thomas Rachel
Am 02.03.2015 20:14 schrieb sohcahto...@gmail.com: On Monday, March 2, 2015 at 12:43:59 AM UTC-8, Sarvagya Pant wrote: f = open("somefile.txt") This one is the problem. Under Windows, you have to open the file in binary to avoid that something "bad" happens with it. So just do f = open("

Re: why can't download file from linux server into local window disk c:

2014-12-09 Thread Thomas Rachel
Am 08.12.2014 19:11 schrieb Luuk: > no, it's the ssh-server denying a log on from 'root' You are repating yourself. How could possibly with open(localpath, 'wb') as fl: PermissionError: [Errno 13] Permission denied: 'c:' be a problem with the SSH server? --- SoupGate-Win32 v1.05 * Origi

Re: why can't download file from linux server into local window disk c:

2014-12-09 Thread Thomas Rachel
Am 09.12.2014 09:14 schrieb pengsir: > My vps ip is x.y.z.w ,i want to download /etc/passwd from linux server > into my local window disk c: . > localpath = 'c:' [...] > with open(localpath, 'wb') as fl: > PermissionError: [Errno 13] Permission denied: 'c:' That's completely clear: you ar

Re: Question on lambdas

2014-12-09 Thread Thomas Rachel
Am 09.12.2014 04:09 schrieb memilanuk: so in the first example in my original post: ... lambda: update_label2('A', 100) would this work the same? It looks as though it'd be passing the same two parameters to the same function... lambda: 'A', 100: update_label2() No. Even if it would be all

Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread Thomas Rachel
Am 08.12.2014 19:11 schrieb Luuk: no, it's the ssh-server denying a log on from 'root' You are repating yourself. How could possibly with open(localpath, 'wb') as fl: PermissionError: [Errno 13] Permission denied: 'c:' be a problem with the SSH server? -- https://mail.python.org/mailman

Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread Thomas Rachel
Am 09.12.2014 09:14 schrieb pengsir: My vps ip is x.y.z.w ,i want to download /etc/passwd from linux server into my local window disk c: . localpath = 'c:' [...] with open(localpath, 'wb') as fl: PermissionError: [Errno 13] Permission denied: 'c:' That's completely clear: you are n

Re: io.UnsupportedOperation: fileno

2014-11-14 Thread Thomas Rachel
Am 14.11.2014 00:42 schrieb satishmlm...@gmail.com: fileno() in not supported. Is it only in 3.1? What is the workaround? You have been asked many times about the details of your environment. Especially, you have been told that it is important to know if you directly use the Python CLI or som

Re: %%(%s)s mean in python

2014-10-29 Thread Thomas Rachel
Am 29.10.2014 07:02 schrieb satishmlm...@gmail.com: What does %%(%s)s mean in Python? Weird question, as this has nothing to do with the code you just posted. In general, what comes up to my mind, is that it is a format string to build another format string. Example: metafmt = '%%(%s)s' f

Re: Iterator, modify data in loop body

2014-09-16 Thread Thomas Rachel
Am 13.09.2014 09:22 schrieb Chris Angelico: In that case, don't iterate over the list at all. Do something like this: while lst: element = lst.pop(0) # work with element lst.append(new_element) And if you don't like that, define a def iter_pop(lst): while lst: yiel

Re: Thread-ID - how much could be?

2014-09-16 Thread Thomas Rachel
Am 11.09.2014 23:32 schrieb Ervin Hegedüs: There is no upper limit to the thread name other than that you will eventually run out of memory ;) thanks - I hope that the memory will not run out by these threads... :) Anyway, that means, on my system: import sys print sys.maxint 9223372036854

Re: 'is not' or '!='

2014-08-21 Thread Thomas Rachel
Am 20.08.2014 13:17 schrieb Chris Angelico: That's true, but how easy is it to annotate a file with each line's author (or, at least, to figure out who wrote some particular line of code)? It's easy enough with 'git blame' or 'hg blame', and it wouldn't surprise me if bzr had a similar feature;

Re: 'is not' or '!='

2014-08-19 Thread Thomas Rachel
Am 18.08.2014 22:53 schrieb Marko Rauhamaa: Frankly, I don't know of any other object that is "==" to the None object except None itself, but such objects could possible exist. class ImitatingNone(object): def __eq__(self, other): return True # is equal to everything else r

Re: 'is not' or '!='

2014-08-19 Thread Thomas Rachel
Am 19.08.2014 00:04 schrieb Chris Kaynor: In each of these cases, the behavior may be different in other implementations or versions of Python. And, the most important thing, in each of these cases, using "is" is semantically wrong, so no matter how different versions behave. If you ask the

Re: Iterating through set

2014-07-17 Thread Thomas Rachel
Am 15.07.2014 02:10 schrieb LJ: Hi All. I'm coding a Dynamic Programming algorithm to solve a network flow problem. At some point in the algorithm I have to iterate through a set of nodes, while adding and/or removing elements, until the set is empty. I know a regular set() object does not wo

Re: Python's re module and genealogy problem

2014-06-11 Thread Thomas Rachel
Am 11.06.2014 14:23 schrieb BrJohan: Can it, for a pair of regular expressions be decided whether at least one string matching both of those regular expressions, can be constructed? If it is possible to make such a decision, then how? Anyone aware of an algorithm for this? Just a feeling-base

Re: try/except/finally

2014-06-10 Thread Thomas Rachel
Am 08.06.2014 05:58 schrieb Rustom Mody: Some people¹ think that gotos are a code-smell. ¹ I am not exactly those people. A chap called E W Dijkstra made the statement: "Goto statement considered harmful" and became famous. And became widely misunderstood. If anybody would read the whole what

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-13 Thread Thomas Rachel
Am 13.01.2014 10:54 schrieb wxjmfa...@gmail.com: Not at all. I'm afraid I'm understanding Python (on this aspect very well). IBTD. Do you belong to this group of people who are naively writing wrong Python code (usually not properly working) during more than a decade? Why should I be? 'ß

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

2014-01-13 Thread Thomas Rachel
Am 12.01.2014 08:50 schrieb wxjmfa...@gmail.com: 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' Wow. You just found one of the major differences between Python 2 and 3. Your assertins are just wrong, as s = '

Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Thomas Rachel
Am 09.11.2013 14:27 schrieb Joshua Landau: `select` is quite an odd statement, in that in most cases it's just a weaker variant of `if`. By the time you're at the point where a `select` is actually more readable you're also at the point where a different control flow is probably a better idea. T

Re: Is there a function that applies list of functions to a value?

2013-08-28 Thread Thomas Rachel
Am 2013-08-28 14:52 schrieb AdamKal: Hi, From time to time I have to apply a series of functions to a value in such a way: func4(func3(func2(func1(myval I was wondering if there is a function in standard library that would take a list of functions and a initial value and do the above li

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: 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: 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: 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: is "_io.py" missing from 2.7.4 ?

2013-04-08 Thread Thomas Rachel
Am 08.04.2013 15:42 schrieb dbv: Ah, okay. Then on Windows, _io.pyd should be in the /DLLs folder but it isn't there ? It seems to be a built-in module: >>> import _io >>> _io alike to >>> import __builtin__ >>> __builtin__ as opposed to >>> import win32ui >>> win32ui 'C:\Python27\lib\

Re: del not working for (exhausted) dict iterable value (Python 3.3)

2013-03-12 Thread Thomas Rachel
Am 12.03.2013 06:52 schrieb alex23: You're effectively doing this: event = dict(Items=[1,2,3]) for e in event['Items']: ... del event['Items'] ... Traceback (most recent call last): File "", line 2, in KeyError: 'Items' You want to move your del statement up an indentation level so i

Re: This mail never gets delivered. Any ideas why?

2013-03-11 Thread Thomas Rachel
Am 10.03.2013 19:39 schrieb Νίκος Γκρ33κ: Hey man this worked via Python! [...] if( os.system( 'echo "%s" | mail -s "%s" supp...@superhost.gr' % (MESSAGE, FROM) ) ): [...] Thank you! I beleive this is the simplest way of sending an email! Until you get a MESSAGE which

Re: This mail never gets delivered. Any ideas why?

2013-03-11 Thread Thomas Rachel
Am 11.03.2013 10:15 schrieb nagia.rets...@gmail.com: Thank you Thomas but that simple line as i have it now its capable of sending mail successfully Obviously not, otherwise you wouldn't ask, would you? Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: This mail never gets delivered. Any ideas why?

2013-03-10 Thread Thomas Rachel
Am 11.03.2013 06:47 schrieb Thomas Rachel: # either message.add_header('Subject', email.quoprimime.header_encode(SUBJECT)) # or message.add_header('Subject', email.base64mime.header_encode(SUBJECT)) Sorry! These were completely wrong. # either message

Re: This mail never gets delivered. Any ideas why?

2013-03-10 Thread Thomas Rachel
Am 11.03.2013 06:25 schrieb Thomas Rachel: 1. Your subject is not properly encoded. All characters outside the ASCII area must be encoded in an appropriate way if you send an email. It MIGHT be the case that sendmail handles this for you, but probably not every version. Mine not, at least

Re: This mail never gets delivered. Any ideas why?

2013-03-10 Thread Thomas Rachel
Am 09.03.2013 22:20 schrieb Νίκος Γκρ33κ: SENDMAIL = '/usr/sbin/sendmail' FROM = mail TO = ['supp...@superhost.gr'] SUBJECT = "Επικοινωνία πιθανού πελάτη!" TEXT = comment mess

Re: "The urlopen() and urlretrieve() functions can cause arbitrarily long delays"

2013-02-24 Thread Thomas Rachel
Am 24.02.2013 20:27 schrieb 7segment: When in doubt, check some other way, such as with a browser. Thank you Ian. Browser is not a good idea, because I need this tool to work automatically. I don't have time to check and compare the response times manually and put them into the database. Of

Re: improving performance of writing into a pipe

2013-02-18 Thread Thomas Rachel
Am 18.02.2013 17:31 schrieb mikp...@gmail.com: However I get an exception while trying to open the queue: fout = open('/tmp/mypipe', 'w') I don't see an exception in your answer. Where did you put it for us? I have tried it in a command line and the call doesn't return until in another ter

Re: inheritance and how to use it

2013-02-15 Thread Thomas Rachel
Am 15.02.2013 17:59 schrieb Bob Brusa: Hi, I use a module downloaded from the net. Now I want to build my own class, based on the class SerialInstrument offered in this module - and in my class I would like to initialize a few things, using e. g. the method clear() offered by SerialInstrument. He

Re: Implicit conversion to boolean in if and while statements

2013-02-10 Thread Thomas Rachel
Am 10.02.2013 12:37 schrieb Steven D'Aprano: So, in Python 4000, my vote is for set literals { } to create frozensets, and if you want a mutable set, you have to use the set() type directly. 4000 sounds about long future. In the meanwhile, a new syntax element could be introduced fpr frozens

Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Thomas Rachel
Am 08.02.2013 07:29 schrieb Rick Johnson: Consider this: if connect("my:db") as db: No need to make a call and then test for the validity of the call when you can do both simultaneously AND intuitively. Would be great, but can be emulated with def ifiter(x): if x: yield

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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 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 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 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: '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: 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: 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-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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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. --

  1   2   3   >