« first day (2491 days earlier)      last day (2460 days later) » 

12:02 AM
yup ^
you have valid points but most meta-savvy people probably disagree
 
wim
shrugs I've got plenty of stuff on meta
 
12:43 AM
I'm hesitant to post on meta. I find it bizarre to use up/down votes to express your agreement. There are plenty of good questions that I'd disagree with but should be recognized as good questions.
 
you don't strictly have to do that
I've upvoted many posts that I thought were good questions that I disagreed with
 
cbg
 
cbg
 
Also, more on the same question of closing indentation questions as dupes... I've joked before about creating a canonically bad question for the purposes of marking other bad questions as dupes. However, isn't it analogous to creating a canonical answer for handling indentation typos. I mean, can't I ask a terrible question then answer it my self with a well written statement about how to prepare a MCVE and then mark questions without a MCVE as dups?
Or even mark poorly asked questions as dups of stackoverflow.com/help/how-to-ask
 
@piRSquared no, because we specifically have close reasons for no MCVE, and posts closed as typos are actually solved
 
12:48 AM
I don't feel strongly about it. I'm just posing the question because it seems to be similar in function.
Oh, yeah.... I forgot about that
 
the indentation typo post as a dupe target would tell the OP (and any future readers) what might cause their problem
"your problem is bad and you should feel bad" isn't a solution, alas :)
 
Very good point
 
wim
Yeah I would like to discourage "your problem is bad and you should feel bad" except when it is really warranted
Of course there is noticeably more crap from 1 rep users nowadays. But I've been here long enough to remember back when the site wasn't quite so hostile to the newbies, and it was a better place for the most part.
 
I assume back then even decent people searched their problems and couldn't find an answer
the more knowledge there is (especially here on SO), the larger the ratio of crap in what gets asked
 
1:09 AM
cbg
It is definitely hard to ask good questions that have not already been asked and answered on SO.
Asking good questions is hard enough. Asking a good question that has never been asked before is even harder.
 
the point of it all should be solving your problems, not working hard to ask good questions
step 1: have problem
step 2: try to solve
step 3: fail
step 4: ask a good question
anyway, rhubarb from me
 
 
1 hour later…
2:26 AM
Hey guys, I'm using the Yelp api to scrape the max amount of local businesses at a given zip code
For some reason despite passing the offset key to get all 1000 results with a limit of 50, I only get 20 results in my csv file
any ideas?
Thought it might have been the use of a token that is called each mapped process call
But I moved it out of the partial token = get_token()
 
2:48 AM
in Android, 1 min ago, by Code-Apprentice
https://pcpartpicker.com/product/bL6BD3/msi-video-card-r72402gd3lp x2 or https://pcpartpicker.com/product/Pp8H99/gigabyte-video-card-gvn75twf2oc4gi x1? Which would be better for a dual monitor setup?
 
 
2 hours later…
5:10 AM
My profile pic (python):
 
 
2 hours later…
7:32 AM
@MalikBrahimi You have a return statement in your for loop. You can't ever get more than 20 results like that (one per process)
 
 
1 hour later…
8:42 AM
What the yam? How can this function possibly throw a 'str' object has no attribute 'path' error?
class Image:
    def open(self, *args, **kwargs):
        return self.path.open(*args, **kwargs)
print(type(self)) -> <class 'str'>????
 
hmm :D
now a tough one... which mojibake is this:
P├дiv├дkirja.xml
this should be Päiväkirja.xml
 
Cabbage
 
Oh, I found the bug. I accidentally called Image.open('/some/path')
 
I have no idea which codepage this could be
 
Since when does that not throw a TypeError?
 
8:49 AM
it is not cp437, 850, 1252, latin1...
sigh
In [29]: for i in encodings:
    ...:     try:
    ...:         if 'P├дiv├дkirja.xml'.encode(i).decode() == 'Päiväkirja.xml':
    ...:             print(i)
    ...:
    ...:     except:
    ...:         pass
    ...:
cp866
there is no way to list all encodings.
but wth is that cp866
 
