Re: Evaluation of variable as f-string

2023-01-29 Thread Johannes Bauer
Am 29.01.23 um 05:27 schrieb Thomas Passin: Well, yes, we do see that.  What we don't see is what you want to accomplish by doing it, and why you don't seem willing to accept some restrictions on the string fragments so that they will evaluate correctly. I'll have to accept the restrictions.

Re: Evaluation of variable as f-string

2023-01-29 Thread Johannes Bauer
Am 29.01.23 um 02:09 schrieb Chris Angelico: The exact same points have already been made, but not listened to. Sometimes, forceful language is required in order to get people to listen. An arrogant bully's rationale. Personally, I'm fine with it. I've been to Usenet for a long time, in which

Re: Evaluation of variable as f-string

2023-01-28 Thread Johannes Bauer
Am 27.01.23 um 23:10 schrieb Christian Gollwitzer: Am 27.01.23 um 21:43 schrieb Johannes Bauer: I don't understand why you fully ignore literally the FIRST example I gave in my original post and angrily claim that you solution works when it does not: x = { "y": "z" } s =

Re: Evaluation of variable as f-string

2023-01-28 Thread Johannes Bauer
Am 28.01.23 um 00:41 schrieb Chris Angelico: On Sat, 28 Jan 2023 at 10:08, Rob Cliffe via Python-list wrote: Whoa! Whoa! Whoa! I appreciate the points you are making, Chris, but I am a bit taken aback by such forceful language. The exact same points have already been made, but not listened

Re: Evaluation of variable as f-string

2023-01-28 Thread Johannes Bauer
Am 28.01.23 um 02:51 schrieb Thomas Passin: This is literally the version I described myself, except using triple quotes. It only modifies the underlying problem, but doesn't solve it. Ok, so now we are in the territory of "Tell us what you are trying to accomplish". And part of that is why

Re: Evaluation of variable as f-string

2023-01-27 Thread Johannes Bauer
Am 27.01.23 um 20:18 schrieb Chris Angelico: All you tell us is what you're attempting to do, which there is *no good way to achieve*. Fair enough, that is the answer. It's not possible. Perhaps someone will be inspired to write a function to do it.  See, we don't know what "it" is, so

Re: Evaluation of variable as f-string

2023-01-27 Thread Johannes Bauer
Am 23.01.23 um 17:43 schrieb Stefan Ram: Johannes Bauer writes: x = { "y": "z" } s = "-> {x['y']}" print(s.format(x = x)) x = { "y": "z" } def s( x ): return '-> ' + x[ 'y' ] print( s( x = x )) Except this is not at all

Re: Evaluation of variable as f-string

2023-01-27 Thread Johannes Bauer
Am 25.01.23 um 20:38 schrieb Thomas Passin: x = { "y": "z" } s = "-> {target}" print(s.format(target = x['y'])) Stack overflow to the rescue: No. Search phrase:  "python evaluate string as fstring" https://stackoverflow.com/questions/47339121/how-do-i-convert-a-string-into-an-f-string

Re: Evaluation of variable as f-string

2023-01-27 Thread Johannes Bauer
Am 23.01.23 um 19:02 schrieb Chris Angelico: This is supposedly for security reasons. However, when trying to emulate this behavior that I wanted (and know the security implications of), my solutions will tend to be less secure. Here is what I have been thinking about: If you really want the

Evaluation of variable as f-string

2023-01-23 Thread Johannes Bauer
Hi there, is there an easy way to evaluate a string stored in a variable as if it were an f-string at runtime? I.e., what I want is to be able to do this: x = { "y": "z" } print(f"-> {x['y']}") This prints "-> z", as expected. But consider: x = { "y": "z" } s = "-> {x['y']}"

Creating lambdas inside generator expression

2022-06-29 Thread Johannes Bauer
Hi list, I've just encounted something that I found extremely unintuitive and would like your feedback. This bit me *hard*, causing me to question my sanity for a moment. Consider this minimal example code (Py 3.10.4 on Linux x64): class Msg(): def hascode(self, value):

Re: Creating lambdas inside generator expression

2022-06-29 Thread Johannes Bauer
Aha! conds = [ lambda msg, z = z: msg.hascode(z) for z in ("foo", "bar") ] Is what I was looking for to explicitly use the value of z. What a caveat, didn't see that coming. Learning something new every day. Cheers, Joe Am 29.06.22 um 11:50 schrieb Johannes Bauer: >

