« first day (1601 days earlier)      last day (3341 days later) » 

1:46 AM
Hi again I posted a question, updated status and still the same... I am stuck with this:stackoverflow.com/questions/28531573/…
 
 
3 hours later…
5:09 AM
again a question from the same user, the previous one actually was tolerable but this is unclear, and lacking the code really.
 
5:25 AM
@AnttiHaapala I just hammered it...
 
6:22 AM
cbg
@thefourtheye lol wrong link :D:D
but yes, that is a dupe
 
@AnttiHaapala ;)
Cabbage
 
6:52 AM
I have a object called Game, and a collection of Game objects. Each one has a secret key. I'm wondering if it's better to have the collection be a dictionary from secret key to Game object or just a list of Game objects with the secrets being an attribute of the object.
The first scenario would allow quick lookup by key (which is necessary) but then the secret key isn't truly part of the Game object
Is there a way I can have Game.secret with O(1) lookup?
 
@quantumtremor well make Game know the GameCollection it belongs to, and make Game set the secret->game in GameCollection upon changes to Game.secret...
 
Wouldn't that mean a game collection object in each Game?
I guess that could work with databases but I'm confused on how to do this without
Game.secret will never change once created by the way
I think I'll just go with the dictionary for faster access
 
7:20 AM
_csv.Error: field larger than field limit (131072)
WHATTA FSCK??
what stupidity is this?
24
Q: _csv.Error: field larger than field limit (131072)

user1251007I have a script reading in a csv file: # example from http://docs.python.org/3.3/library/csv.html?highlight=csv%20dictreader#examples import csv with open('some.csv', newline='') as f: reader = csv.reader(f) for row in reader: print(row) However, this throws the following error...

ofc no one would tell about that either
 
7:35 AM
@AnttiHaapala what's the matter? :)
As in it's probably not that, and it's a dumb suggestion?
 
@RobertGrant I mean who in right mind would think it is good to break zero-one-infinity like this, and then that you can set a global value to change the default
 
Ah yeah, that was the other reason I though you might be saying that
 
"New in version 2.5."
 
I reckon Rasmus Lerdof joined the team at that point
 
csv.field_size_limit([new_limit])

Returns the current maximum field size allowed by the parser. If new_limit is given, this becomes the new limit.

New in version 2.5.
so, we get a crash on production because it so happened that there was 1 column that was > 128k
 
7:46 AM
Oh, it was added as a nice feature
That's pleasant
 
of course it is not documented anywhere else
it is just that there is a function "field_size_limit"
I have read the entire manual, but somehow skipped that method, because no one talks about it anywhere.
I am now looking at the source code of _csv
 
done
how do I see a commit message in Hg?
Set an upper limit on the size of the field buffer, raise an exception when this limit is reached. Limit defaults to 128k, and is changed by module set_field_limit() method. Previously, an unmatched quote character could result in the entire file being read into the field buffer, potentially exhausting virtual memory.
 
8:06 AM
Wow, that seems like the wrong way to solve that
 
I think I am going to do my own csv that will use mmap
 
Yeah mmap seems better, though will it work outside of cpython?
 
culprit is Andrew McNamara
this is in C implementation
 
Oh yeah true
 
the whole stuff is a CPython implementation detail
ofc the limit is not documented anywhere bc "you can always ask it"
however it has been 128k all this time
 
8:10 AM
Blimey
Hackety hack hack
 
8:20 AM
I picked 'typo'.
Another typo question.
Another typo. And badly asked. The traceback in the comment shows they doubled a : colon.
They are coming in thick and fast this morning.
 
Cbg :)
 
@MartijnPieters nice to be the closer on so many :)
 
9:08 AM
how can I see TravisCI build output??
I just have 2.6, 2.7, failed...
 
9:35 AM
train cbg
 
hate when python C api documentation does not a) link to source, b) say whenever it returns borrowed references...
what is the type of tp_str?
reprfunc
 
Cabbage
 
cabbage
 
That question this morning was so full of wut…
 