that's what I used.
and that's just so wrong :(
 
@wim How you deal with indentation error questions is up to you. I'm not insisting that they get closed as typos, but I really don't think it's right to close them as dupes. Ideally, IMHO, they'd be closed as "Lacks minimal understanding" if we still had that close reason. Such questions require a tutorial on how to do indentation in Python, and SO isn't really a tutorial site (although I must admit that some of my answers can verge on being tutorials :) ).
I guess that linking to Christian Dean's Q&A is the next best thing to writing a custom tutorial answer for each indentation question, and I expect that it will be very helpful for most OPs who don't yet get Python indentation.
Code page 866 (CP 866) is a code page used under DOS and OS/2 to write Cyrillic script. It is based on the "alternative character set" of GOST 19768-87. The code was widely used during the DOS era because it preserves the pseudographic symbols (unlike Windows-1251) and maintains alphabetical order (although non-contiguously) of Cyrillic letters (unlike KOI8-R). == Character set == Each character is shown with its equivalent Unicode code point and its decimal code point. Only the second half of the table (code points 128–255) is shown, the first half (code points 0–127) being the same as ASCII....
@wim However, I certainly agree that we should try to avoid making the OP of indentation questions feel dumb. But we do need to let them know that they have an important gap in their knowledge that needs to be fixed for them to make further progress in Python, and that they should probably be studying about indentation in their textbook / tutorial.
 
9:29 AM
@PM2Ring why not as a dupe
of "how to fix indentation error" :D
 
@AnttiHaapala We keep dupes so they can act as signposts for others with similar problems. But there's so much potential variation in indentation errors that I don't think that typical indentation error questions make useful search targets for other people who have indentation errors. And so keeping such questions visible on the site just adds to the clutter.
 
so, close as a dupe and delete.
 
I guess we could do that.
 
9:47 AM
The main reason I'm not comfortable with that is that those of us with close-voting powers should bear in mind that just because we close-vote dupe questions that doesn't imply that dupe questions are bad, and they shouldn't be lumped in with questions that need closing because they are actually bad.
Dupe questions are only bad when they are really obvious, that is, if a suitable dupe target can be easily found with a simple Google search then the question deserves downvotes for lack of research. As I said yesterday, the main reason to close dupe questions quickly is to prevent them from getting new answers.
We don't want answers to be scattered all over the place: we want the answers to be pooled together so they're easy to find, and so they can fairly compete with each other in the voting process.
OTOH, a little bit of duplication doesn't hurt, and Jeff Atwood has argued that a little bit of duplication can actually be a good thing.
Jeff Atwood on November 16, 2010

As Stack Overflow grows — or any other Q&A; site in the Stack Exchange network, really — there’s a natural pressure to discover and link duplicate questions. The more questions you have, the higher the possibility a given new question isn’t in fact a new question, but a duplicate of an older existing question. Because of this, we’ve continually enhanced the tools for finding, linking, and merging duplicate questions:

Handling Duplicate Questions

Handling Duplicate Questions …

"What we want is on the order of 4 or 5 similar-but-not-quite-the-same duplicates to cover all possible search terms and common permutations of the question. It is also OK for these duplicates to have their own answers so people who find them don’t have to click yet again to get to a good answer."
 
10:10 AM
guys can i post a drive by question?
 
Questions are welcome as long as they're python-related and phrased in an understandable manner, drive-by or not
 
okay. its a basic one im new to python so... basically what i have to make is a post request to my web site
i tried to do it with postman and in c#(works fine there) but now i need to write it with python
for the start i just want to test is stuff is working and i should get a 401 error response
conn = httplib.HTTPConnection("https//:redmine.myredmine.com", 443)
conn.request("POST", "/isuess.json")
response = conn.getresponse()
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
this is the error im getting
im trying for the start to get this from a simple python script
but im unable to even get a response
huh
now that i removed the https:// it seems to work?
why is that so
 
Because https//: is not a protocol; https:// is.
 
and instead 401 im getting 401
 
please read the second pinned post -->
 
