« first day (1566 days earlier)      last day (3373 days later) » 

12:02 AM
@Death_Dealer os.path.getsize('path/to/file') should return the size (in bytes) of the file
@Death_Dealer "\n" is a newline character.
 
hmm it must be working then, it doesnt error. when i change the path it does.
but it doesnt print anything.
os.path.getsize('TexturePack.pack-\info.pack-\Info.pack')
 
12:15 AM
oh sorry guys disregard my questions.
s = os.path.getsize() was what i needed to do.
 
12:47 AM
@Death_Dealer careful: windows filenames use backslashes, which Python uses as escape characters. That's what that r' ' notation was for. os.path.getsize('TexturePack.pack-\info.pack\info.pack') might do weird things if \i is a valid escape code for anything (and I don't know if it is)
 
its working thanks :)
 
raw strings treat all backslashes as literals, so C:\newfile.txt is r"C:\newfile.txt" or "C:\\newfile.txt" but never "C:\newfile.txt" since the \n makes a newline, not a literal backslash n
 
oh that was backwards i turned them around already.
thanks for telling me that tho. when they were the other way it would just throw an error
 
I haven't seen a case in Python where C:\path\to\file wasn't equivalent to C:/path/to/file
 
me either ... always use linux style file seperators is what I have found ...
 
1:01 AM
yep i get "FileNotFoundError: [WinError 2]"
and i turn them around and it works
FileNotFoundError: [WinError 2] The system cannot find the file specified:
it looks like it combines all the directory's into one string actually. and it cant find it
 
hello, i am trying pyscopg2 query string and using %s to indicate the table column to reference, however i keep getting an error as it appears that the query executes with the column adding quotes. for example: execute("""UPDATE table1 set %s = %s""", (c_name, c_value))
but the logs seem to show this happening: UPDATE table1 set 'c_name' = 'c_value'
i think its the quotes that are failing the query string
as in it should be UPDATE table1 set c_name = 'c_value'
any thoughts?
i figured it out, you need to use: from psycopg2.extensions import AsIs
and then do execute("""UPDATE table1 set %s = %s""", (AsIs(c_name), c_value))
 
1:16 AM
@greenhouse you can only use placeholders for values - not table/column names...
but - you've solved it anyway :p
 
1:31 AM
thanks @JonClements !
 
2:16 AM
@Death_Dealer backslashes give the FileNotFoundError? I guarantee the backslashes are working as escape characters then! Use a raw string r"C:\some\arbitrary\path\to\file.txt"
(re-cbg)
 
ok ill try that
 
2:37 AM
One of these days I ought to actually choose a picture
@MartijnPieters how was your CodeMentor call yesterday?
 
3:25 AM
Just had a conversation with the head of the other half of our I.T. department (my half does all the software and user contact, his handles hardware and networking) where I told him a plan I had for our next project
his response?
"Don't worry. I have plans for you -- be patient."
ominous
 
user559633
3:48 AM
I'm torn between reading something I find interesting and finishing off some webdev.
 
@tristan are you getting paid for the webdev?
 
user559633
my own startup
 
user559633
so no, not yet
 
Reading it is :)
 
user559633
hah, but i'm already ~180 hours deep into the project, so it's kind of time to just launch
 
3:57 AM
so put in ~20 more hours, call it ~200 hours, and release :D
 
user559633
i like your style
 
"Hey developer, there's a bunch of bugs here." "Yeah, those were slated for dev hours 201, 202, and 203, which unfortunately didn't make it in before launch. We'll release DLC bugfixes for $9.99 each."
(you wanted to compete with EA, right?)
 
user559633
that's positively horrid. i like it
 
user559633
yeah, sorry, the "responsibly hash your password" pack is DLC
 
user559633
please insert your credit card number to get website bux
 
user559633
4:02 AM
 
If you're particularly nasty, you should contract out 10 hours a piece to 5 other developers to develop bugfixes for your broken code and release bugfixes as zero-day DLC
 
user559633
oof.
 
user559633
social features that only work if you both pay for the feature
 
and link your Facebook
 
