« first day (2841 days earlier)      last day (2090 days later) » 
03:00 - 19:0019:00 - 00:00

 
2 hours later…
6:17 AM
Hello what should I do in order to support rebind(A,B) so that all reference to A object will take effect on B object? Suppose that I have object references of both A and B in my data structures, and references are everywhere.
 
Huh?
 
Basically, you want this?
>>> A = object()
>>> B = object()
>>> rebind(A, B)
>>> A is B
True
 
Yeah something like this
only with that it may be: datastructure.field=A
and I want:datastructure.field is B is ALSO true
 
That's not possible. Python doesn't support identity theft.
 
I can control how A is defined. Is it possible without considering the is operator?
 
6:32 AM
@Aran-Fey A = B
 
```
class A(object):
    def any_operation(self, a):
        raise NotImplementedError
    def any_operation2(self, a,b,c,d):
        raise NotImplementedError
    # ... like 90 operations with various fingerprints

def rebind(a,b):
    # what should I fill

class Dummy(A):
    def __init__(self, key):
        self._key = key
    def key(self):
        return self._key
    # what should I fill

class Worker1(A):
    def __init__(self, k):
        self.k=k
    def any_operation(self, a):
        print "good operation for w1", self.k
 
If you really really really really really need that kind of functionality, you'll have to wrap A and B in some kind of proxy class. Here's an example with lists:
 
You just have to do that first :D
 
>>> A = [object()]
>>> B = [object()]
>>> A[0] = B[0] # this is the rebind(A, B) operation
>>> A[0] is B[0]
True
 
Thanks
 
6:35 AM
@Andras yw :) Might want to link 'em to the handy posting code in chat guide though :p
 
I did, then deleted when I thought they edited
 
How can I have a transparent proxy class?
 
I didn't expect mod abuse D: might wanna format it properly though...
@Thiner for future reference sopython.com/wiki/…
 
@AndrasDeak meh... just hit fixed font on it and it looked better even if not 100%
 
@Thiner Not sure if it's a good idea to make a transparent proxy. Some things can't be proxied, and you might end up shooting yourself in the foot. Consider writing proxy-aware code instead (i.e. take the wrapped object out of the proxy if you need to interact with it)
 
6:43 AM
proxy aware code may increase code size by 100% I believe ...
I can control the class Dummy
And all I want to bind with a dummy is an A
Unbinded dummy can contain an object ref and nothing else - calling any method on it raise NotImplementedError
Binded dummy will not be rebinded
 
Huh. If they won't be rebinded, why do you even need them?
 
7:04 AM
I still think a = c would work...
I know, it needs a key
How about Aran's suggestion but with a dict representing all the dummies?
 
@AndrasDeak Well, only if a is the only reference.
"Suppose that I have object references of both A and B in my data structures, and references are everywhere."
 
They just need to bind before everything :P They only need to delay references to A
Frankly this sounds very much like an XY problem
 
class A:
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def __repr__(self):
        return f'{self.a} {self.b}'

a1 = A(1, 2)
a2 = A(3, 4)

a1.__dict__ = a2.__dict__

a2.b = 100

print(a1, a2)
Prints:
3 100 3 100
@Thiner you want this behaviour?
 
Interesting. I didn't know you could actually assign to __dict__ and it would maintain the reference.
 
@Aran-Fey Python is magical :) I'm still learning it after 14 years that I began coding with it
 
7:21 AM
Cabbage
@Aran-Fey Sure! It's just a normal dict. And you're allowed to modify it directly, although because it's a dunder attribute it's preferred if you don't... unless you need to. :) Reading from __dict__ is pretty common, eg fmt.format(**self.__dict__). But I occasionally do stuff like self.__dict__.update(kwargs)
 
Don't forget the vars() builtin...
 
I often see mappingproxy objects being used as __dict__s, and you can't assign to those. Turns out I should've google why that is, which would've told me that mappingproxy objects are only used for classes.
 
@JonClements Oh, yeah. :)
 
>>> class C:
...     pass
...
>>> C.__dict__ = {}
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: attribute '__dict__' of 'type' objects is not writable
Instead of spending 15 seconds on google I learned to avoid assigning to __dict__ :/
 
I'm trying to decide how to build a palette, which can be a flat list or a bytearray. In the following code clist returns a [R, G, B] list. Option #1:
palette = []
for i in range(0, 40):
    palette.extend(clist(240 - 1.5 * i))
for i in range(40, 60):
    palette.extend(clist(420 - 6 * i))
for i in range(60, 101):
    palette.extend(clist(150 - 1.5 * i))
# option #2
palette = bytearray(303)
for j in range(0, 120, 3):
    palette[j:j+3] = clist(240 - 0.5 * j)
for j in range(120, 180, 3):
    palette[j:j+3] = clist(420 - 2 * j)
for j in range(180, 303, 3):
    palette[j:j+3] = clist(150 - 0.5 * j)
# option #3
palette = list(chain.from_iterable(chain(
    (clist(240 - 1.5 * i) for i in range(0, 40)),
    (clist(420 - 6 * i) for i in range(40, 60)),
    (clist(150 - 1.5 * i) for i in range(60, 101))
)))
Option #3 is most compact, and pretty efficient. But I think option #2 is maybe a little more readable, and it's also quite efficient, maybe even more efficient than #3. I'm not keen on #1 because of the 101 .extend calls.
 
7:40 AM
Well, you could pre-allocate the list and then use slice assignments like with the bytearray
I'd probably use the bytearray just because it makes it obvious that the values are expected to be ints between 0 and 255. If you use a list, someone might try putting in a float between 0 and 1
 
True, I could do palette = [0]*303, but that's not really an issue. I'd actually prefer to make the palette a bytearray, since they're smaller and faster. bytearray has .extend.
 
I'd use numpy ;)
 
I'm trying to avoid Numpy for this application. It would be faster, but there's not a lot of use for Numpy in the rest of the program, just in the final phase, where I convert the output data to an image.
The palette is fixed, there's not much point in changing it. FWIW, it looks like this:
Ok, that's only 100 colours, but I think you get the idea. :)
 
(Also more elegant, probably)
 
8:00 AM
I'm using it to display the output of code that calculates the avalanche effect for hash functions. "whenever a single input bit is complemented, each of the output bits changes with a 50% probability". An avalanche diagram is a grid where each row represents an input bit & each column an output bit. The value grid[y][x] is a measure of the probability that flipping bit y in the input bitstring causes bit x to be flipped in the output bitstring.
If the function has perfect avalanching, then every grid cell gets a value of 0.5. So I run a bunch of random trials, calculate the percentages, and map the results to colours. If the probability is in the range 40%-60%, that's pretty good & the cell gets a green colour from the two middle rows of that palette. If the probability is too low, I map it to a cold colour, if it's too high I map it to a hot colour.
 
Can anyone understand what this OP is trying to do? Linking two lists together to find highest and output value over 3?
 
The Python hash function is ok for hashing long strings, but it doesn't work so well when you want to randomize small integers. Of course, if you just pass it a small integer it just returns that integer, but you can pass it a tuple to get a random-looking result. However, it has terrible avalanching.
@smci I'm tempted to close it as unclear. I don't agree with all the points in your comments, but the code is certainly hard to read, and it does weird things with no explanation. The OP has had ample time to clarify what the code is supposed to do, but he hasn't done that. And his indentation is still broken, although that's only a minor issue.
 
8:33 AM
@PM2Ring Uhuh, which comments of mine do you disagree with? But I'd be inclined to post your criticism of the OP as comment and give them time to fix it, and tell them it'll be closed if not.
 
@smci Well, the __init__ method is ok: it initialize a couple of instance attributes. Yes, it also adds stuff to class attributes, which is not that unusual, although it's more common to simply add the whole instance. But I suspect that the OP is doing cargo-cult coding & doesn't really understand what they're doing.
 
cbg
 
cbg
 
8:51 AM
Haven't a clue what that OP is trying to do
 
> Whitespace between tokens

Except at the beginning of a logical line or in string literals, the whitespace characters space, tab and formfeed can be used interchangeably to separate tokens.
I'm struggling to put a formfeed in my python source :(
 
@smci I've added a couple of comments. And close-voted.
 
I've just read a question where someone misspelled patsy library as pasty and my Northern Englishman instincts went into overdrive. "I must have this library installed!"
Of all the inventions in Manchester, I think our proudest is the first drive-through Greggs
 
9:51 AM
@roganjosh great... now I really fancy a sausage roll... :)
 
where's a "dachshund rolling over" gif when you need one
their anatomy probably makes that a difficult maneuver for them
 
meh... all good dogs know how to roll over... :)
 
Don't blame me, it was the OP's fault, I just had to pass it on :)
 
tired cbg
 
@roganjosh nope... I'm going to blame you until a Gregg's sausage roll (or two) turns up at my door :p
/me taps paws... I'm waiting... (puppy dog eyes look) :p
 
10:05 AM
I'm in the hills currently, there's not a Greggs for at least a mile :/
On the other hand, I'm also a big fan of Absolutely Fabulous so I hope a library named Patsy has crippling one-liners for their exception messages
 
There is another puppy here who likes rolls :D
 
yeah... but that's my evil twin... :p
 
I remember when I moved to Nottingham and went in Greggs and asked for a meat and potato pasty. They looked at me like I'd gone mad, they'd never heard of it. In Manchester it's their best seller. They're lucky I didn't just start breaking stuff.
 
when you seen Jon rolling, you hating
 
The Evil Ninja Puppy ;-)
 
10:10 AM
still spreading those blatantly untrue rumours I see Evil Puppy :p
 
Similar when I was in London and the chippy didn't serve gravy. That's false advertisement, you can't be a chippy without gravy. Trading standards should be shutting these places down.
 
I don't have gravy on chips, but I know the local chippy does it... :)
I did once go to a chippy and asked for mushy peas with it... was a little worried when I got a confused look
 
I love it when people get confused as they cannot decide who is actually the evil one
BTW, do you follow football?
 
It's "evil twin" and not "morally opposite twin" for a reason; two evil guys can both be evil twins ;)
 
Lol, up here there's a phrase: "scraps and pea wet". It's the bits of batter left floating in the oil and the water left behind from mushy peas
 
10:14 AM
ew
 
I've never gone so far as to ask for that, I do have a line on my northerness
 
Come on puppy, quick. Think of something. This hooman, AndrasDeak might be on to us.
 
@AndrasDeak I'm not evil though... meep meep
 
oh OK then :P
 
@thefourtheye no... I've been banned from stadiums... they don't like it when I run on, pick the ball up and run around with it... I thought it was fun and everyone was chasing me and stuff... apparently... turns out they didn't like it :(
plus, it hurts my jaw, so I stick to tennis balls and running around with those now...
and won't be trying to catch a cricket ball again anytime soon... that really hurts...
 
10:23 AM
lol. This must be you.
@AndrasDeak Good, good.
Humans are naiver than we thought. Puppies world domination will happen soon.
 
@thefourtheye I can neither confirm or deny such rumours :)
 
Nah, to think of it, that can't be you. Has anyone ever seen a Ninja? ;-)
 
True... but once seen - it may be their last memory...
oh dear... you're tainting me with your evil! :p
 
Muhahaha
Sigh, I need a better laugh.
 
it'll do for now... we'll get you a training course later... :p
 
10:54 AM
 
bbias
 
user7659542
Hello
I am facing a bit of an odd issue
 
user7659542
 command = "Path to data: " + str(args.bin) + "/lib/" +str(data["tests"][0]["command"])
 print("Going to execute this: "+ str(command))
 print("                                     /home/Jo/Desktop/build/lib/integration_test_lib")
 if str(command) == "/home/Jo/Desktop/build/lib/integration_test_lib":
     print("Are equal")
 else:
     print("Not equal")
 
user7659542
This generates the following output:
 
user7659542
Going to execute this: Path to data: /home/Jo/Desktop/build/lib/integration_test_lib
                                     /home/Jo/Desktop/build/lib/integration_test_lib
Not equal
 
user7659542
11:05 AM
As you can see both strings are perfectly equal
 
user7659542
yet it claims they aren't
 
user7659542
Does anybody know why?
 
user7659542
args.bin, is a command line argument and data["tests"][0]["command"] is data from a json file
 
whitespace?
try .strip()-ping the command. And command is already a string so calling str() on it is superfluous
but you should probably use a format string or similar instead of hacking together a string with calls to str()
 
@JonClements If Tim petters is an AI, and if you are a puppy, I'll start questionning myself if their really are humans developping in python.
 
11:14 AM
Peters
 
@traducerad Ummm, command starts with Path to data: .
 
hehe, nice
 
user7659542
doesn't seem to be the case: I tried adding this line

command = "Path to data: " + str(args.bin) + "/lib/" +str(data["tests"][0]["command"])
command = command.lstrip()
print("Going to execute this: "+ str(command))
 
user7659542
@Aran-Fey hahah that s so stupid of me!
 
user7659542
xD
 
11:16 AM
Oopsy; Sprouts
 
user7659542
indeed, thanks!
 
11:29 AM
@T.Nel there may or may not be... maybe some day you will know... or maybe not... :P
 
Huh, I didn't realise pip 10 had caused so many problems on Debian. It's a good job I ignored the upgrade suggestion and didn't blindly stumble into that problem on my server
 
I went back to pip 9
 
I never even realised pip was telling me to do something that is considered self-sabotage
 
@roganjosh it became aware, couldn't be bothered to destroy the human race, so it's settled for becoming masochistic :)
 
"You should consider upgrading via the 'pip install --upgrade pip' command." is kinda like that W3schools article about python "arrays" that concludes with "everything we just said is wrong because python doesn't have arrays [sic]"
 
11:40 AM
Umm... unless you count array.array? :p
 
@JonClements I'm the perfect victim. I stumble around linux like one might coming out of the pub on a Friday night. I'm more than happy to listen to what pip is telling me I should do.
^^ hence the [sic] :P
 
:)
I'll see if I can't get a commit to pip that says "Don't worry about updating me... just remember that puppy is still waiting for his sausage rolls?" :p
3
 
Have a star
 
@traducerad When you want to check that strings like that, it's a good idea to pass them to repr. Eg,
s = "This\tis\na string of words"
print(repr(s))
#output
'This\tis\na string of words'
 
@JonClements if only I could remedy the situation. I'm as heart broken as you :(
 
11:44 AM
@JonClements Don't forget about bytearray. Sure, it's not a general purpose array, but it's very handy when you want mutable array of 8 bit values. It's my new best friend. :) It's smaller than list, and generally faster.
 
@PM2Ring the problem was the fluff in this case
 
Hey @roganjosh One of my favourite guitarists is a Northerner: a young Yorkshire lass named Chantel McGregor.
Nov 1 '15 at 13:07, by PM 2Ring
One of my favourites is a young English lady named Chantel McGregor, who's more into rock than pure blues, but she plays a fairly wide variety of styles, both covers & originals. Here she is from a few years ago doing a great cover of an old Jethro Tull blues-rock number, A New Day Yesterday. And if you like that check out her doing Robin Trower's Daydream.
 
Giving it a listen
The north has a proud history of music. So many Mancunian bands on the world stage. And, of course, we had the Hacienda
 
@AndrasDeak Sure, saying to use repr was just general debugging advice.
 
From the video I'm watching it looks like she does pub gigs. There's a pub just up the road from me that does loads of live music and jam sessions, I wonder if she'll ever end up in there
 
11:54 AM
She may have been there already. :) She does travel around a bit, but does lots of gigs in the north.
 
I'll have a look when I get home and see what they have on. They pack the week out with gigs so they'll churn through acts pretty quickly and it's a distinctive place (in other words, it's not unlikely). I should go there more often, some really talented musicians turn up for the jam sessions
 
One of the UK's greatest rock vocalists, Joe Cocker, was from Sheffield.
 
@PM2Ring I haven't... Also convenient for integer operations as it returns ints when operated over...
@roganjosh it's fine. I'm over it. Went and had a fryup at the local cafe... Tomorrow though... we shall see :p
 
I'd say a fry up is more than enough to get over it :) That's tomorrow's breakfast
 
@JonClements Yep. And for some odd reason it also seems slightly faster to iterate over than a bytes (at least on my old 32 bit single core machine), which I found surprising. I figured bytes would have the performance edge, being immutable.
I recently upgraded some of my prime number generating programs to use bytearray for boolean arrays. They use much less space than lists, and are faster as well. That's why they're my new best friend.
 
12:22 PM
Interesting - I'd have expected the same bytes vs bytearray...
Or at the very least the same performance
 
The iterator implementations for byte and bytearray are at github.com/python/cpython/blob/master/Objects/… and github.com/python/cpython/blob/master/Objects/… respectively. They are almost completely identical (modulo type names) except for the line beginning with item = PyLong_FromLong(
The bytes object directly reaches into its char array and retrieves the value you need. The bytesarray object uses the PyByteArray_AS_STRING macro, which does a little bit of boundary checking on top of that
I don't know if a single assert and a size check could really account for the discrepancy you're seeing, but that's the only obvious difference I found
 
@Kevin That makes sense. So the reason that bytearray is faster must be due to something else. Or maybe I just have a weird machine. :)
 
Hmm not sure how I read your previous message three times and still interpreted it to mean that the bytes object was faster
 
I don't have any comparison code in my timeit programs collection. It's just something I noticed recently, but I can't remember the context. I probably just did the timing using the bash time command, rather than a proper timeit test.
 
Looking at the struct definitions for each type, I found it interesting that their buffers are declared differently: char ob_sval[1]; vs char *ob_bytes;. I wondered if this would affect indexing time but from my fuzzy recollections of C++ I don't think there's a difference under the hood
 
12:38 PM
Come to think of it, I probably did the timing using time.perf_counter, when I was doing stuff that needed a big table of smallest prime factors. The table didn't need to store any primes over 100 (such numbers got a zero in the table), so I used bytearray. And since the table is pre-calculated before the main loop that does the real work, I figured that loop could run a little faster if the table was a bytes rather than a bytearray. But it was actually a little slower.
@Kevin A smart compiler could optimize the array address, since it knows that it can't change, whereas the pointer could change.
This OP is yet another dedicated adherent of the "clarification through repetition" school. ;)
 
I'm trying to visualize what this means for memory layout. Does that imply that the buffer for a bytes is always directly adjacent to its header, but a bytearray's buffer could be miles away from its header? One might expect caching to be slightly better for bytes, then
Now we've reached the "idk it's probably caching" milestone of the performance analysis, which means everything that follows is pointless speculation. Please tip your waiter and have a good night, everyone
 
user7659542
I have a bunch of binaries, written in C. The code finishes its main by either returning 0 or -1. Is there an easy way in Python to catch that value when running that binary?
 
@Kevin Yes, that's possible. So I guess that means that a bytearray backing buffer could get moved into a CPU cache independently of the rest of the struct. But I don't know a lot about modern CPU architecture, my knowledge about that stuff is a little dated.
 
Still better than mine :-)
@traducerad Are you using subprocess to call them? Check the returncode attribute.
 
user7659542
12:55 PM
@Kevin yep, subprocess.Popen
 
user7659542
@Kevin Hmm, ok let's see...
 
user7659542
@Kevin Works like a charm. Thx!
 
Nice :-)
 
I am deeply tired today, so I do not know if questions are unclear or I just can't understand them until it is solved.
I doubted for a while on this
But I should have understand he confused rows with columns when I read "1000 lines and 25 rows" in an excel.
 
1:36 PM
@T.Nel No, it's not just you. There have been some classics today. I just managed to decode one that was initially rather baffling. stackoverflow.com/questions/51558462/…
 
DSM
Australian cabbage for all!
 
Looking in the edits : Just a sentence with a few choosen word and the problem becomes clear.
 
Hello, I encountered the following error while running the script on CentOS7 system.

Non-C locale detected. This is not supported.
Call 'setlocale(LC_NUMERIC, "C");' in your code.

My search for information found that setting LC_NUMERIC='C' in code solves the problem

import locale
locale.setlocale(locale.LC_NUMERIC,'C')
locale.setlocale(locale.LC_ALL,'C')


But it still prompts the same error
Does anyone know what to do?
 
But without that you had 20 minutes of comments needed to understand
French cbg for you DSM
 
DSM
If you're asking why I'm offering Australian cabbage to everyone even though I'm in Canada, it's because I found the earlier question where the guy confused a map of Australia with a map of India hilarious. Apparently everywhere is Australia now!
 
1:46 PM
Mini nerd snipe: construct an is_perfect_square implementation that works on integers of any size. (implementations depending on math.sqrt tend to fail above sys.float_info.max)
 
And Austria at the same time, because it's the same country.
I did not see it, you have a link?
 
DSM
-5
Q: Dividing a map into boxes

Aditya Rajhow we can divide Indian map into five boxes in python to study the temperature variation over these box . https://i.stack.imgur.com/LdxgC.png it will be like the image present in link.

 
Melon
 
DSM
Hmm, was hard to get the formatting right there, not sure why. Anyway, to repeat myself: it's just funny how the grammar worked, even though I know the OP was just using it as an example.
 
Twist: that map of Australia was made in India, thus qualifying it as an "Indian map"
 
1:49 PM
!
 
@DSM Yep. I presume that he knows what a map of India looks like, considering that he has a very Indian name. :)
 
DSM
Could use techniques invented in India too! It definitely uses Indian numerals. ;-)
 
Hard mode: write an algorithm that only works on maps made in India.
Sly OP, he was asking for a DRM system all along
 
DSM
You could write the right algorithm and then multiply it by an error term which scales with the difference of the country's shape from India's.
 
recbg
 
1:53 PM
@Kevin There are a few ways to handle that, but I didn't want to complicate the issue. Since the OP was happy to use math.sqrt, I'm happy enough to use it in my answer. :)
 
DSM
I know we've done lots of isqrt Qs before. Didn't you do a Newton one sometime, PM? I think I did one using Decimal once.
 
That's a nice setup for a scifi novel. Earth, 100,000 AD: tectonic shifts have caused the coastline of India to fall outside the expected tolerance, causing all replicator technology on the continent to fail. A dark age ensues.
@PM2Ring Yeah, on a practical level I think it's fine to use sqrt for almost all use cases.
 
DSM
I think the idea Antti gave me is more practical‌​.. mind you, so practical that versions have already been done.
 
On an academic level it bothers me just a little when a function is purported to work on all integers, when it really works on approximately 0% of them :^)
 
@DSM Yep. Decimal.sqrt is fine, but here's a Newton one I did a few years ago:
def int_sqrt(m):
    if m <= 0:
        return 0
    n = m << 2
    r = n >> (n.bit_length() // 2)
    while True:
        d = (n // r - r) >> 1
        r += d
        if -1 <= d <= 1:
            break
    return r >> 1

# Test
m = 2 * 10 ** 100
r = int_sqrt(m)
print(r)
print(r**2)
print((r+1)**2)
#output
141421356237309504880168872420969807856967187537694
19999999999999999999999999999999999999999999999999771656080961606813043742880457326381198582670837636
20000000000000000000000000000000000000000000000000054498793436225822804080625299265996912517045913025
 
2:10 PM
hello dudes, some one to poit me way to work with class in python, i play with structural php, oo and class is new to me...
 
@Kevin i gona read tks
 
Another option is to use continued fraction expansion, like I did here.
 
Haven't personally read the second and third links, but they're at the top of the google results for "python class tutorial", so they can't be that bad.
On the other hand, W3schools regularly appears in the #1 result for google queries not unlike this one... Maybe I better give these a skim
 
one daubt is, for example: im try work with scrapy and see some class in examples codes, but i dont see call to instances that class, scrapy have auto load class?
 
2:14 PM
No such thing.
I can think of a couple reasons why a module might define a class but not create any instances of it. It might be an abstract base class. They might expect the person importing the module to make their own instances. The class might not be intended to be instantiated, instead serving as a namespace for static methods.
 
1 example real code...
class ImagesWithNamesPipeline(ImagesPipeline):
def get_media_requests(self, item, info):
# values in field "image_name" must have suffix ".jpg"
# you can only change "image_name" to your own image name filed "images"
# however it should be a list
for (image_url, image_name) in zip(item[self.IMAGES_URLS_FIELD], item["image_names"]):
yield scrapy.Request(url=image_url, meta={"image_name": image_name})

def file_path(self, request, response=None, info=None):
image_name = request.meta["image_name"]
 
Hard to say what the intent is without seeing the entire code. Where did this come from?
 
Not about the code, but how ImagesWithNamesPipeline class, start work...
on php we call the function like ImagesWithNamesPipeline()...
 
Python does the same thing.
 
ok but ImagesWithNamesPipeline not is a function is a class
 
2:18 PM
@MagicHat If you already know how to program you should work through the official Python tutorial. It's not for raw beginners: it was designed for people who have experience coding in at least one other language. It has a good introduction to classes in Python. But don't just jump straight to that section. You should work methodically through the tutorial, or you may get confused, or develop misunderstandings that will interfere with your learning.
 
@PM2Ring nice, souds good advice.... u refer about that---> docs.python.org/3/tutorial
Another thing is about versions pyhon 3 is better than 2.7?
 
Short answer: yes. Long answer: it's complicated.
 
@MagicHat Yes, that's the official Python tutorial. At this stage of your learning, this room can only offer limited assistance. Once you're a bit more familiar with the core elements of Python then we will be able to help you with your questions.
 
@Kevin np , like im start learn i search for the rught way
 
Python 3 is generally considered better for people starting from scratch
 
2:21 PM
@PM2Ring nice apreciate the atention... i realy start love python
 
... Or coming from another language
 
ok tks for now, lets start tuto... see you dudes
oh last one, i have 2,7 in the machine can upgrade, or is better unistall and reinstall 3?
 
You can have both versions at the same time if you want.
 
@Kevin but requerie complexy enviroment, or they work in paralel?
 
Although it may be confusing if you run a script in one version, expecting it to be the other version. Maybe uninstalling is better.
 
2:24 PM
ok
 
DSM
2:36 PM
Hooray! The IT guys at the office have fixed my profile, so now I'm not getting flashbacks to my 8-bit days.
 
Neat.
 
2:54 PM
cbg.
Though @MagicHat, if you are using a version of MacOS, it may not be a good idea, due to the fact that some Mac app's front ends/back ends are written in python 2.X.
 
i read something about that here https://unix.stackexchange.com/questions/332641/how-to-install-python-3-6

im case i just for learn so i think np use 3.7.0... when problems appear, i discovery a good place for change ideias
https://chat.stackoverflow.com/rooms/6/python hehe
 
@MagicHat If you are on a Mac or Linux system, then you definitely don't want to uninstall the system Python(s). But there's no problem having multiple versions of Python installed, as long as you keep the names distinct. On this Linux system I have 2.5, 2.6, 3.1 & 3.6.
 
no, i dont for now i use
update-alternatives --install /usr/bin/python python /usr/local/bin/python3.7 50
with this priority i work with last version... i think
 
3:09 PM
CABBAGE
 
Hey, I am working on a project that is going to be multiprocessed, and I am not sure of to have a dynamic number of processes. The only way I can think of is to use exec or eval, which I shouldn't do. I could hard-wire the code for every different number of processes(2,4,6,8) I want with if and elifs, but that seems like a waste of time, space, and would not allow people to use any thing other than the hard-wired number of processes. Any ideas?
 
Why do you think you'd need exec or eval to handle a dynamic number of processes? Can you explain a bit more about what you're trying to do?
 
multiprocessing.Pool can decide on your behalf how many processes to use if you don't give it any arguments
 
One sec, I am going to make a gist.
That is the class I am using.
 
3:29 PM
Hello, I want to use alembic with multidb but there doesn't seem to be much clear infomation available... can anyone pelase tell how should my env.py file should look like? For now I have only 2 tables and both are configured in top level alembic.ini file
 
lol
 
recbg
 
Reminder to self: the sides of hakama are not pockets. Phone met concrete.
 
Sometimes I feel like I'm about to do that with pants that definitely have pockets.
 
recbg
 
3:54 PM
@FélixGagnon-Grenier I've been meaning to post this for a few days i.imgur.com/1QnxdUD.mp4
 
AAAAAAAAAAA
it's like, both adorable and terrifying
though, I might survive an encounter with such a cat. the spider however... I don't think I have nerve enough
 
The fact that there's a bit of doubt in my mind that it might actually be real is unsettling
 
... well, come to think of it, that cat is probably video edited.
 
Don't say "probably", you're fueling that little part of my mind that's unsure :/
When I was kid we went to some place (I really can't describe it better than that because it was when I was very young) and there was a cat in formaldehyde that did have 8 legs. It was Siamese twins almost perfectly fused along the spine, so it had 4 legs pointing vertically upwards on its back.
which completely ruins the perpetual motion idea of putting a piece of buttered toast on a cat's back and dropping it
I suppose you could put a slice of buttered toast on either flank and make it produce more energy than a regular cat
 
4:44 PM
Interesting. Searching "python pickle" in Google gives me the docs for Python 3.7 as the featured result. Normally I'm used to seeing 2.7 docs first. And it seems the same with "python csv" too. Am I imagining something changed or is google now ranking searches for "python" documentation differently?
 
I see the same, duckduckgo is 2.7
 
That seems to me to be an intervention on Google's side, because 3.7 docs must be the lowest used of all the documentation?
 
DSM
python json is still 2.7 first for me, although I'm kind of surprised 3.7 is second.
 
@roganjosh that would be my guess
 
Clearly Google has long assigned a high page rank to anything with ".7" in the title, and finally 3.X gets a piece of that pie
 
4:47 PM
@DSM 3.7 for me :)
good guy google bringing us the future near past
 
I think it's quite plausible Kevin's statement is right
 
If you liked "which Python should I use, 2 or 3?", you'll love "which Python should I use? 2.7 or 3.7 or 3.<most_recent>?"
 
or someone hijacked a Ukrainian botnet to increase the hits for 3.7
 
I'm on the precipice of a rabbit hole that I don't want to fall into. Just noticed that when I run a vanilla dash hello world type app, it takes up 1.3% of my server's cpu. Now, dash is using flask so I did the same thing with a vanilla flask hello world... that took up max 0.3% of the cpu. Question is: what is dash doing? that is churning the cpu? I haven't said very much about anything. Before I go down the road figuring out if I should avoid dash, does anyone know something?
 
(1% doesn't sound too much)
 
4:53 PM
4x what plain flask was doing
This is company server, not my machine.
 
you should do something more substantial to see if it's x4 or +1 percentage point
 
yeah, good point
 
I don't investigate performance discrepancies unless they're worse than 10x
 
needless to say, I have no actual knowledge of the subject
 
stay tuned... you won't want to miss this unfolding drama
 
4:55 PM
sysadmins hate him for this one weird trick
6
 
My favourite clickbait title was "When this woman saw THIS she had no choice but to be gobsmacked". I like to think she sat down and considered her options and just had to settle on that.
 
what do you think her options were? 1. Ignore it 2. Report it to HR 3. Be gobsmacked
 
All wearing a translucent green visor and expertly jabbing at an adding machine, whose ticker tape has already spooled out into a substantial pile on the floor
Yep, the numbers add up... I can only be gobsmacked
 
@piRSquared the accompanying screen cap was of an owl so, unless she worked at Hogwarts or in an aviary, I'd say it wasn't a HR problem. That one can be ruled out pretty quick.
 
The most clickbaity thing I ever clicked on was "watch what we do with this knife and this baby" and it turned out to be a baby-shaped cake so now I just assume that all clickbait is cake-related
The owl was a cake, saved you a click
 
5:03 PM
@roganjosh Owls are known for their quintessential gobsmacked expression. It could have been for demonstrating how gobsmacked she was as opposed to hinting at the subject for which she was gobsmacked.
 
DSM
@Kevin: so you're saying the cake was a lie? Portal 3 confirmed!
 
Related question: How many times can you reasonably use gobsmacked in a sentence?
 
See, now I feel the need to provide a definitive answer to what it was all about... I should have clicked the link
 
Portal 3 confirmed, but instead of a game, it's a cake
 
@Kevin you said "cake" - so it must be TRUE!!! :p
 
wim
5:13 PM
what to do when user is editing to fix the bugs that they are asking the question about in the first place?
I'm rolling back ... but done it twice already
 
^ Throwing up hands in frustration seems to be the proper response
 
Allow edit, vote to close as "can no longer be reproduced", post your own version of the question, self-answer it, and ride the incoming wave of upvotes
 
" and ride the incoming wave of upvote" FTFY
 
I want to close this as a dupe of this. The OP is brute-forcing their way around OOP and pinning the issues on numpy. How do we proceed?
 
wim
Hmm I wonder who downvoted me
@JonClements thanks Jon, for your comment wielding the mighty diamond
 
5:54 PM
Might have helped might not - sometimes though, just dropping a comment with a diamond next to your name is enough
(now if that ended all disputes - I'd be a very happy puppy - but alas... :p)
 
Maaaah so many clouds. There goes my lunar eclipse watching :'(
 
I think I'm on the wrong side of the planet for the eclipse.
Equivalently, I'm on exactly the right side to witness the earth eclipse the moon, which is being eclipsed. Jealous?
 
pay to seed them so they rain themselves away?
 
Wait... wat... there's supposed to be an eclipse?
 
I have a ubuntu machine running some python scripts but monitoring system saying it is spanning nslookups. nslookup 0000 and nslookup -
Any idea where I would go to find what its doing?
 
6:03 PM
A total lunar eclipse will occur on July 27, 2018. The Moon will pass through the centre of the Earth's shadow. This will be the first central lunar eclipse since June 15, 2011. Since it will occur near apogee, this eclipse will also be the longest total lunar eclipse in the 21st century. Totality will last approximately 103 minutes.This eclipse will be the second total lunar eclipse in 2018, after the one in January. The eclipse will occur simultaneously with the perihelic opposition of Mars, a coincidence that happens once every 25,000 years. == Visibility == It will be completely visible over...
 
@Damon look at the Python scripts and see what they're doing?
 
They are several tools doing tons of different network stuff
But I don't know where to look first
Does it log lookups and stuff?
 
wim
continental USA recently had a spectacular total solar eclipse, so I don't mind to miss a ho-hum lunar eclipse.. ;)
 
DSM
Any pycharm + conda users around who didn't upgrade to 2018.2 recently?
 
@wim Rub it in
 
6:12 PM
@DSM /raises hand
 
DSM
I'm in the process of reconfiguring things to point at the right environment after my profile reset, and I can't remember if a certain fact was true beforehand or not..
 
@JonClements tonight, century's longest
 
wim
didn't pycharm used to update/patch itself?
now they are redirecting me to the download page, grrr
 
On the flip side, a clouded-out lunar eclipse is spectacularly less disappointing than a clouded-out solar eclipse
 
DSM
@piRSquared: cool. Could you open a PyCharm console in a project which is set up to live in a conda environment, and see if os.environ["PATH"] inside the console includes a bunch of environment-specific paths at the start?
 
6:14 PM
The good news is that the most disappointing experience of my life is already behind me
 
wim
where did you go for the solar eclipse?
 
I did see a totality around 2000
 
Somewhere in the path of the totality... Virginia? North Carolina? Something around there.
 
@Kevin Ahh... but will Future Kevin agree? :p
 
wim
I drove to Ste. Genevieve, Missouri and the skies were perfect
 
DSM
6:16 PM
totaloty <- like, really a lot
 
@DSM I use PyCharm in windows to edit code on linux. I use PyCharm as a fancy editor.
 
wim
the drive back was like a total traffic eclipse of the highway though ... :-\
 
Moderate enthusiasm for space stuff has been fairly constant through my life so I think Future Kevin will have the same viewpoint
 
wim
>>> 'L'if 000else'R'
'R'
>>> 'L'if 001else'R'
'L'
>>> 'L'if 00jelse'R'
'R'
>>> 'L'if 0b0else'R'
'R'
>>> 'L'if 0o0else'R'
'R'
>>> 'L'if 0x0else'R'
  File "<ipython-input-33-a74d8fb4fad9>", line 1
    'L'if 0x0else'R'
                ^
SyntaxError: invalid syntax
tokenizer fun
 
DSM
@piRSquared: that's.. less useful to me. :-)
 
6:19 PM
sorry.
 
DSM
I can't remember if I knew that leading zeros were still allowed as long as it was all zero or not.
 
wim
it's not off topic
but has been answered on main
you will probably have more success to search the difference between any two of them rather than all three
 
hummm ok
 
@MagicHat use Google search, not SO search, too even if the results point back to SO answers
 
wim
was that really necessary
 
Yup
Those 3 messages made me check if it was overexchange under a new name
 
wim
was it?
 
I nearly commented yesterday that I didn't realise that there was a public reading of the Voynich manuscript but sometimes I do think the policy is a bit draconian
 
Thank you for your input :)
 
03:00 - 19:0019:00 - 00:00

« first day (2841 days earlier)      last day (2090 days later) »