10:25 AM
no in my file i wrote it okay
it was https://
 
You might need HTTPSConnection for that? Guessing here
 
nah is the same
 
Also, use python 3 unless you have a really really good reason not to
 
we are using python 2.7 on the app itself
 
OK :)
I'm out of rubber duck ammo
 
10:35 AM
its an older app and im new to python so its not like i have much to say about it
 
Too bad...they're doing you harm by making you learn python 2
 
there is a lot of difference between 2 and 3?
 
@Proxy There are a few important differences, eg the handling of Unicode text data vs binary data.
 
@Proxy I would recommend you to use different library for http requests
try requests package
 
It's probably easier to get a solid foundation Python 3 first and then learn about the Python 2 quirks, than to learn Python 2 first and then have to un-learn the quirks & learn the nicer Python 3 way. BTW, Python 2 reaches its official End Of Life in 2020.
 
10:41 AM
i have to avoid using 3rd party libraries
 
@Proxy That's a pity. Even though Requests is a 3rd party module, it's so good (& so popular) that the official Python 3 docs recommend it.
 
yeah i know, but that is what i have to work with
 
Fair enough.
 
also coming from c# the syntax is weird
especially writing variable names without a type before. or at least the var keyword
 
@Proxy As Andras said, you ought to use class HTTPSConnection to connect to a HTTPS host. But more importantly, the HTTPConnection and HTTPSConnection host arg needs to be a domain string, eg 'www.example.com', you shouldn't prefix it with the 'http://' or 'https://' protocol.
 
10:48 AM
oh i did not know that
i guess im able to drop the www.?
 
I hope you have a good reason to not use requests, because whole power of python lies in external libraries. httplib is fine but its just a little bit cumbersome
the same code with requests would be like 2-3 lines of code
just saying :p
 
as i said i was assigned with a task and told not to use any external libraries
 
@Proxy Yeah, that takes a bit of getting used to. But variables work differently in Python to many other languages. The name is just a name: a label for an object, it doesn't store any type information, the object itself looks after that.
 
i think its because currently the only one developer who knows python is on vacation so they want to make sure i wont break anything :)
 
See Other languages have "variables", Python has "names" for a quick explanation with cute diagrams.
 
10:51 AM
will take a look. thanks @PM2Ring
 
For a more in-depth article, see Facts and myths about Python names and values
 
:)
now im getting an error about handshake failure... guess certificate problems on my side...
oh well lunch 1
 
11:31 AM
I wish we could upvote close votes. "Nice dupe target bro, have some rep"
 
@Rawing Well, you can upvote the "Possible dupe" comment, but they evaporate rather quickly. :)
But yeah, it's a perennial topic on SO Meta that dupe hunters ought to get more incentives.
 
12:00 PM
OTOH it could lead to "my dupe is better" wars
 
12:19 PM
@Rawing I suppose it could, although gold badgers now have the ability to edit additional links into the dupe target banner, so if there are multiple good dupe targets they can all share the glory. :)
 
Design question. Suppose I am writing a remote API that allows clients to play a game of chess with one another. For most kinds of moves the user can make, they call a method move_piece(source_position, destination_position) to move their piece for the turn. When the user moves his pawn to the end of the board, he may choose to turn it into another piece.
How should I integrate this into my API? Should I change move_piece's parameter list to (source_position, destination_position, piece_this_piece_will_become_if_it_is_a_pawn_about_to_be_promoted=None)? Should I create a promote(position, new_piece_type) method that the user must call in addition to his move?
 
hi hi
 
At a more general level I'm interested in API design principles that dictate how "atomized" one should make their interface if it's possible for the user to perform multi-part transactions
 
i like first version better
because moving a pawn to last line and not promoting would end up with invalid state
 
If I implement a promote method and if the user does not want to promote his pawn, I imagine I would either 1) require him to call promote with "pawn" as the new piece type argument, or 2) create another method end_turn which they call to indicate that they don't want to perform a promotion
 