Typedefs: unaryfunc, binaryfunc, ternaryfunc, inquiry, intargfunc, intintargfunc, intobjargproc, intintobjargproc, objobjargproc, destructor, freefunc, printfunc, getattrfunc, getattrofunc, setattrfunc, setattrofunc, reprfunc, hashfunc
of course do not say them in documentation
actually using the prototype would mean that my C code would not have undefined behaviour.
 
9:49 AM
cbg
@MartijnPieters With the emphasis on thick...
 
yeah: all functions are called with 2 arguments except if it is a METH_VARARGS | METH_KEYWORDS, then they are called with 3 arguments
can't believe there are suggestions that you should use casts
static PyObject *
Buffer_str(PyObject *self) {
    return Buffer_join(self, NULL);
}
 
While looking at the transcript to see the context of Fizzy's starred "Thanks for answering my question", I noticed that weird re.split example:
>>> re.split(r'\t', 'a\tb\tc')
['a', 'b', 'c']
That's scary.
 
yea
for that one 'a\tb\tc'.split('\t') would do
docs.python.org/3/c-api/structures.html#METH_VARARGS ah it is actually documented well here.
 
Sure. I always use plain str methods in preference to re. And when I do need to use a regex I generally run a few test examples to make sure I haven't screwed something up. And I almost always use compiled regexes and raw strings. But even so, I'm now worried that I've got regexes lurking in my code that don't always do what I expect them to.
 
>>> re.split('\\t', 'a\tb\tc')
 
10:05 AM
Cbg
 
I had UB in my C code :(
 
@AnttiHaapala Sure. But this bug isn't confined to re.split. Eg,
>>> re.findall(r'.\t', 'this is\ta test\tof the\tTAB bug')
['s\t', 't\t', 'e\t']
 
10:25 AM
@PM2Ring I kinda understand it, but I'm not sure that sorted() can do that.
I'd say use sort then interweave stride slices based on the repeat count, perhaps.
just not going there.
resource request.
 
@MartijnPieters Maybe, but the OP says that the repeat count is identical for all elements in the list of dicts.
 
so, sorted(set(keys)) then manipulate that based on the number of repeats?
 
@Ffisegydd too complicated, were it using Python 3.4 and annotations
 
10:41 AM
guys? can i interrupt you just for a moment with a silly question
 
you just did :d
 
11:06 AM
Lol
 
@PYPL We're still waiting...
 
25 minutes of silence thanks to you D:
 
github.com/dc-js/dc.js found a new toy :3
 
xD sorry was away
how can i convert "Sat Feb 28 12:27:08 2015" this type of date to a standart type 28/02/2015
 
well, 28/02/2015 is hardly "standard" :D
 
11:19 AM
yeh but it's shorter
 
@PYPL you can parse the string with datetime.strptime(), then use datetime.strftime() to format it again.
 
@AnttiHaapala It is where I live. :)
 
Look up datetime.
 
See docs.python.org/2/library/… for the syntax.
"%a %b %d %H:%M:%S %Y" ought to do it (untested).
then output with "%d/%m/%Y".
 
@PYPL Are you reading dates in that format from a text file (or user input), or are you getting them in that format from a Python function?
 
11:21 AM
This is unclear to me
 
im reading it from am xml file, thanks Martijn gonna try it now
 
>>> datetime.strptime("Sat Feb 28 12:27:08 2015", "%a %b %d %H:%M:%S %Y").strftime('%d/%m/%Y')
'28/02/2015'
 
@Ffisegydd London again angel.co/l/GALVG
 
aww yes that's it! thanks alot
 
I'd not format the datetime objects until absolutely necessary.
 
11:23 AM
datetime.datetime.strptime('Sat Feb 28 12:27:08 2015', '%a %b %d %H:%M:%S %Y') works if your locale is set to English
if you do anything with locale then you can get
ValueError: time data 'Sat Feb 28 12:27:08 2015' does not match format '%a %b %d %H:%M:%S %Y'
 
@AnttiHaapala and the default is C, even if the LANG parameter in the parent environment was set.
You need to explicitly inherit the locale for that to be a problem.
 