user559633
"chat is not available with premium users (UPGRADE TODAY)"
 
5:15 AM
I love creating over-engineered solutions to beginner homework questions when they don't even attempt the question before dumping it on SO. Did I go overboard?
 
user559633
not bad. i also like doing that. +1 for the QtyError subclass of a subclass of a plain exception
 
I considered writing the whole thing as a single sum([listcomp]) but decided that was too much work
 
user559633
my favorite troll "down your own damn homework" included a queue that printed strings char by char
 
5:31 AM
I did this earlier and that's about all the code murdering I can stand to be guilty of in one day.
Oooh I totally should have gone threaded! One thread to yield food items to a consumer who would query the inventory and either return None to the main thread or pass a message to another thread who'd query the producer and pass the price back to the main thread
throw it in three separate modules, with unit tests attached
 
user559633
should i call someone?
 
6:01 AM
cbg
@AdamSmith not very pythonic :D
@AdamSmith why did you fix the indentation errors :(
 
@AnttiHaapala it's not a bad question. Closely related to the canonical stackoverflow.com/questions/23294658/… but not quite, and I was able to guess reasonably well at his indention intention.
 
6:16 AM
yeah but who knows if the 2nd return was indented there or the func body level
that is the point,
unless they learn to copy the code verbatim, etc then there is no point in answering them, just tell them to copy the code how they had written it and close the question as "must have a working example"
 
@AnttiHaapala Doesn't really matter, since the first return will return regardless. If I guessed wrong, OP can correct it but it won't change the problem
 
yeah, but you didnt fix the problem of op asking bad questions
IF you close the question there are 2 alternatives: OP will get angry and never ask questions on stackoverflow anymore, or OP will fix the question/ask better questions the next time. Both are good results.
if you fix the question, if OP is of the first kind, then it will lead to OP ask crappy questions over and over again
 
Wasn't really a bad question. Clear problem statement with existing (if broken-by-paste) code. Should have had expected output and correctly indented code, but neither of which kept the question from a clear answer.
I'm not yet so jaded as to prefer to drive a new user off rather than suffer their bad questions :)
 
IF it is a valid question then close it as a duplicate
see now this shitty question has gotten answer upvotes at the same level as any interesting question with good algorithmic considerations
 
I couldn't quickly place a good duplicate for it, there's no canonical that I know of that speaks to infinitely concatenating user input strings
If you can find one I'd be happy to cv
 
6:23 AM
it does not need to be infinitely concatenating user input
but explaining return
 
6:44 AM
Best nonsense answer I've seen in a long time stackoverflow.com/review/low-quality-posts/6882038
>there are just not enough blues songs written about bin lookup. It is estimated that that bin lookup is thought about eight times every day by those most reliant on technology, which I can say no more about due to legal restrictions.
 
cabbage
 
7:22 AM
Cbg fellows
 
howdy howdy howdy.
 
recommended del ^
 
Same
 
7:39 AM
Cbg
 
@Ffisegydd cbg
 
night all
 
subtle, but there's a phone number in the usercard..
and cbg :-P
 
daily wisdom:
 
@AdamSmith: and I enjoyed my CM session, thanks for asking :-)
Someone who wants to learn about how Python itself works.
 
8:35 AM
cbg
 
cbg Jon
 
Cbg pup
 
cbg cbg
 
Cbg ya'll
 
errr... yo' word up? :)
 
8:53 AM
Nice
 
yeah... this bro is down with da lingo! :p
 
resists starring all the things, as instructed
 
You have no idea how tempted I was to pin a message saying "Disregard previous message. Star all of the things!"
Nice teamwork there @Jon :P
 
Yeah... tag teaming Tim.... :)
wow... inadvertent alliteration there
 
Spring Roo seems to have stalled completely, after a promising start (long ago)
 
9:09 AM
I'd vote for adding a function to compute an average rep among posters to Nidaba. Will probably help to determine question quality
 
Upgrading Google Chrome got rid of my cv-pls extension. My anger knows no bounds.
How will I cv-pls so many linkedin questions now!
 