12:32 PM
I don't like the idea of having a promote arg for every move, since most of the time it's irrelevant, and the normal move handling logic shouldn't have to bother with it most of the time. But I guess it's not a big deal, since you can make it an optional arg.
 
hi there! I'm currently trying to access a class method and class variables which belongs to an instance of class A from inside class B. I tried nesting, which makes it possible to pass the methods from class A to the nested class B, but like this I can't access the variables of the outer class after they changed.
 
The benefit of changing move_piece's paramter list is that the amount of game state I need to explicitly store on the server and relay to users is minimized. I can represent state as "here is the position of each piece. It is Black's turn to move.". If I created a promote method, I would have to represent state as "here is the position of each piece. It is white's turn, after they have moved, but before they have decided whether and how to promote the pawn at position P"
 
And I guess you also need to deal with castling, where two pieces get moved in a single move.
 
Using class attributes and @classmethod doesn't work, because I want to jitclass the classes with numba... any idea how i can do this?
(currently everything works with inheritance for the methods and using class attributes for the variables, but numba doesn't support both)
 
never used numba, or jitclass...no idea what those are.
 
12:35 PM
Having to have granularity of state finer than "it is X's turn" means that I'm sending a full extra byte of information for every get_state call, and it pollutes my server's GameState object with a bunch of self.position_of_pawn_whose_promotion_is_pending-like attributes that will be empty 99% of the time
 
well, numba introduces the jit/jitclass decorator to speed up python by using LLVM compiler
 
@Scotty1- I don't quite understand what you mean by "class variables which belongs to an instance of class A". Are these "class variables" class attributes, or are they instance attributes?
 
maybe you should provide an example to help illustrate what you are trying to do.
it's sometimes hard to visualize.
 
@PM2Ring currently I'm using class attributes, but numba can't deal with them. so I want to go to using only instance attributes
 
@Kevin Ok. In that case, I guess it does make sense to store the promotion state as an arg of the move_piece method rather than cluttering the game state with it.
 
12:38 PM
data = urllib.urlencode({'key':'fdsf425otrkf45349gdvfsfsi34645gegfdv',
                            'issue':{'subject':'testiram',
                            'description':info,
                            'project_id':'9',
                            'tracker_id':'7'}})
is this a valid json for urlib?
 
@idjaw yea, I m currently trying to shrink my code to a minimum working example (or better: not working example)
 
@Proxy That's a valid Python dict, if that's what you mean. It's not valid JSON, though, because JSON uses double-quotes, not single-quotes.
 
yeah i need to convert it to post parameters
 
I don't think that's valid input for urlencode, no
 
That's assuming that info contains something valid. :)
 
12:40 PM
it does :P
 
But yeah, I don't think the parameter encoding scheme can cope with a nested dict. You probably need to flatten it somehow.
 
recbg
 
spec = [
        ('a', numba.float64),
        ]


@numba.jitclass(spec)
class subcls():
    def __init__(self, a):
        self.a = a

    def test(self):
        return self.a


subcls_type = numba.deferred_type()
subcls_type.define(subcls.class_type.instance_type)
spec2 = [
        ('n', numba.float64),
        ('k', subcls_type)
        ]


@numba.jitclass(spec2)
class supcls():
    def __init__(self, n):
        self.n = n
        self.k = subcls(n)

    def print_test(self):
        print(self.a)
a = 3
n = 2.8
 
ctrl+k for code format
 
subjit = subcls(a)
supjit = supcls(n)
 
12:46 PM
if there's that much code, using a pastebin/gist might be better
 
sorry for that long code
 
especially instead of posting it in multiple lines
 
yeah, i head commented lines in between, I was hoping no one replied before i finished posting it
 
hah, you wish
 
now what i want to do and what is not working: supjit.k.print_test()
yea ;P
I want to access the class method from the outer class from within the nested class. @classmethod or instances don't work with numba
 
12:48 PM
@Proxy Python 2 urllib.urlencode seems to cope ok with the nested dict, but the inner dictionary doesn't get turned into proper paramters, it gets treated as a single string.
 
@Proxy to post json you need to set proper header
and you dont really need to use urlencode as far I know
you can just use json dumps
 
Calling urllib.unquote on the result returns this string:
issue={'project_id':+'9',+'description':+'info',+'tracker_id':+'7',+'subject':+'testiram'}&key=fdsf425otrkf45349gdvfsfsi34645gegfdv
 
header = {'Content-Type': 'application/json'}
 
and I also need to access instance attribute n from within supjit.k but numba doesn't support class attributes (which i currently use to do things like that)
 
@Scotty1- where's the nested class?
 
12:51 PM
@marxin yeah json dumps solved the problem
thanks for helping me out @everyone
 
@PM2Ring Yes, but there is one benefit to high granularity of state: if the user moves his pawn, and his browser crashes before he can promote, then when he re-establishes his connection to the server, the server can say "welcome back. You previously moved your pawn to position P and I am now awaiting your promotion choice". If the state is not high granularity, then the server can only say "it's your turn, I haven't gotten any move data from you yet"
 
@AndrasDeak well, this is my current code with which I tried to do it. my old code which I tried before used nested classes. in this code I m only creating a class instance in the other class... but I want to avoid using nested classes anyways because it would impede the modularity of my code...
 
OK, but if you're showing one code and asking about the other, what result do you expect?
 
In the specific case of chess, it's not a huge deal that a crash would cause some already-performed-but-not-committed actions to be lost. Since at most all you lose is a single pawn move. But there may be other kinds of transactions in other kinds of games/applications where you'd prefer to recover as much as possible.
 
if it would be a web api, first solution is much better
 
12:55 PM
@AndrasDeak true... sorry about that. unluckily I already had my code modified while I was still thinking about nesting...
 
For instance, if I write an API for Risk, when the user turns in three matching cards, he may place upwards of thirty army men on any combination of territories he controls. If he places 29 army men and the browser crashes and all his placements are lost, this would be a pretty bad user experience for him
 
@Scotty1- also: at first glance it seems to me that there's supjit.print_test vs subjit.test, but you're trying to call supjit.k.print_test which would be an attribute of subcls which doesn't have print_test...does it?
 
yeah, that s correct. in my current working code (without numba, but i need numba for speeding it up) I use inheritance to make that work. but now I m looking for a workaround without inheritance
and I was hoping to be able to use instances of one class inside another class to access the outher class' methods.
 
I don't understand. Do you agree that your code is broken and that's why it's not working?
 
yes
 
12:58 PM
So what exactly are you asking...?
 
Jul 24 at 14:37, by PM 2Ring
@Scotty1- The Python philosophy is that composition is generally better than inheritance, but inheritance is almost always better than nested classes.
 
@PM2Ring yep. but numba makes composition and inheritance impossible...
@AndrasDeak I need to find a way to access one class method from inside another class without using @classmethod and also to access instance attributes from another class without making them class attributes...
 
@AndrasDeak I was just following the tag-guideline: Use the more generic [python] tag if your question is not version-specific. I haven't thought about dupe-detection but in case you (or someone else) thinks that provides more exposure I would suggest python-3.x and python-2.7. The python-2.x tag is not used as much as python-2.7 — MSeifert 3 mins ago
 
I don't know numba, but it seems weird to me that it prevents composition. After all, all Python classes use composition, since everything in Python is an object, so every instance attribute is an object of some class or another.
 
for the powers that be ^
@Scotty1- you first need to write a piece of code that's supposed to work using @classmethod!
 
1:02 PM
Taken to the extreme, in general I have two choices when creating a remote API of a transactional nature: discretize the interface so every call to the server only contains the smallest amount of user choice information; or generalize the interface so that every call to the server contains as much choice information as can possibly be provided.
 
as I said, your above code tries to access the method of a wrong class!
 
It's place_reinforcement(location) called thirty times, vs place_reinforcements(locations) called with a single thirty item tuple
Or even something like performActions((PlaceReinforcements(locations), MoveBattalion(source, destination), initiateCombat()))
 
@Scotty1- until you show us a piece of code that works without @jit and breaks with it (or documentation stating the same thing), I don't think it's merited to assume that "numba forbids classmethods"
 
@Kevin you have a local cache as well, if browser crash you can recover some stuff
 
@AndrasDeak yea, just a second. I had a code with classmethod before... just need to rewrite that. bwt, numba documentation of jitclass also says that it forbids classmethods
 
1:05 PM
or you can even save state to the server but commit will happen when specific function is called
 
@Scotty1- OK, now that's a good reason
 
@marxin That seems like a small nightmare to get right, though. If I have send_move_to_server(); save_locally(), and if the browser crashes after sending the move but before saving, then the local state will think that it's my turn, but the server will think it's the other player's turn.
If I instead have save_locally(); send_move_to_server(); and if the browser crashes after saving the move but before sending it, then the local state will think that it's the other player's turn, but the server will think it's my turn.
 
in theory you could even have something like SQL - begin transaction function, do some stuff, commit function
not really because when you restart the browser, you will query the server to get current state
 
So in case of local state and server state disagreeing, the server state wins... Hmm, that may be valuable in some circumstances.
 
@numba.jitclass(spec2)
class supcls():
    def __init__(self, n):
        self.n = n

    @classmethod
    def print_test(self):
        print(self.n)
@AndrasDeak this just gives a typeerror that numba can't use class members. same error when trying to use class attributes. so this is where my problems come from
 
1:10 PM
OK
so do you really need a classmethod?
And why do you call the first arg of the classmethod self?
 
uhm, that is because i just copied my other class, deleted some stuff, added the decorator and forgot about the self :)
and no, classmethods are not required. but inheritance also doesn't work. passing the "outer" class to the inner class during instance constructions works for methods, but not for attributes.
well, it works for attributes, but it seems like it is copying the attributes and not only referencing them, or is that wrong?
 