Re: threading and multiprocessing deadlock

2021-12-06 Thread Johannes Bauer
Am 06.12.21 um 13:56 schrieb Martin Di Paola: > Hi!, in short your code should work. > > I think that the join-joined problem is just an interpretation problem. > > In pseudo code the background_thread function does: > > def background_thread() >   # bla >   print("join?") >   # bla >  

threading and multiprocessing deadlock

2021-12-05 Thread Johannes Bauer
Hi there, I'm a bit confused. In my scenario I a mixing threading with multiprocessing. Threading by itself would be nice, but for GIL reasons I need both, unfortunately. I've encountered a weird situation in which multiprocessing Process()es which are started in a new thread don't actually start

'%Y' in strftime() vs. strptime()

2019-12-29 Thread Johannes Bauer
Hi list, I've just stumbled upon a strange phaenomenon and I'm wondering if it's a bug. Short and sweet: Python 3.7.3 (default, Oct 7 2019, 12:56:13) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from datetime import datetime as d >>> x = d(1,

Handling of disconnecting clients in asyncio

2019-09-24 Thread Johannes Bauer
Hi group, I'm trying to get into async programming using Python. Concretely I open a UNIX socket server in my application. The UNIX socket server generates events and also receives commands/responds to them. I do this by: async def _create_local_server(self): await

Re: GPG wrapper, ECC 25519 compatible?

2019-09-03 Thread Johannes Bauer
On 03.09.19 05:28, rmli...@riseup.net wrote: > But I just don't understand how to get > and pass information back to the gpg command line prompts at all, not to > mention automating the process. The manpage describes how to enable the machine-parsable interface, which is exactly what you want.

Pythonic custom multi-line parsers

2019-07-10 Thread Johannes Bauer
Hi list, I'm looking for ideas as to a pretty, Pythonic solution for a specific problem that I am solving over and over but where I'm never happy about the solution in the end. It always works, but never is pretty. So see this as an open-ended brainstorming question. Here's the task: There's a

Re: Curious case of UnboundLocalError

2018-03-31 Thread Johannes Bauer
On 30.03.2018 16:46, Ben Bacarisse wrote: >> Yup, but why? I mean, at the point of definition of "z", the only >> definition of "collections" that would be visible to the code would be >> the globally imported module, would it not? How can the code know of the >> local declaration that only comes

Re: Curious case of UnboundLocalError

2018-03-30 Thread Johannes Bauer
On 30.03.2018 13:25, Johannes Bauer wrote: >> This mention of collections refers to ... >> >>> } >>> for (_, collections) in z.items(): >> >> ... this local variable. > > Yup, but why? I mean, at the point of definiti

Re: Curious case of UnboundLocalError