@vaultah I think we've got something similar in the list of things to look at on the github page
 
@Ffisegydd need an extension that automatically goes to a cv-pls -tagged link, hits the close link and votes for the most-picked option :)
 
We need some form of machine learning program which can process questions automatically and sugg...............
 
@Ffisegydd that's a fantastic idea... why didn't you think of that sooner! sighs
 
9:19 AM
:D
 
I know! Let's get it done! Jon would you mind start paying for a serv............
 
Okay... then if we get a github repo setup, have some discussion about design... maybe get a nice .io domain...
@Ffisegydd you always seem to be running htop on the server :)
 
I have a screen dedicated to htop. Also I use tmux so I really do have an open screen probably, I'm just not connected to it :P
I like being able to logon, type tmux attach and BAM I have 6 tabs set up roughly how I need them.
 
wb @greenhouse
 
Screen is amazing
What's tmux, a way of having lots of screens at once?
 
9:27 AM
@Robert yeah so you can have as many as you want open, and you just flip between them, like browser tabs.
But the cool thing is they keep on running even if you're disconnected from the server.
So my htop screen has been running for about 3 months :P
 
Yeah as in the utility screen?
 
No idea never used screen
But presumably yes.
 
googles
 
Well, server's only been up 51 days and 14 hours :)
 
Woteva.
 
9:30 AM
Oh okay, so I was expecting it to be a layer on top of screen allowing easy access to multiple screens etc, but it's actually its own implementation of that same concept
 
Am I bovvered!? :)
 
Anyway. Yeah, I love screen. Used to have IRSSI running in it so I'd always have huge conversation histories to come back to
Such a clever idea
 
@Robert I use to love BitchX in the days :)
 
I think I'm too..something? for BitchX. Too uncool?
Some mates just ran (well, run) a server and chatted on there all the time. wonky.org.uk
Not that that URL really does anything on a browser
 
I use to love IRC - was an IRC admin, chanserv and nickserv admin and +O for years...
 
9:34 AM
I used to use IRC a lot. Good times.
 
Awww.... we should install an IRC server on sopython for nostalgia purposes :)
 
I used to be on Freenode IRC all the time.
Now I don't even open my IRC client for months at a time..
 
I was +O on ircnet/efnet, then admin'd stuff on undernet and dalnet, then a group of us created a new network called othernet
Anyway - othernet became something I didn't agree with and left, but it's still going othernet.org - amazing
co-wrote the chanserv bot with a guy called Chris Birch for that network
 
@JonClements yeah, IRC+Screen was basically this sort of chat but 15 years ago :)
 
Think I started using IRC early 90s...
 
9:39 AM
I never used IRC :/
 
@vaultah then we're all going to have to turn our backs to you in shame :p
 
:d
 
I started using IRC around 2003 I think.
 
/mode #python +b vaultah!*@* :p
@Martijn I have no idea what that guy is going on about with that hex question - does he think 0x6f is different from 111 or something?
 
9:45 AM
cbg @Intrepid
@martijn you gonna put your name down for sopython.com/wiki/sopython_T-shirts ?
 
(we should probably star the link)
 
Register your interest for a sopython/zalgo-like T-shirt at sopython.com/wiki/sopython_T-shirts
14
 
Argh I would like one but I probably don't want to have it shipped to South Africa
 
@Robert fair enough. I think the plan was to put the designs on sopython anyway so you could get one printed locally.
 
Maybe I should just do it and have it shipped to the 'rents
 
9:51 AM
Aye - I figured that would be a problem for our international audience
 
Now I'm not sure which to get
 
If nothing else, you can treat us Brits like guinea pigs to see if the designs come out well :)
And why is it an either/or choice Robert? :P
 
Yeah also a good point :)
Okay, I'll put it on both. Sold! Assuming I like the designs.
Okay now I'm in, I want a way to distinguish early adopters from dopes that get one once they're famous
Maybe some sort of 3D-printed gift
OR a 3D-printed alien coming out of the front of the t-shirt
 