I can never find any good tutorials on the hyper-abstract problems that I come up with these days... Maybe they're on the Dark Web.
15 design principles that doctors don't want you to know about!
 
@Kevin - have you considered passing in a Move object? Subclasses of Move could be MoveAndPromote or MoveCastle, and these would contain the specifics of those special move types.
Sorry if I am chiming in late and this was already considered
 
1:25 PM
I very briefly hinted at that kind of possibility in chat.stackoverflow.com/transcript/message/38624766#38624766
Game history playback and an Undo queue are some "nice to have" features in my design, and they would probably require a hierarchy of Action classes representing anything the user is capable of doing
 
This keeps your signature from getting polluted with all different kinds of moves. Even moreso for games like Risk that you mentioned earlier. The Move object encapsulates the complete information for an atomic move, that can be done or undone.
 
\o cbg
 
cbg
 
Y'know, the last super abstract problem I had ("Is it OK to have duplicate mutable data?") was solved to my satisfaction when I looked at five example implementations on github and every one of them used the same approach. Maybe I should do that more often.
 
In object-oriented programming, the command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time. This information includes the method name, the object that owns the method and values for the method parameters. Four terms always associated with the command pattern are command, receiver, invoker and client. A command object knows about receiver and invokes a method of the receiver. Values for parameters of the receiver method are stored in the command, the receiver object to execute these...
 