I know
 
@MartijnPieters You are closing in on Ignacio Vazquez-Abrams
 
11:42 AM
@thefourtheye I am. Mostly focussed on getting into the top 20 at the moment.
But Jonathan Leffler has decided to speed up the moment I came close. :-P
 
Oh, then two days it is... :D
 
@MartijnPieters I find that annoying; OTOH, it's not that hard to import locale and set the locale appropriately. But it's still annoying that it doesn't happen automatically for stuff that's locale-aware. IMHO.
 
@PM2Ring I would find it terribly annoying if it did do that.
Locales should only be set for code where this matters. End-user GUIs and stuff.
 
I think this question is being unfairly down-voted.
 
The majority of code does not need it and could break in bad ways if this was done automatically.
It'd be a terrible idea for a web server, for example.
@PM2Ring not sure about that. I don't see research and effort in understanding what they have.
 
11:47 AM
@MartijnPieters Hmm. I'll have to think about that. Why would it be annoying for a Python script to respond to a locale set explicitly in the command line environment, like standard bash commands do?
 
@PM2Ring It should be an explicit choice.
 
@MartijnPieters Ah. Ok. That makes sense.
 
> Explicit is better than implicit
@AvinashRaj: treasure hunt: try and find more machine names I use.
 
cbg!
 
This guy has scored 190 on his first day! Unfortunately, his answers tend to be a bit sloppy, and all the ones I've looked at use txtspeak, like "ur" and lowercase "i". I've tried to encourage him to fix up his spelling with this comment, but he's ignoring me.
 
11:57 AM
Ignoring you or hasn't read it :)
 
Well, he's answered 2 questions since I made that comment, so maybe he's just too busy to notice I made the comment... and down-voted him 50 minutes later. :evil grin:
 
@PM2Ring BTW, OP is asking for recommendations :D CVing
 
I need to push few files (like around 1000) from client to Django server. I have tried ftplibbut still it's not helping me. Any advice ?
 
Why use Django?
 
@thefourtheye Good point. And his question is a bit muddled.
 
12:06 PM
As opposed to, say, WebDAV
 
@PM2Ring Just left a comment...
 
the answer by padraic there is much better
 
I have a Django app where they can upload resumes of each candidates. Taking each resume one by one and uploading it is becoming tedious. Later I tried with something called "multiple upload" where they could upload two to five files by selecting the files holding Ctrl. But now I want to do something like bulk uploading of resumes i.e. I will be giving the path of folder and resumes inside the folder will be uploaded to FTP server on cloud.
 
0
Q: Baleful Python rites working when they souldn't

mathgeniusI have the following code: >>> pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')] >>> pairs.sort(key=lambda pair: pair[1]) >>> pairs [(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')] I have just gotten to lambda functions and i get how they work, ot at least, i can comprehend the ba...

See the tags
 
@d-coder Amazon AWS S3 service allows uploading directly with HTTP
one can use drag-and-drop with javascript... though not yet perfect...
 
12:16 PM
@AnttiHaapala It is. But mata's answer also contains useful info.
 
yes I upvoted it too, ofc
 
I tried something with FTP actually. It runs well as standalone file but when I integrate with Django server code then it chokes.
 
@thefourtheye ROFL
 
@d-coder I'd just not use Django and say that for bulk upload they use webdav or similar
Or what Antti said, which might work nicely
 
12:19 PM
what was wrong with the ctrl-click-approach?
only 5 files?
 
I have reasons to stick to Django. I'm doing some extraction on those resume to extract name,mobile number, email id,etc. after I put it on server and putting it in database.
No I need to upload around 1000 files on each click.
 
control-A in file selection dialog
the cross-folder is something that is problematic
or you can upload a zip
 
yes
But How to unzip it on server >
?
 
1
A: Baleful Python rites working when they souldn't

