I am trying to dynamically create classes in python and am relatively new to classes and class inheritance. Basically I want my final object to have different types of history depending on different needs. I have a solution but I feel there must be a better way. I dreamed up something like thi...
Well, your psychic answer (combined with your hand-holding) was obviously better than mine. I tried to explain a few things and give an answer that was a minimal distance from his example code, but somebody took offense and voted me down. I'll never know why :-)
Yeah. Of course, the guy who admitted that he downvoted me because he didn't like my attitude was super annoying, as well :-) And then, of course, was the time I disagreed with J. F. Sebastian and the downvote happened right after that -- can't say I didn't sort of see that one coming, though...
The oddest (to me) was where a rep 13 user needed help with basic debugging skills and I gave him sufficient information to help him out with that. His question was upvoted +2/-0, and my accepted answer was voted +1/-1. Too short? Who knows? Anyway, I'm really new at this so I'm sure everybody else here has lots more stories than I do... G'night all.
Debugged - http://cdn.sstatic.net/stackoverflow/img/favicon.ico?v=c8 has incorrect alpha, http://cdn.sstatic.net/stackoverflow/img/favicon.ico?v=4f32ecc8f43d (main site favicon) appears to be alright. Don't know if one's old and one's the new or just versioning
With the new Stack Overflow logo, there is also a new favicon. But it is very thin and missing a lot of contrast.
Here is the old favicon compared to the new one in my tab bar right now:
Of course, the old one isn’t too noticeable with my current color scheme on deactivated tabs either, but t...
Mmm - I think that's a different theme (mine was all a darker grey). Also - they may have changed it since last night when I noticed and others confirmed. I can't no-one at the SO office has noticed.
Yeah - chat is different to main site - see the links on my quoted message above.
Shall I answer your question on meta, d'ya reckon. As Fizzy says, main site looks OK ish to me - but I haven't got your "-just off orange" theme going on.
See my addition to the answer. I think the issue really is that all the bars are the same colour. So if you lose one, you lose them all. Before - you'd likely only lose one against any background. Yeah - the grey is quite a step different
quick simple question (not worth an actual question) -> I used to split a string like H4N4 into 'H', '4', 'N', '4' using units = ["".join(x) for _, x in itertools.groupby(Analyte, key=str.isdigit)] However, users apparantly want to be able to use negative values, can I safely just swap the isdigit for isalpha or are there potential pitfalls with that change?
@Wally I take that as a high compliment. Now, what am I doing using this chat service? Software running on someone else's machine might be mailing my messages direct to GCHQ. Quick, everyone shut this down and switch to a highly encrypted channel. Key exchange to be performed by chartered stagecoach with previously unused horses only.
Weird. As I said last night, both the new favicons look identical & ok to me on Firefox 29.0.1. So I downloaded the Chat version & looked at it in qiv, and it looked the same as what Firefox shows me, although qiv displays images with transparent backgrounds on a white & grey check background, and I could just see a very minor problem with the alpha between some of the orange bars.
But then I converted the .ico to a pair of .png files using GraphicMagick's convert program, and both the 16x16 & 32x32 versions looked terrible.
Go on. Add an answer - happy to tag mine Chrome only (that's where I noticed it and where I got all my examples from)
The PNG's faithfully represent what I see in Chrome, though - I did check that. I switched away from Firefox for this because I couldn't easily put them against a dark grey background (my bad skills, not Firefox's deficiency no doubt)
@BasJansen Because you cannot interpret the - on its own. You don’t know if there is a valid number following. Actually, my solution isn’t too good for that either, since it requires that there is no minus sign in the text part. You can use this instead:
@JRichardSnape That would be weird, since the .ico format is just a simple uncompressed format, similar to BMP, except it allows multiple images in the one file. But anyway, I just looked at the Chat .ico file using GraphicMagick's display program (which I presume functions identically to the original ImageMagick version), and it looks horrible - the orange is bleeding all over the place.
>>> s = 'H-Foo123This is some really crazy345stuff that probably doesn’t even fit your requirement-2345But it works.'
>>> re.split('(-?\d+)', s)
['H-Foo', '123', 'This is some really crazy', '345', 'stuff that probably doesn’t even fit your requirement', '-2345', 'But it works.']
@PM2Ring I thought .ico was very simple to display. I wonder if there's some kind of "chain" to produce the favicon, where they're converting another image to the favicon automatically rather than having a dedicated favicon and that is causing bleeding artefacts / white borders etc.
Ahh no - I have installed a dark firefox theme and the chat favicon is awful. Goes off to remove the newly added caveat
Not sure I can put up with the theme for long, either
It looks like I was half right. From en.wikipedia.org/wiki/ICO_%28file_format%29 "An ICO or CUR file is made up of an ICONDIR ("Icon directory") structure, containing an ICONDIRENTRY structure for each image in the file, followed by a contiguous block of all image bitmap data (which may be in either Windows BMP format, excluding the BITMAPFILEHEADER structure, or in PNG format, stored in its entirety)."
Is there any chance that data/features could be served from different servers based on geography? And if so, could it be that PM is in Aus which is far away from the rest of us?
I need to have pytest with a minimal version depending on the running python version installed and tried to run the following line in the install section:
- pip install pytest >= $PYTEST_MINIMAL_VERSION
The environment variable is correctly set, but the command does not run or give any output.
Ahh, open source is so great. I had something I didn’t like, so I went on GitHub to check for an issue on it, or create one, and there already has been one and it was fixed a day ago.
@ByteCommander Sorry, I'm not familiar with building packages for pip, but are you sure that shell environment variables like $PYTEST_MINIMAL_VERSION are valid in that file? I can't find any examples that do that in the pip install docs. But if you're sure it's ok, then try getting rid of the spaces around the >=.
@PM2Ring Should double quotes allow expansion within them, then?
I would fire up vbox, but it's got in a tizzy because I tried to start it with a Linux install USB absent mindedly left in the computer too and now windows doesn't know whether the service is stopping or starting.
Yes. And if you don't use double-quotes then you get word splitting. Which is generally not desirable: if VAR contains a filename with spaces, then some_command $VAR will see each of the separate words in VAR as separate args.
@JRichardSnape Oh dear. Windows is so helpful like that...
It's easy to forget that sort of stuff when you're not using it regularly. IMHO, Bash syntax is ok when you're used to it, but if you only dabble in it occasionally it can be a bit arcane, especially the stuff relating to word splitting. The rule of thumb: when in doubt, wrap it in quotes. :) Normal stuff goes in single quotes, anything starting with a $ should be wrapped in double quotes unless you know you really do want word splitting.
@VigneshKalai I think the question is not clearly worded - depends whether order is important - I think it is, but the upvoted answer that the OP is "trying out" clearly can't (guarantee to) preserve order.
yeah - it is implicit. But all the answers are assuming it doesn't matter and treating it like a graph clique problem, or set union problem (which are effectively the same thing in this case). I commented to try to clarify OP said "I don't know" so I'm out
all fine - OP is struggling somehow, I think. Yet another where the level of the question seems to display quite a mismatch with the understanding of the OP.
@JRichardSnape Maybe. I was going to say his null list may be due to something simple like an indentation error, but changing the indentation on that filtering operation only affects the efficiency, it doesn't affect the result.
pass. There is probably some difference between the case he's put in the problem and what he's actually working on. Hence the pregnant pause while he goes away to test what should take 30 seconds to paste into a file and run.
Grumpy today. Probably need more coffee
P.S. @Pm2 re your comment about mentioning that he knew why it didn't work. He did, in bold, at the bottom...
Anyone seen anything tricky looking today? I fancy a challenge.
I was looking at this one might interest you @pm2 but not Python. However, I can't for the life of me see why the OP is using that particular numerical approximation and no response to my query on same.
They're doing some strangeness @antti. Off on a wild goose chase IMHO, but I'm always drawn to the maths-y questions. Usually there's some reason that they don't have to do it the way they're trying (i.e. a big XY going on)
Some people are interested in calculating constants to a great precision... However, it is like an old joke here "How would you get to London from Helsinki?". "Well, I wouldn't start from Helsinki..."
@AnttiHaapala I did not. I was with the scientist who said he would eat his shorts if it were true. Some group in Italy claimed it. But it was down to measurement error, predictably enough. Some good results, followed by a bad one that they trusted iirc
@JRichardSnape I don't know Java. And if I want high precision Zeta I can get it from mpmath. FWIW, I just found an error in a Zeta calculation in a comment on the linked SE.Mathematics page
@PM2Ring Thought it might pique your interest :) Yeah - there are much better ways - I think the Java question is just obfuscating really. Unless they really do want to try for ~100 s.f. complex arithmetic and functions in Java as an exercise.
@AnttiHaapala Yeah. From a quick skim of the comments, it appears that the OP doesn't have the skills to do the job properly. Eg
This (new) class Complex, using BigDecimal: do you really think that calculations with a very high precision helps while calling all Math functions using double, with just 15 significant digits? — launeyesterday
My thoughts too. And I am offended, offended I tell you, that you get a reply in 2 minutes to your comment and yet nothing on my "why are you doing it like this?" query :)
@JRichardSnape That reminds me of a similar thing in the Python tag a few months back. The OP was using Decimal to do some high precision calculation, but he also need a square root, so was using math.sqrt(). :)
Interestingly - a quick google and follow the wikipedia entry for "arbitrary precision floating point libraries" reveals this apfloat.org/apfloat_java which looks worth a punt. Although Antti's assumption from a few messages up should be employed until proven different.
Pity you need to do this in Java. If you were using Python, you could do arbitrary precision Zeta calculations using mpmath, including calculating various orders of Zeta function derivatives, and finding zeroes. — PM 2Ring26 secs ago
I'm going to see if I can simply plug the formula into that Java library for kicks over lunch. Like Antti says, there's nothing interesting about this question, which is probably why I get stuck on it...
>>> a = [1, 2, 3, 4]
>>> for i, a[(i - len(a) - 1) % len(a)] in enumerate(a[:]): pass
>>> a
[2, 3, 4, 1]
>>> for i, a[(i - len(a) - 1) % len(a)] in enumerate(a[:]): pass
>>> a
[3, 4, 1, 2]
class Foo:
def __init__(self):
print("Created a new Foo")
def __setattr__(self, name, value):
print("Now", name, "=", value)
for Foo().x in [1, 2, 3]:
pass
Kevin. I accidentally left out the leading factor of ½ in that kinetic energy calculation last night. Sorry. But I guess errors that are less than an order of magnitude are ok for engineering work. :)
Using Python 2.6, which does not have logging.Logger.getChild(name) implemented yet, how can I backport this function inside an existing program that relies on it?
The code of the function can be basically reduced to one line, which I try to put into the Logger class as lambda function like this...
The sooner that every modern project fails to work on 2.6, the sooner this RHEL thing will cease to be a viable technology. Thus bringing their current users into the current century.
RHEL might support 2.6 as default, but isn't it recommended that you don't use the system default anyway (even if it were the same version that you wanted)?
Python wiki - Beginners Guide / Non-Programmers Link to LPTHW is no more. It has ceased to be. It's expired and gone to meet its maker. This is a late link. It's a stiff. Bereft of life, it rests in peace. It is pushing up the daisies. It's rung down the curtain and joined the choir invisible. This is an ex-link.