1:34 PM
@PaulMcG That's where I got the idea for an undo queue in the first place :-)
 
But the benefits go beyond just support for Undo
 
Yeah the list on that page has like nine other things
 
I did something similar in my pyparsing adventure/interactive fiction demo. User statements ("take shovel") get parsed into xxxCommand instances (TakeCommand), which the game engine then executes using game state and player state.
The game loop is very simplistic, and it is easy to add new types of commands without butchering the "execute()" signature
 
@Scotty1- I have no idea, but frankly I'm not sure I understand what you mean. You can set this up, and check the id of the input instance attribute and the one that is created. But if you're passing an object, I find it unlikely that its attributes are magically copied
 
No TakeShovelCommand, though? ;-)
 
1:40 PM
cbg
 
No - the TakeCommand gets inited with the object reference, which may or may not be present, be takeable, etc. If can't be taken, some snarky response is returned.
 
In the game Peasant's Quest, in order to complete the game you need to execute the command >THROW BABY. IIRC it's the only time in the game you need to throw anything, so it may have indeed been represented in the code as ThrowBabyCommand, since a generic ThrowCommand would not be necessary.
 
You wouldn't want classes to proliferate just because you add a new object
Ok, I could see it for something this special - but generally you wouldn't
 
Just gotta use metaclasses, then B-) for obj in all_objects_in_game: create_throw_subclass("Throw{}Command".format(obj.name))
 