AKX# The following incantation shall summon from the depths # of the data abyss thirteen entities: four tuples, # four integers, four strings and a list containing all these. # The amalgamation of these entities, the list, shall be bound # to the name `pairs` to further do our dark bidding without #...

 
@poke: you and me both got downvoted on the shifting bits in a bytes value question.
I do wish people would ask for clarification rather than downvote.
 
user559633
12:37 PM
@AnttiHaapala hooray, someone else is starting to crack a little too
 
In Python 3, the cmp parameter was banished to the innermost circle of the 9 realms of Hades. In it's place, the even more diabolical functools.cmp_to_key() incantation has sprung forth to baffle fledgeling wizards even more. — Martijn Pieters 49 secs ago
Finally. Stoopid chat server
 
12:53 PM
guess the relevant comment was removed?
 
@MartijnPieters It's a shame that the OP hasn't responded to any of the answers or comments on that page.
 
@PM2Ring it is, but I suspect that the daemons from the fiendish pentagon on the floor have dragged him in and under.
 
Could be. He needs to read Pratchett's "Eric" to learn the dangers of meddling in this stuff. :)
 
morning everyone
 
@PM2Ring yes, that's definitely the reference text :)
 
user559633
1:06 PM
I don't understand why cmp() went away. it was simple and did what it said on the box
 
user559633
(this isn't complaining -- if there's a good reason, i'd like to learn)
 
user559633
thanks! yeah, still not convinced it was good to remove.
 
Yeah me neither
 
user559633
so useful and easy
>>> cmp(1,2)
-1
 
1:09 PM
Just don't make your custom sets comparable if they can't be compared
Although not equal is useful I suppose
 
user559633
exactly. it feels like a "screwdriver didn't work with nails, so the screwdriver is at fault" approach
 
@MartijnPieters meh.
Or at least they should add a reason to their downvote, so one know what’s going on
 
user559633
i find out if i'm quitting my job today :)
 
ohh
getting news about your job application then?
 
@tristan yay or oh dear?
Ah, you applied somewhere else. :-P
 
1:12 PM
Weird you say that, I got approached about a job recently as well, but I think I won't take it
 
user559633
I told my employer that I'm leaving NYC and would need to go remote.
 
Ah :)
 
user559633
And I was told that the discussion would happen at the beginning of the week, and here we are :)
 
And leaving the timezone as well :)
 
user559633
Yep :)
 
1:14 PM
Oh right, you were coming to Germany, right?
 
At least you'll have a cool website to advertise your place on :)
 
user559633
I actually think it would be more helpful to (employer) to have me on a different schedule. The tech department at (employer) has decently high turnover and it would be useful for them for me to pick up feature dev/pay down tech debt while they're sleeping.
 
user559633
@poke Yeah, visiting with my parents for around a month and then heading over to Berlin
 
nice :)
 
usually employers aren't that smart...
 