Know what'd be nice? A polo shirt with the sopython logo on one breast (quite small, discreet, not overly flashy) and a name on the other possibly.
Or maybe just the sopython logo on one breast, kinda like the way PA do their polo shirts
Unfortunately I'd assume that would be much more expensive and so would probably need more numbers.
 
Oooo - that'd be quite cool
also what'd be cool is sopython cufflinks
 
10:01 AM
I mean I never actually wear t-shirts (outside of the house).
 
(or am I the only person in the world that bothers with cufflinks?)
 
So I want an sopython t-shirt, but I'd only wear it around the house, but a nice polo-shirt I'd wear out.
 
In SA I might find use for a t-shirt :)
 
I use cufflinks when wearing a suit.
 
@Ffisegydd errr... it's an attendance requirement to wear a sopython t-shirt for sopycon!
 
10:02 AM
Yeah cufflinks with a double-cuff shirt
 
Then we'll have to have it in my house :P
I'm pretty sure I've not left the house in a t-shirt in 3+ years.
 
That's fine
 
well... I rarely leave the house :)
 
As long as nidaba hasn't become self-aware by then and causes an electrical fire in a bid to kill its makers (and me)
 
10:06 AM
Can't find anywhere on teh internetz, so here goes. Can I have a named list of lists? For example, something along the lines of [hr = [], si = []]?
 
@Roman use a dictionary.
x = {'hr':[], 'si':[]}
print(x['hr']) # []
 
I'll try that, thanks.
If I use a dictionary, can I still reference it by position instead of name?
 
@Roman probably have a skim through docs.python.org/3.4/tutorial/datastructures.html#dictionaries as there's a few things that can catch people out. For example they're unordered so if you iterate over them they may come out in a different order.
 
It would appear x[0] doesn't go through.
 
@Roman no you can't do that. If you want index and name then you probably want a namedtuple
 
10:11 AM
I guess I could do x[list(x)[0]]. :P
 
No that wouldn't work because they're unordered.
So list(x) won't necessarily come back in the same order.
 
Well, it well if no mutation has occurred :)
 
In [14]: from collections import namedtuple

In [15]: Coord = namedtuple('Coord', ['x', 'y', 'z'])

In [16]: c = Coord(1, 2, 3)

In [17]: print(c)
Coord(x=1, y=2, z=3)

In [18]: c[1]
Out[18]: 2

In [19]: c.z
Out[19]: 3
 
Gah. :)
 
cabbage fellow pythonistas
 
10:13 AM
cbg @Nebril
 
Unfortunately namedtuple doesn't support c['z'] D:
I wonder if there's a specific reason for that?
 
does any of you use tox for your tests? I seem to have a problem with passing parameters to them
 
@Ffisegydd well, you could kinda make it... but heck... how many ways does one want to access a field? :)
 
@Nebril I do
But my experience of it isn't exactly in-depth. I set it up over lunch one day and didn't really look at it again.
 
:(
 
10:15 AM
@Jon c.__getattribute__('x')? :P
It would be useful to be able to programmatically get the field though, using c.z is kinda hard-coded.
 
I guess I will need to check it's code out then. I have a problem with sending parameters with spaces in them to tox
 
@Nebril ask your question, if someone can help then they will
 
ok
 
cbg
@Ffisegydd Or just getattr(c,'z')
 
(sorry, was proof reading before our meeting)
 
10:17 AM
@PM good point, I always forget that getattr is in the builtins.
 
@RobertGrant Haha. I don't see why not to be honest :)
 
IIRC, namedtuple is just syntactic sugar for a class.
 
@Ffisegydd Well, can't be hurt to look. We could pass on our thoughts to the great designer one to see what he thinks
@JonClements Could 3D print prototypes for Robert ;)
 
@Intrepid yeah see what can be done. If the cost wasn't too extortionate I'd buy multiple polo shirts.
 
What about a list of dict keys, then you can iterate over the list to get the dict values in order :)
 
10:20 AM
@JonClements (on mobile) I have a great Zalgo shirt :-P what'll be the SOPython design?
 
@Robert shame there isn't something in collections called OrderedDict or something :(
 