I have a simple design woe myself. I want a simple collection of objects (dicts and arrays and whatnot), which I can pass as one bundle to many functions. I might want to use .attr kind of access to the stuff inside. Should I define a class that just assigns All The Things to self.attrs in its __init__? Should I use a namedtuple? Is there another suitable solution?
 
1:44 PM
(Disclaimer: I am not seriously advocating for this design)
 
@AndrasDeak - I think I've seen some reddit posts recently for classes which do this, not copying attributes but just doing __getattr__ tricks to do __getitem__ under the covers
 
I considered that...essentially monkeypatching/subclassing dict I mean. Is that not unnecessarily ugly/convoluted?
I want a 4-5 field with fixed names, so namedtuple can work for me
 
If I'm lazy, I use a dict and try to live with only having ["attr"] access and not .attr access. If I'm not lazy, I write a dict-like class that overrides __getattr__, as Paul describes.
 
It will only be ugly on the inside
 
@Rawing but isn't a return fine because there are multiple processes?
 
1:48 PM
yeah, I'm usually happy with dicts, but in this particular use case (passing a bunch of things to and fro) I feel it might be cleaner to use attribute access
 
Yeah you can encapsulate all the ugliness inside the AttributeyDict class, which nobody needs to look at if you document it sufficiently well
 
thanks guys, at least I'm not as confused as I usually am :)
 
@MalikBrahimi It's fine if you only need 1 result per process. 20 processes, 20 results.
I'm not an multiprocessing expert, but the easy solution would be to just return a list of results instead
20 processes, 20 lists of 50 results
 
Yeah I just tried that
instead of returning in the for loop I append to a list which is returned at the end
but I got an error
 
oooh, an error :P
is it an IndentationError?
 
1:52 PM
class AttributeyDict(dict):
    def __getattr__(self, name):
        try:
            return super().__getattr__(name)
        except AttributeError:
            return self[name]
    def __setattr__(self, name, value):
        self[name] = value
d = AttributeyDict({"foo": 23, "bar": 42})
d.baz = 99
print(d.foo)
print(d.baz)
Something like that.
 
@Kevin thanks. I even understand the super part, which I would've forgotten to do.
 
@AndrasDeak Lol indentation error
 
Jan 29 '16 at 17:11, by davidism
@MalikBrahimi my idea is that you read what I posted above about MCVE.
 
Ok, no I have 54 results but I should be getting like 1000
 
that was 1.5 years ago
 
1:55 PM
What was that lol
and how do you have the time to hunt thru 1.5 years of chat
lol
 
@AndrasDeak How did you dig that up?
 
"-Do <solution> instead." "-I tried <solution> but I got an error."
 
Is the super() part necessary? I think you only need that if defining __getattribute__.
 
__getattr__ only gets called if you specify a non-existent attr name, which dict is unlikely to respond to
 
1:56 PM
@AndrasDeak yea, you are right. it is not copied... looks like i made an error somewhere. if i remember it right i was slicing a numpy array, that could be the cause for copying... thanks for your help!
 
Understanding every part of an error message and stack trace is like using every part of the buffalo. Show respect to your environment by making full use of the bounty given to you.
 
@PaulMcG thanks, I didn't know that
 
(Hmm, are non-Americans aware of the buffalo trope or is this one of those half-lies that only impressionable United States kids learn)
 
I wasn't, but I figured what you mean
 

« first day (2491 days earlier)      last day (2460 days later) »