2018-03-30 Thread Johannes Bauer
On 30.03.2018 13:13, Ben Bacarisse wrote: >> import collections >> >> class Test(object): >> def __init__(self): >> z = { >> "y": collections.defaultdict(list), > > This mention of collections refers to ... > >> } >> for (_,

Curious case of UnboundLocalError

2018-03-30 Thread Johannes Bauer
Hey group, I stumbled about something that I cannot quite explain while doing some stupid naming of variables in my code, in particular using "collections" as an identifier. However, what results is strange. I've created a minimal example. Consider this: import collections class Test(object):

Re: Entering a very large number

2018-03-23 Thread Johannes Bauer
On 23.03.2018 14:01, ast wrote: > It is not beautiful and not very readable. It is better to > have a fixed number of digits per line (eg 50) Oh yes, because clearly a 400-digit number becomes VERY beautiful and readable once you add line breaks to it. Cheers, Joe -- >> Wo hattest Du das

Brainstorming on recursive class definitions

2017-09-12 Thread Johannes Bauer
Hi group, so I'm having a problem that I'd like to solve *nicely*. I know plenty of ways to solve it, but am curious if there's a solution that allows me to write the solution in a way that is most comfortable for the user. I'm trying to map registers of a processor. So assume you have a n bit

Lexer/Parser question: TPG

2016-11-14 Thread Johannes Bauer
Hi group, this is not really a Python question, but I use Python to lex/parse some input. In particular, I use the amazing TPG (http://cdsoft.fr/tpg/). However, I'm now stuck at a point and am sure I'm not doing something correctly -- since there's a bunch of really smart people here, I hope to

[issue20491] textwrap: Non-breaking space not honored

2016-10-03 Thread Johannes Bauer
Johannes Bauer added the comment: Hey there, wanted to follow up on the state of this... is there a reason why this has not made it into vanilla yet? If so, I'd like to try to help out clear impediments if I can. This issue is *really*, really, really annoying me. I've posted about a year

Re: Magic UTF-8/Windows-1252 encodings

2016-08-30 Thread Johannes Bauer
On 29.08.2016 17:59, Chris Angelico wrote: > Fair enough. If this were something that a lot of programs wanted, > then yeah, there'd be good value in stdlibbing it. Character encodings > ARE hard to get right, and this kind of thing does warrant some help. > But I think it's best not done in core

Zero runtime impact tracing

2016-07-30 Thread Johannes Bauer
Hi group, I'm using CPython 3.5.1. Currently I'm writing some delicate code that is doing the right thing in 99% of the cases and screws up on the other 1%. I would like to have tracing in some very inner loops: if self._debug: print("Offset %d foo bar" % (self._offset)) However, this

Re: value of pi and 22/7

2016-06-18 Thread Johannes Bauer
On 18.06.2016 01:12, Lawrence D’Oliveiro wrote: > I’m not sure how you can write “30” with one digit... 3e1 has one significant digit. Cheers, Johannes -- >> Wo hattest Du das Beben nochmal GENAU vorhergesagt? > Zumindest nicht öffentlich! Ah, der neueste und bis heute genialste Streich

pytz and Python timezones

2016-06-11 Thread Johannes Bauer
Hi there, first off, let me admit that I have a hard time comprehensively wrapping my head around timezones. Everything around them is much more complicated than it seems, IMO. That said, I'm trying to do things the "right" way and stumbled upon some weird issue which I can't explain. I'm unsure

Re: What is heating the memory here? hashlib?

2016-02-15 Thread Johannes Bauer
On 15.02.2016 03:21, Paulo da Silva wrote: > So far I tried the program twice and it ran perfectly. I think you measured your RAM consumption wrong. Linux uses all free RAM as HDD cache. That's what is used in "buffers". That is, it's not "free", but it would be free if any process would

Re: raise None

2016-01-02 Thread Johannes Bauer
On 31.12.2015 21:18, Ben Finney wrote: > As best I can tell, Steven is advocating a way to obscure information > from the traceback, on the assumption the writer of a library knows that > I don't want to see it. How do you arrive at that conclusion? The line that raises the exception is exactly

Re: raise None

2015-12-31 Thread Johannes Bauer
On 31.12.2015 01:09, Steven D'Aprano wrote: > Obviously this doesn't work now, since raise None is an error, but if it did > work, what do you think? I really like the idea. I've approached a similar problem with a similar solution (also experimented with decorators), but the tracebacks really

Understanding WSGI together with Apache

2015-10-10 Thread Johannes Bauer
Hi there, I'm running an Apache 2.4 webserver using mod_wsgi 4.3.0. There are two different applications running in there running on two completely separate vhosts. I'm seeing some weird crosstalk between them which I do not understand. In particular, crosstalk concerning the locales of the two.

Re: RPI.GPIO Help

2015-09-01 Thread Johannes Bauer
On 31.08.2015 19:41, John McKenzie wrote: > Still checking here and am discussing all this in the Raspberry pi > newsgroup. Thanks to the several people who mentioned it. > > Again, still listening here if anyone has any more to add. I've had the problem to use interrupt-driven GPIOs on the

Re: Sometimes bottle takes a lot of time

2015-08-23 Thread Johannes Bauer
On 22.08.2015 16:15, Christian Gollwitzer wrote: Probably yes. You should take a look at the OP again and compare the time stamps. It says that in between two consecutive calls of the same program, the request was served once in a second, and once with serious delays. Despite that the server

Re: Sometimes bottle takes a lot of time

2015-08-23 Thread Johannes Bauer
On 23.08.2015 18:47, Michael Torrie wrote: Since this is an ajax thing, I can entirely understand that Firefox introduces random delays. Practically all ajax-heavy sites I've ever used has had random slowdowns in Firefox. This would imply that random six-second delays have somehow passed the

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Johannes Bauer
On 21.08.2015 23:22, Cecil Westerhof wrote: Just before everything was done in a second: Since you're on GitHub, why don't you git bisect and find out where you screwed up instead of trying to get people to remotely debug and profile your broken code? Cheers, Johannes -- Wo hattest Du das

Re: Every character of a string becomes a binding

2015-08-22 Thread Johannes Bauer
On 21.08.2015 19:04, Cecil Westerhof wrote: Because the execute method expects the bindings to be passed as a sequence, Yeah, I found that. I solved it a little differently: urls = c.execute('SELECT URL FROM links WHERE URL = ?', [url]).fetchall() You continuously ask more than

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Johannes Bauer
On 22.08.2015 13:28, Cecil Westerhof wrote: If you would have taken a little more time you would have seen that there where 20 seconds between both logs. I am fast, but not that fast. It is exactly the same code. I suppose it has to do something with bottle. Something I use since yesterday.

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Johannes Bauer
On 22.08.2015 15:09, Cecil Westerhof wrote: So let me get your story straight: I wish you really meant that. I really do, did I get it wrong at all? I really don't think that I did. Also: take a course in reading. Maybe you, oh very wise Senior Software Engineer, should take a course in

Re: Searching for a usable X509 implementation

2015-07-06 Thread Johannes Bauer
On 05.07.2015 07:33, Laura Creighton wrote: For an RSA key in PEM format you can do: from OpenSSL.crypto import _new_mem_buf, _lib, _bio_to_string def dump_rsa_public_key(pkey): bio = _new_mem_buf() result = _lib.PEM_write_bio_RSAPublicKey(bio, _lib.EVP_PKEY_get1_RSA(pkey._

Re: Pure Python Data Mangling or Encrypting

2015-06-27 Thread Johannes Bauer
On 27.06.2015 10:53, Chris Angelico wrote: On Sat, Jun 27, 2015 at 6:38 PM, Steven D'Aprano st...@pearwood.info wrote: I'm not a security expert. I'm not even a talented amateur. *Every time* I suggest that X is secure, the security guy at work shoots me down in flames. But nicely, because I

Re: Pure Python Data Mangling or Encrypting

2015-06-27 Thread Johannes Bauer
On 27.06.2015 10:38, Steven D'Aprano wrote: Can you say timing attack? http://codahale.com/a-lesson-in-timing-attacks/ Can you [generic you] believe that attackers can *reliably* attack remote systems based on a 20µs timing differences? If you say No, then you fail Security 101 and

Re: Pure Python Data Mangling or Encrypting

2015-06-27 Thread Johannes Bauer
On 27.06.2015 11:27, Jon Ribbens wrote: Johannes might have all the education in the world, but he's demonstrated quite comprehensively in this thread that he doesn't have a clue what he's talking about. Oh, how hurtful. I might even shed a tear or two, but it's pretty clear to me that you're

Re: Pure Python Data Mangling or Encrypting

2015-06-27 Thread Johannes Bauer
On 27.06.2015 11:17, Chris Angelico wrote: Good, so this isn't like that episode of Yes Minister when they were trying to figure out whether to allow a chemical factory to be built. I must admit that I have no clue about that show or that epsisode in particular and needed to read up on it:

Re: Pure Python Data Mangling or Encrypting

2015-06-27 Thread Johannes Bauer
On 27.06.2015 12:16, Chris Angelico wrote: Okay, Johannes, NOW you're proving that you don't have a clue what you're talking about. D-K effect doesn't go away... :-D It does in some people. I've seen it happen, with knowledge comes humility. Not saying Jon is a lost cause just yet. He's just

Re: Pure Python Data Mangling or Encrypting

2015-06-26 Thread Johannes Bauer
On 26.06.2015 22:09, Randall Smith wrote: You've gone on a rampage about nothing. My original description said the client was supposed to encrypt the data, but you want to assume the opposite for some unknown reason. While you seem to think that Steven is rampaging about nothing, he does

Re: Pure Python Data Mangling or Encrypting

2015-06-26 Thread Johannes Bauer
On 26.06.2015 22:09, Randall Smith wrote: And that's why we're having this discussion. Do you know of an attack in which you can control the output (say at least 100 consecutive bytes) for data which goes through a 256 byte translation table, chosen randomly from 256! permutations after the

Re: Pure Python Data Mangling or Encrypting

2015-06-26 Thread Johannes Bauer
On 26.06.2015 23:29, Jon Ribbens wrote: While you seem to think that Steven is rampaging about nothing, he does have a fair point: You consistently were vague about wheter you want to have encryption, authentication or obfuscation of data. This suggests that you may not be so sure yourself

Re: Pure Python Data Mangling or Encrypting

2015-06-26 Thread Johannes Bauer
On 27.06.2015 02:55, Randall Smith wrote: No the attacker does not have access to the ciphertext. What would lead you to think they did? Years of practical experience in the field of applied cryptography. Knowledge of how side channels work and how easily they can be constructed for bad

Re: Jython and can't write cache file

2015-06-21 Thread Johannes Bauer
On 21.06.2015 11:40, Cecil Westerhof wrote: Thanks. Good that I asked it. :-D Good for you that you found someone able to enter words into a Google query. That's a skill you might want to acquire some time in the future. Cheers, Johannes -- Wo hattest Du das Beben nochmal GENAU

Re: Using ssl module over custom sockets

2015-06-08 Thread Johannes Bauer
On 08.06.2015 09:22, jbauer.use...@gmail.com wrote: Something that I could always use as a workaround would be to open up a listening port locally in one thread and connection to that local port in a different thread, then forward packets. But that's pretty ugly and I'd like to avoid it.

Re: Function to show time to execute another function

2015-06-07 Thread Johannes Bauer
On 07.06.2015 10:22, Cecil Westerhof wrote: That only times the function. I explicitly mentioned I want both the needed time AND the output. And you also posted your solution. I fail to find any question in your original posting at all. Sadly the quality of the answers on this list is going

Re: Function to show time to execute another function

2015-06-07 Thread Johannes Bauer
On 07.06.2015 22:35, Cecil Westerhof wrote: And you also posted your solution. I fail to find any question in your original posting at all. That is because there was no question: I just wanted to share something I thought that could be useful. If you would have taken the trouble to read a

Re: Ah Python, you have spoiled me for all other languages

2015-05-24 Thread Johannes Bauer
On 23.05.2015 19:05, Marko Rauhamaa wrote: Johannes Bauer dfnsonfsdu...@gmx.de: I think the major flaw of the X.509 certificate PKI we have today is that there's no namespacing whatsoever. This is a major problem, as the Government of Untrustworthia may give out certifictes for google.de

Re: Ah Python, you have spoiled me for all other languages

2015-05-23 Thread Johannes Bauer
On 23.05.2015 05:31, Michael Torrie wrote: Sigh. I blame this as much on the browser. There's no inherent reason why a connection to a site secured with a self-signed certificate is insecure. The problem is *not* that the certificate is self-signed. It's that it's unknown previously to

Re: Ah Python, you have spoiled me for all other languages

2015-05-23 Thread Johannes Bauer
On 23.05.2015 13:21, Tim Daneliuk wrote: Trust has context. You're going to that site to read an article. This is rather different than, say, going somewhere to transact commerce or move money. Sure, for your site it doesn't really make a difference. And, as I said before, having a

Re: Ah Python, you have spoiled me for all other languages

2015-05-23 Thread Johannes Bauer
On 23.05.2015 14:44, Marko Rauhamaa wrote: Johannes Bauer dfnsonfsdu...@gmx.de: I dislike CAs as much as the next guy. But the problem of distributing trust is just not easy to solve, a TTP is a way out. Do you have an alternative that does not at the same time to providing a solution also

textwrap.wrap() breaks non-breaking spaces

2015-05-17 Thread Johannes Bauer
Hey there, so that textwrap.wrap() breks non-breaking spaces, is this a bug or intended behavior? For example: Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2] on linux import textwrap for line in textwrap.wrap(foo dont\xa0break * 20): print(line) ... foo dont break foo dont break

Re: Is this unpythonic?

2015-05-10 Thread Johannes Bauer
On 08.05.2015 14:04, Dave Angel wrote: It might be appropriate to define the list at top-level, as EMPTY_LIST=[] and in your default argument as def x(y, z=EMPTY_LIST): and with the all-caps, you're thereby promising that nobody will modify that list. (I'd tend to do the None

Re: Is this unpythonic?

2015-05-10 Thread Johannes Bauer
On 10.05.2015 10:58, Frank Millman wrote: It is then a simple extra step to say - EMPTY_L:IST = () and if required - EMPTY_DICT = () and expand the explanation to show why a tuple is used instead. So if there was a situation where the overhead of testing for None became a

Re: sqlite3 and dates

2015-02-18 Thread Johannes Bauer
On 18.02.2015 08:05, Chris Angelico wrote: But if you need more facilities than SQLite3 can offer, maybe it's time to move up to a full database server, instead of local files. Switching to PostgreSQL will give you all those kinds of features, plus a lot of other things that I would have

Re: sqlite3 and dates

2015-02-18 Thread Johannes Bauer
On 18.02.2015 12:21, Chris Angelico wrote: SQLite3 is fine for something that's basically just a more structured version of a flat file. You assume that nobody but you has the file open, and you manipulate it just the same as if it were a big fat blob of JSON, but thanks to SQLite, you don't

Re: sqlite3 and dates

2015-02-18 Thread Johannes Bauer
On 18.02.2015 13:14, Chris Angelico wrote: On Wed, Feb 18, 2015 at 10:57 PM, Johannes Bauer dfnsonfsdu...@gmx.de wrote: SQLite and Postgres are so vastly different in their setup, configuration, capabilities and requirements that the original developer has to have done a MAJOR error

Idiomatic backtracking in Python

2015-01-25 Thread Johannes Bauer
Hi folks, I have a problem at hand that needs code for backtracking as a solution. And I have no problem coding it, but I can't get rid of the feeling that I'm always solving backtracking problems in a non-Pythonic (non-idiomatic) way. So, I would like to ask if you have a Pythonic approach to

Re: Obscuring Python source from end users

2014-10-02 Thread Johannes Bauer
On 29.09.2014 16:53, Sturla Molden wrote: Chris Angelico ros...@gmail.com wrote: I have a project that involves distributing Python code to users in an organisation. Users do not interact directly with the Python code; they only know this project as an Excel add-in. Now, internal audit

Re: GIL detector

2014-08-17 Thread Johannes Bauer
On 17.08.2014 16:21, Steven D'Aprano wrote: Coincidentally after reading Armin Ronacher's criticism of the GIL in Python: http://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-to-see/ Sure that's the right one? The article you linked doesn't mention the GIL. I stumbled across this GIL

Re: python small task

2014-08-15 Thread Johannes Bauer
On 15.08.2014 11:18, ngangsia akumbo wrote: i have this piece of code file1 = open('text.txt, w) try: text = file1.read() finally: file1.close() i wish to manage an office task using this small code , how can i implemetn it to function. import random import troll import

Re: how to get the ordinal number in list

2014-08-09 Thread Johannes Bauer
On 09.08.2014 19:22, luofeiyu wrote: x=[x1,x3,x7,x5] y=x3 how can i get the ordinal number by some codes? for id ,value in enumerate(x): if y==value : print(id) Is more simple way to do that? print(x.index(y)) HTH, Johannes -- Wo hattest Du das Beben nochmal GENAU

Re: Proposal: === and !=== operators

2014-07-12 Thread Johannes Bauer
On 09.07.2014 11:17, Steven D'Aprano wrote: People are already having problems, just listen to Anders. He's (apparently) not doing NAN-aware computations on his data, he just wants to be able to do something like this_list_of_floats == that_list_of_floats This is a horrible example.

Re: Proposal: === and !=== operators

2014-07-12 Thread Johannes Bauer
On 12.07.2014 18:35, Steven D'Aprano wrote: If you said, for many purposes, one should not compare floats for equality, but should use some sort of fuzzy comparison instead then I would agree with you. But your insistence that equality always is wrong takes it out of good advice into the

Re: Off-Topic: The Machine

2014-06-24 Thread Johannes Bauer
On 24.06.2014 03:23, Steven D'Aprano wrote: http://www.iflscience.com/technology/new-type-computer-capable- calculating-640tbs-data-one-billionth-second-could Relevance: The Machine uses *eighty times less power* for the same amount of computing power as conventional architectures. If they

Re: OT: This Swift thing

2014-06-15 Thread Johannes Bauer
On 07.06.2014 11:54, Alain Ketterlin wrote: No. Cost is the issue (development, maintenance, operation, liability...). Want an example? Here is one: http://tech.slashdot.org/story/14/06/06/1443218/gm-names-and-fires-engineers-involved-in-faulty-ignition-switch Yeah this is totally

Re: OT: This Swift thing

2014-06-15 Thread Johannes Bauer
On 05.06.2014 23:53, Marko Rauhamaa wrote: or: def make_street_address_map(info_list): return dict((info.get_street_address(), info.get_zip_code()) for info in info_list) or, what I think is even clearer than your last one: def

Re: Unicode and Python - how often do you index strings?

2014-06-06 Thread Johannes Bauer
On 05.06.2014 20:52, Ryan Hiebert wrote: 2014-06-05 13:42 GMT-05:00 Johannes Bauer dfnsonfsdu...@gmx.de: On 05.06.2014 20:16, Paul Rubin wrote: Johannes Bauer dfnsonfsdu...@gmx.de writes: line = line[:-1] Which truncates the trailing \n of a textfile line. use line.rstrip

Re: Unicode and Python - how often do you index strings?

2014-06-06 Thread Johannes Bauer
On 05.06.2014 22:18, Ian Kelly wrote: Personally I tend toward rstrip('\r\n') so that I don't have to worry about files with alternative line terminators. Hm, I was under the impression that Python already took care of removing the \r at a line ending. Checking that right now: (DOS encoded

Re: Unicode and Python - how often do you index strings?

2014-06-05 Thread Johannes Bauer
On 04.06.2014 02:39, Chris Angelico wrote: I know the collective experience of python-list can't fail to bring up a few solid examples here :) Just also grepped lots of code and have surprisingly few instances of index-search. Most are with constant indices. One particular example that comes

Re: Unicode and Python - how often do you index strings?

2014-06-05 Thread Johannes Bauer
On 05.06.2014 20:16, Paul Rubin wrote: Johannes Bauer dfnsonfsdu...@gmx.de writes: line = line[:-1] Which truncates the trailing \n of a textfile line. use line.rstrip() for that. rstrip has different functionality than what I'm doing. Cheers, Johannes -- Wo hattest Du das Beben nochmal

Re: Python 3 is killing Python

2014-06-02 Thread Johannes Bauer
On 02.06.2014 18:21, Roy Smith wrote: Are we talking Tolkien trolls, Pratchett trolls, Rowling trolls, DD trolls, WoW trolls, or what? Details matter. Monkey Island trolls, obviously. Cheers, Johannes -- Wo hattest Du das Beben nochmal GENAU vorhergesagt? Zumindest nicht öffentlich! Ah,

Re: Python 3 is killing Python

2014-05-31 Thread Johannes Bauer
On 31.05.2014 12:07, Steve Hayes wrote: So I bought this book, and decided that whatever version of Python it deals with, that's the one I will download and use. This sounds like remarkably bad advice. That's like saying I bought a can of motor oil in my department store and whatever engine

Re: Python 3 is killing Python

2014-05-28 Thread Johannes Bauer
On 28.05.2014 21:23, Larry Martell wrote: Somthing I came across in my travels through the ether: https://medium.com/@deliciousrobots/5d2ad703365d/ Sub-headline The Python community should fork Python 2. Which could also read Someone else should REALLY fork Py2 because I'm mad about Py3 yet

Re: Python is horribly slow compared to bash!!

2014-05-26 Thread Johannes Bauer
On 22.05.2014 15:43, wxjmfa...@gmail.com wrote: I can take the same application and replace 'z' by ..., and ... No, I do not win :-( . Python fails. That's nothing. I can make an application a TOUSAND times slower by changing the constant 1 to a 2. Python is such utter garbage! import time

Re: PEP 8 : Maximum line Length :

2014-05-15 Thread Johannes Bauer
On 15.05.2014 04:43, Ben Finney wrote: Rustom Mody rustompm...@gmail.com writes: Until then may we relegate '79' to quaint historical curiosities Not until the general capacity of human cognition advances to make longer lines easier to read. I find it surprising how you can make such a

Re: Everything you did not want to know about Unicode in Python 3

2014-05-13 Thread Johannes Bauer
On 13.05.2014 03:18, Steven D'Aprano wrote: Armin Ronacher is an extremely experienced and knowledgeable Python developer, and a Python core developer. He might be wrong, but he's not *obviously* wrong. He's correct about file name encodings. Which can be fixed really easily wihtout messing

Re: Everything you did not want to know about Unicode in Python 3

2014-05-13 Thread Johannes Bauer
On 13.05.2014 10:38, Chris Angelico wrote: Python 2's ambiguity allows me not to answer the tough philosophical questions. I'm not saying it's necessarily a good thing, but it has its benefits. It's not a good thing. It means that you have the convenience of pretending there's no problem,

Re: Everything you did not want to know about Unicode in Python 3

2014-05-13 Thread Johannes Bauer
On 13.05.2014 10:25, Marko Rauhamaa wrote: Based on my background (network and system programming), I'm a bit suspicious of strings, that is, text. For example, is the stuff that goes to syslog bytes or text? Does an XML file contain bytes or (encoded) text? The answers are not obvious to me.

Re: checking if two things do not equal None

2014-03-29 Thread Johannes Bauer
On 29.03.2014 20:05, Steven D'Aprano wrote: On Sat, 29 Mar 2014 11:56:50 -0700, contact.trigon wrote: if (a, b) != (None, None): or if a != None != b: Preference? Pros? Cons? Alternatives? if not (a is b is None): ... Or if you prefer: if a is not b is not None: ... Is this an

Re: checking if two things do not equal None

2014-03-29 Thread Johannes Bauer
On 29.03.2014 22:07, Roy Smith wrote: I agree with that. But if (a, b) != (None, None): seems pretty straight-forward to me too. In fact, if anything, it seems easier to understand than if (a is not None) or (b is not None): Yes, probably. I liked the original, too. If I were

Re: checking if two things do not equal None

2014-03-29 Thread Johannes Bauer
On 29.03.2014 22:55, Johannes Bauer wrote: if (a is not None) or (b is not None): Yes, probably. I liked the original, too. If I were writing the code, I'd probably try to aim to invert the condition though and simply do if (a is None) and (b is None) Which is pretty easy to understand

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Johannes Bauer
On 26.03.2014 10:53, Jean-Michel Pichavant wrote: Note : I don't see what's wrong in your example, however I have the feeling the term stupiditie is a little bit strong ;) The problem is that for a given timedelta t with t 0 it is intuitive to think that its string representation str(t)

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Johannes Bauer
On 27.03.2014 01:16, Steven D'Aprano wrote: py divmod(30, 24) (1, 6) That makes perfect intuitive sense: 30 hours is 1 day with 6 hours remaining. In human-speak, we'll say that regardless of whether the timedelta is positive or negative: we'll say 1 day and 6 hours from now or 1 day

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Johannes Bauer
On 27.03.2014 11:44, Chris Angelico wrote: On Thu, Mar 27, 2014 at 9:22 PM, Johannes Bauer dfnsonfsdu...@gmx.de wrote: Besides, there's an infinite amount of (braindead) timedelta string representations. For your -30 hours, it is perfectly legal to say 123 days, -2982 hours Yet Python

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Johannes Bauer
On 27.03.2014 11:44, Chris Angelico wrote: It's not equally braindead, it follows a simple and logical rule: Only the day portion is negative. The more I think about it, the sillier this rule seems to me. A timedelta is a *whole* object. Either the whole delta is negative or it is not. It

Possible bug with stability of mimetypes.guess_* function output

2014-02-07 Thread Johannes Bauer
Hi group, I'm using Python 3.3.2+ (default, Oct 9 2013, 14:50:09) [GCC 4.8.1] on linux and have found what is very peculiar behavior at best and a bug at worst. It regards the mimetypes module and in particular the guess_all_extensions and guess_extension functions. I've found that these do not

Re: Possible bug with stability of mimetypes.guess_* function output

2014-02-07 Thread Johannes Bauer
On 07.02.2014 20:09, Asaf Las wrote: it might be you could try to query using sequence below : import mimetypes mimetypes.init() mimetypes.guess_extension(text/html) i got only 'htm' for 5 consequitive attempts Doesn't change anything. With this: #!/usr/bin/python3 import mimetypes

Re: Blog about python 3

2014-01-05 Thread Johannes Bauer
On 31.12.2013 10:53, Steven D'Aprano wrote: Mark Lawrence wrote: http://blog.startifact.com/posts/alex-gaynor-on-python-3.html. I quote: ...perhaps a brave group of volunteers will stand up and fork Python 2, and take the incremental steps forward. This will have to remain just an idle

Re: Programming puzzle with boolean circuits

2013-12-11 Thread Johannes Bauer
On 09.12.2013 14:25, Chris Angelico wrote: I found this puzzle again and was thinking about: How would I code a brute-force approach to this problem in Python? Ooooh interesting! Ha, I thought so too :-) Well, here's a start: There's no value in combining the same value in an AND or an

Programming puzzle with boolean circuits

2013-12-09 Thread Johannes Bauer
Hi group, it's somewhat OT here, but I have a puzzle to which I would like a solution -- but I'm unsure how I should tackle the problem with Python. But it's a fun puzzle, so maybe it'll be appreciated here. The question is: How do you design a boolean circuit that contains at most 2 NOT gates,

Python3 doc, operator reflection

2013-10-28 Thread Johannes Bauer
Hi group, in http://docs.python.org/3/reference/datamodel.html#customization the doc reads: There are no swapped-argument versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, __lt__() and __gt__() are each other’s

  1   2   3   >