user559633
1:16 PM
@RobertGrant :) cheers. (and if this play doesn't work out, it will be launched sooner)
 
@PM2Ring: Python interprets tabs as up to 8 spaces.
 
Fixed
 
is there some special way to encode the state parameter in an oauth request?
 
I thought it was base64
(But I literally know nothing so don't do that unless someone else says to)
 
@PM2Ring Am I missing something, or do you make it a point to explain things, that people agree with you on, to them?
 
1:27 PM
@tristan I sometimes miss cmp - I'm kinda used to it, coming from C. But key is heaps more efficient than cmp, since it's only called once on each list item, instead of every yamming time a pair of items needs to be compared.
 
user559633
@PM2Ring but if you're passing items to a function pairwise...
 
1. Just because someone agrees with you, doesn't mean they fully understand something. 2. Other people may read it, and explaining is very rarely a bad thing.
 
@tristan Yea, ok. In that situation cmp makes sense. I was only talking about in the context of sorting a list.
@ljetibo I can do that if I haven't realised that they agree with me. :) Or if there are other people looking at the interaction who might want more details.
 
Moro
 
@IntrepidBrit on phone so can't get other room, will reply in there in a few
 
1:32 PM
sure, :D I just couldn't figure out why you're still ping-ing me and thought I said something wrong.
 
The 80 chars PEP-8 rule makes my code look ugly :'(
 
@thefourtheye but at least it fits perfectly inside the latest monitors
You are coding on a mainframe, right?
 
user559633
:)
 
user559633
I use 120 char as my width
 
user559633
because come on
 
1:36 PM
I just make all my function and variable names 1 character long, so my code always fits inside 80 characters. If you need more than 26 variables at once then it's a good sign your code should be refactored.
 
@ljetibo Sorry about that. But you did say "afaik python indent is 4 spaces" and I felt obliged to respond to that, even though I use 4 space indents myself and consider it a de facto standard. FWIW, some excellent Python programmers think it's insane to use spaces for indentation, and only use real tabs.
 
I'm pretty sure you just stole one of my jokes. I'll see you in court Bob.
 
user559633
26 variables in one file of code?!?? what are you trying to do, use computers to solve a complex task?!?
 
@tristan No open a good text editor that lets you work on files side by side. Suddenly 120 characters look like a lot.
 
user559633
 
user559633
1:40 PM
I disagree
 
Me too
 
user559633
And I'm using textedit.app. Don't tell me I'm not using a good text editor.
 
Aug 5 '14 at 14:42, by Ffisegydd
Stop using long variable names! There are 26 letters in the Latin alphabet! If you need more than 26 variables then you're doing something wrong.
 
Wow, that was diligent of you
Also I'm pretty sure I only joined in October or something :)
 
user559633
How's your crippling depression going @Ffisegydd?
 
1:44 PM
Poorly.
 
Sorry to hear that
 
user559633
oh good, i'm glad to hear you're doing better
 
@RobertGrant but the names should be a little readable, right? After all, Zen of Python says, Readability Counts...
 
Tristan got the joke...Well done sir.
 
@thefourtheye I recommend a mapping of variable names to meanings
In your head
 
user559633
1:45 PM
@Ffisegydd cheers :)
 
user559633
Would anyone be interested in a language in which every variable is a reference to a tweet on the twitter messaging website?
 
@tristan Same.
 
@RobertGrant Unfortunately, other people like to work in the same file :(
 
Not for long.
But maybe you're right. It was a silly idea of mine.
A silly, plagiarised idea.
 
Is there an equivalent post to Your answer is in another castle for questions? I need to respond to this comment.
 
1:47 PM
cbg
 
@poke Sure you can do that. — laike9m 5 mins ago
^ When suggestions to improve the answer are ignored…
 
user559633
I sort of don't understand what the answer is accomplishing.
 
@PM2Ring That question is way too broad anyway.
I'd not waste too much time on it.
 
user559633
If I saw that in a codebase, I'd rip out that approach and schedule a code review.
 
1:49 PM
@tristan which one?
 
@MartijnPieters Whats your number of characters per line setting?
 
@thefourtheye 20.
 
user559633
1
A: Python creating single instance in whole module

laike9mdatalayer.py datalayerInstance = datalayer(); def get_datalayerinstance(): return datalayerInstance example.py import datalayer datalayerInstance = get_datalayerinstance();

 
@MartijnPieters It is, but I was hoping that it could be made less broad with an MCVE.
 
@tristan Well yeah, the function is super redundant. Other than that, it’s the best way to do singletons in Python.
 
user559633
1:52 PM
@poke fair on the singleton point.
 
@PM2Ring It could be, the OP can edit and we can reopen.
But the odds are against the OP there.
 
@MartijnPieters Sounds like a plan...
 
@thefourtheye 80, with flake8 configured to tolerate 120 where the code requires it.
 
Okay, melons :)
 
user559633
have a good day everyone
 
1:57 PM
bai tristris.
 
user559633
k bai ^_______^
 
I'm snowed in today! Pretty big storm here.
Thanks to cutting edge Accuweather (tm) technology, I knew to take my computer home last night
 
Mmmm... PEP-8 says, if the teams agree you can allow 100
> Some teams strongly prefer a longer line length. For code maintained exclusively or primarily by a team that can reach agreement on this issue, it is okay to increase the nominal line length from 80 to 100 characters (effectively increasing the maximum length to 99 characters), provided that comments and docstrings are still wrapped at 72 characters.
Suddenly the code appears a lot neater to me...
 