As much as I love the zalgo regex post (I've linked it several times over the last few days, both on Stack Exchange & xkcd), shouldn't sopython have something more intrinsically Python for its T-shirt?
 
The hex question should be closed as unclear. Apparently my comments have solved the problem.
 
@Martijn it'll be whatever our resident design genius comes up with :p
 
I used to have a train spotting Python shirt that I loved.
You know the 'choose life' intro; but adjusted to choose Python instead.
 
10:22 AM
Arghghg... read this user's profile - yet another maths thing! :p
 
@PM2Ring Python 2-only libraries cause Guido to sweat blackened pitch. HE COMES.
 
@PM2Ring sopython will have have something made. I was just originally asking around to see if people fancied joining in on my zalgo t-shirt order.
 
@JonClements Yeah, but IIRC you still can't index OrderedDict directly, you have to index it via its keys. (I can't test it myself since I'm still on Python 2.6.6, & you need at least Python 2.7 for OrderedDict)
 
@JonClements what do you mean maths thing?
 
10:24 AM
Your future is, like, so python?
 
Oh lots of assignments of "pick two numbers and add, minus, multiply, and prompt the user to enter the correct result 10 times and give them their score out of 10" thing
 
Awesome xD
 
@IntrepidBrit Ah, rightio.
 
ummm.... interesting shuffle results... some metallica, then some christina perri, then some john denver, followed by prodigy and then some alpha blondy...
 
We get heaps of questions relating to this assignment on a very regular basis.
 
10:28 AM
The text is still pretty much relevant except for psyco should be replaced with ctypes. :-)
 
ah, ok I get it, thanks for clarifications @PM2Ring
 
I have occasionally answered questions relating to that math quiz assignment, or at least offered helpful hints in comments. But mostly I suggest that they do a search for existing questions. After all, if they aren't smart enough to use the search engine of their choice to find any of the zillion answers already available they probably do not have the required brain power to be a programmer. :)
 
Hi everyone
 
Ahoy antox!
 
10:40 AM
I'll like to ask you some doubts about the PEP 263, I posted a questions but I'm still pretty confused
i would like*
I would like to understand how python previous to 2.3 version worked with strings and unicodes
I installed python 2.1.3 on my machine
my first doubt comes from this paragraph: " In Python 2.1, Unicode literals can only be written using the
Latin-1 based encoding "unicode-escape". This makes the
programming environment rather unfriendly to Python users who live
and work in non-Latin-1 locales such as many of the Asian
countries. Programmers can write their 8-bit strings using the
favorite encoding, but are bound to the "unicode-escape" encoding
for Unicode literals.
"
 
too broad. Rather than flag for migration, I advised that the OP could do better asking it on Code Review.
 
what I don't understand is: how did asians write python source codes?
 
In English. Using Latin characters.
 
@antox You cannot use anything but Latin-1 codepoints, really. Anything else required the use of \uhhhh escape sequences.
 
for example let's take this character: '象' (U+8C61)
 
10:44 AM
So you could not use Chinese Unicode codepoints or Japanese or Arabic to produce u'...' unicode literals.
Right, you'd use u'\u8c61'.
 
ok
this because python always used to read source codes using asii encoding?
 
You could not use u'象' because Python had no way of knowing what codec was used to save the file.
A source file is nothing but a sequence of bytes.
To treat it as text you need to agree on the encoding.
ASCII has long been the defacto text encoding, but it is limited to 127 characters.
You cannot express in the ASCII standard, so you need a different way of encoding it.
 
yeah, yes, and what encoding did python used for text file? just and always ascii?
 
Older python versions would read the source code as Latin-1 effectively, they'd preserve bytes in the range 128 - 256.
So if you did somevalue = 'äāå' it would produce Latin-1 bytes.
 
ok
i tried the following code on python 2.1.3:
>>> s = u'\u8c61'
>>> print s

Traceback (most recent call last):
File "<stdin>", line 1, in ?
UnicodeError: ASCII encoding error: ordinal not in range(128)
 
10:49 AM
Blimey, hope there's a good reason for that specific version :)
 