That makes me feel better about my own long lines
 
How to check if an object A has an attribute a ?
 
2:00 PM
hasattr(obj, methodname)
 
That's so unintuitive
 
It's not something you need to do very often, so I guess they didn't spend a lot of time worrying about usability
 
Python code longer than 80 characters is destroying America! If elected President, I vow to you to hang any people who break this most sacred of laws.
 
thank you, it works
 
@Kevin I'm joking :)
 
2:02 PM
@MartijnPieters Only one more vote needed to close that; the OP still hasn't responded.
 
D'oh, you got me :-)
 
Bah, I was wondering if that was also a joke and decided to play it straight :)
 
@PM2Ring it's gone
Really, the Please tell me step by step how to do it. part tells me this isn't going to be improved any time soon.
 
It was more or less a canned response that I say as a reflex in response to "[semi-obscure feature] isn't very usable" whether the observation has any merit or not :-D
"The Python devs in their infinite wisdom decided to make [thing] ugly and hard, because they know you shouldn't be using it, you naughty person"
 
@Kabyle The EAFP approach is to just wrap the attribute access in a try:... except AttributeError: block.
@MartijnPieters Fair call.
 
2:06 PM
@Kevin that I totally get
 
@thefourtheye: I was the one that downvoted your list remove answer, by the way.
 
@Kevin Has KS a minimum line length requirement? Would be fun.
 
The del s[s.index(elem)] approach was just overkill when s.remove(elem) does the exact same thing.
 
@MartijnPieters he he he, I kinda know that :D And guess who did the first upvote on your answer? :D
Yup. I never used that before. So, couldn't think of that.
 
2:11 PM
@thefourtheye there is another answer on that post now using list.pop() and list.delete(). I don't think they quite got what is being asked or tested what they posted.
And duped the question.
 
Ah... Should have searched for a dupe when I was formatting the question...
 
@poke newlines have no meaning outside of string literals, so from the point of view of the interpreter, every KS program is exactly one line long. And since the empty string isn't a valid KS program, there's an effective minimum line length of 1.
 
I don't know why, these days I spend more time on formatting the questions
 
@Kevin 1 is boring.
 
2:14 PM
@Kevin I hope KS refuses to execute a file that does not end with a newline :D
 
The Nth line must have a minimum width of fibonacci(N). How about that.
 
+1
 
KevinScriptIDE Professional Edition will automatically pad things for you with no-op expressions. Only $199.99.
 
a program that is over 1 kc wouldn't fit on my window horizontally
 
If anyone has $250 to spare, I'd like the 13in briefcase kickstarter.com/projects/92038024/…
 
2:18 PM
(technical errata: newlines do have meaning - they separate literal tokens from one another, just like any other whitespace. print 1 and pr\nint 1 do not compile to the same program)
(but whitespace gets removed after the parsing step anyway, so my previous assertion about the interpreter still stands)
 
python has such great string formatting tools, makes everything in other languages seem so bad :|
 
Yep
 
2:42 PM
except Perl :D
 
Even C’s printf is better than the nothing some languages offer.
 
My friend, who is a die-hard Python fan, has gotten a job at BigCorp UK programming perl. Says he absolutely loves it.
 
Sure, Perl has incredible string processing. Pity it looks like line noise.
 
You can write non-line-noise perl. It's just not the default.
 
2:48 PM
I used to enjoy doing string processing in REXX, with its parse instruction. But it's been a while since I've used REXX, I probably couldn't even read most of my old REXX source code these days.
 
I like perl's do_thing_that_can_fail() or die idiom.
 
@Kevin Go do PHP
 
Not until they fix all their problems. All of them.
 
Good comeback
 
@Kevin fix_all_problems() or die;
 
2:54 PM
the good thing is that all objects are blessed
 
And post-modern
 
And Web scale
 

« first day (1601 days earlier)      last day (3341 days later) »