so how did they handle unicode character? even though I used '\uXXXX' form I could'nt print tha
that*
 
@antox print s is trying to encode that to ASCII, and obviously it won't succeed. What does your python 2.1.3 print for print s.encode('utf-8') presuming you're running it in a terminal that handles utf-8.
 
@PM2Ring in that way it prints in the correct way. But should print encode s in the encoding of the stdout?
 
The print statement isn't that smart, it just encodes to ASCII.
 
11:00 AM
Was debugging some old Python code the other day and came across that problem
 
I mean taking s = u'\u8c61' should it notice that there is a \uXXXX character and take all that an translate it in utf8?
shouldn't it notice...*
 
Why should it assume you want to encode to utf-8? There are several unicode encoding possibilities.
 
because stdout uses utf8, I mean it should translate \uXXXX in the encoding indicated by stdout
 
Ahh.... just found out why a system I'm maintaining keeps losing data
 
@antox it's a 7-years-old version of python, and perhaps things weren't as clear-cut then as they seem to be now
 
11:03 AM
DELETE FROM table and there's a note in the code - "must add where clause later"...
sighs
 
@JonClements Squirrels?
 
@JonClements that's well commented code, that is.
 
well... anyway - at least I know why stuff is vanishing that shouldn't be deleted :)
 
@Ffisegydd : I resolved my tox problem, upgrading it to 1.8.1 solved my problem.
I have no idea why though, and I don't have time to investigate :(
 
@RobertGrant so previous to python 2.3 were asian programmers constrained to code print someunicode.encode('utf8') every time?
 
11:08 AM
Dunno
 
@antox: Let's just say that some unfortunate choices were made in how Unicode handling was added to Python 2; it was later realized that a new approach was needed for Python 3.
 
But I think as people want to accommodate characters that weren't familiar to the language's original creators, they didn't want to make the same mistake again and assume utf8 for all time they way they did with ascii
 
IIRC, unicode support was added to Python long before non-ASCII chars were permitted in Python sources via the # -*- coding: header, so the pattern of Unicode use was already established by the time Unicode literals could be used directly in Python sources.
 
Or you know, ignore my link that works too ;)
 
ok now i have things a little bit more clear, thank you everyone
 
11:20 AM
TL;DR: use a newer version of Python if you can :)
 
@RobertGrant yeah yeah :) I'm learning Python 3.4 but I wanted to know how old versions worked too :P
 
That's a good example of an encoding problem: you tell me something, and I literally have no idea how to interpret it :D
 
@antox you'll do more harm than good trying to understand 2.1 etc IMO :P It's fine once you've got a really, really firm understanding of 3.4/2.7 of course.
 
@Ffisegydd maybe you're right, because it could confuse ideas, but you know, when I have a doubt in my mind about something it's pretty difficult to let it go
 
2.1 seems an odd one to pick; I could understand 3.latest and 2.7
 
11:29 AM
@RobertGrant I took it because in the PEP 263 talked about it and to fully understand the pep I would understand how 2.1 worked
 
Yeah I think it would be more informative to learn 3.4 and also learn how 2.7 differs.
 
and so I'm trying to do
 
I recently solved the switches puzzle; it is known as the locks puzzle on Code Eval.
There is a O(1) approach the OP has missed..
 
Yeah
print(10)
Sorry, I do know what you're talking about :) I just can't work it out fast enough
 
cbg all!
 
11:41 AM
cbg @Uni!
 
Tks!
 
@RobertGrant There is a mathematical solution, rather than brute-force calculating it; for each switch in the series there is either an even or an odd number of times it has been switched.
 
Yeah, but he wants the total number of unswitched ones
 
If it has been switched an even number of times it'll end up in the same state as it started, so you only need to care about the switches that are toggled an odd number of times.
ah, right, unswitched.
so it is a math puzzle to figure out the formula that'll tell you how many switches are toggled an odd number of times.
Ah, the OP has specifically stated that they know this and that that is not the point. Roight.
 
11:57 AM
 

« first day (1566 days earlier)      last day (3373 days later) »