« first day (1068 days earlier)      last day (3880 days later) » 
01:00 - 15:0015:00 - 23:00

1:16 AM
Hello, is anyone here ?
 
 
2 hours later…
3:21 AM
cabbage
 
4:07 AM
cabbage
 
4:17 AM
cabbage
 
Cabbage folks
 
cabbages
 
5:11 AM
huh, today is my 250th day at being at SO
and my 250th consecutive ;)
 
5:31 AM
wow
I'm trying to get the fanatic badge on codegolf.se
 
how many days?
 
90
10 to go
 
goodluck. Don't ruin it
;)
 
6:12 AM
Hey, just asking a stupid question, must a function be the last argument to a decorator?
 
Never used a decorator before, sorry
 
6:39 AM
@Haidro there's another thing on your to-learn things in Python ;)
 
Well, I know about decorators
1064
Q: How can I make a chain of function decorators in Python?

ImranHow can I make two decorators in Python that would do the following. @makebold @makeitalic def say(): return "Hello" which should return <b><i>Hello</i></b> I'm not trying to make HTML this way in a real application, just trying to understand how decorators and decorator chaining works.

 
 
1 hour later…
7:55 AM
hi
cbg
 
morning
 
8:34 AM
Declaring an array this way: all_list = []
 
Python doesn't use arrays
 
How do I check if the array has a specific index?
I tried so far:
if all_list[i] != None:

and

if all_list.index(i):
 
again
no such thing as an array in Python
Its a list. You need to treat it as a list not an array.
 
So..?
 
len(all_list) > i
 
8:36 AM
If you can't comprehend what I just wrote - you should go back to the tutorial.
 
It's not what I'm looking for @Paco
I want to verify if a certain position of the list contains values.
 
lists don't work like arrays in python
 
It's not possible then?
 
Every position in a list will contain a value
 
@user2742861, you can do something like : if len(all_list) < i and all_list[i] == my_object: pass
The first bit checks that you're not going to far
 
8:37 AM
I think I got what you're trying to say to me @paco
 
but the easiest way
is to do a for loop
 
but one thing
 
for my_object in all_list: print my_object
 
if I want to insert in that position a value, how do I do it?
 
which is much better than a while loop
 
8:38 AM
all_list[position] = value?
 
usually we use all_list.append(value)
that adds value to the end
 
but append, for what I searched, it's for add to the end
Y
I'm currently using the insert
which, for what I get, it inserts in a specific position
 
otherwise, you can use all_list.inset(position, index)
 
Ok, I'll give a try, 1 minute please.
 
insert*
 
8:43 AM
Maybe I should create a question in stack. I think your solution is right but I'm failing in another aspects.
 
what's failing ?
 
Can someone help me?
 
@wanmohdpayed what's your isue ?
issue*
 
Can someone explain to me what this sentence mean "you can't download the file with that URL. You will need to check JavaScript source files to see what javascript:checkDownload() does to get the actual file location."?
 
Btw, is it possible to have this:
index 0, value 2
index 3, value 4
?
Meaning that it hasn't values in index 1 and 2
nor was created that index
 
8:48 AM
no
but you can have None for index 1 and 2
as a value
 
It creates automatically?
If I insert(5, 'paco')

The index 0,1,2,3,4 will get automatically the value 'None'?
 
give it a try
 
anyone have an idea?
 
@wanmohdpayed can you give us more context
?
 
@user2742861 no
@wanmohdpayed This is the Python room - go to the javascript room.
@user2742861 stop trying to treat lists like arrays - learn what a list is from the ground up. and forget what arrays are when using Python - whatever you are trying to do - has a way of being done in python that uses lists, you need to switch your mind to working with python code. Which can do everything you want - you just need to learn how.
 
8:53 AM
@Paco this is the link "http://www.downloadcrew.com/article/27337-makemkv".. the download button contain javascript..How can I take the download link?
@InbarRose I am working on python 2.7 and beautifulsoup.
 
@paco, @InbarRose - for a better conclusion of what I'm trying to achieve: pastebin.com/8v5h8i5y
 
hi Good Morning friends....
 
@user2742861 line 2 is wrong
I guess what you want to do is : all_list[i]
 
variable_time = str(all_list.index(i)) ?
 
not all_list.index(i)
unless you store values of i in all_list
 
8:59 AM
This "i" is a loop from 1 to 31 (days)
If there is value in one of those days, it should insert into the list.
 
9:14 AM
You need a dictionary. Or a class for what you are doing. not a list.
In python these are not dirty words - they do not have so much overhead as in other langauges.
 
I'm actually trying to use your advices by using a list
And I've changed my code for something like this:
 
make sure you do not fall into the XY Probelm
 
all_list = list()
for index in range(len(all_list)):
# now here's the problem
if index == i: # is this wrong?
 
in Python, you don't loop over indexes. you loop over items
for item in list:
or you loop over enumerated lists.
 
Actually you can loop over indexes
 
9:17 AM
for idx, item in enumerate(list):
 
" If you need only the index, use range and len:

for index in range(len(L)):
print index"
 
@user2742861 Please, I think between us I have a bit more understanding than you do about this. And trust me - python is not a language where you loop over indexes, here, you loop over items.
Of course - there are cases were you need to loop indexes, but that just means you are doing it wrong.
 
Hmm
Maybe what I should do is comparing like this:
if all_list(index, item) != 'None':

Or something
 
I don't yet know what you are trying to do
 
I have a loop from 1 to 31 days
 
9:19 AM
Please read about the XY problem
 
Inside that loop I need to verify if I have values in my list in the position of the "i"
for i in range (1, 32)
for index, item in enumerate(all_list):
I think so far this is right
 
stop
you have not payed attention
Instead of telling me what you are trying to do to solve your problem (ie: how to implement the solution you have decided must be used) tell me what your goal is. and I will tell you how you should do it.
 
@user2742861 a list has length of len(lst) and has values for all indexes from 0 to length - 1, although the values can be 0. Subscripting the array beyond length - 1 will yield IndexError
mgmmg
ahhaha
next time I need to see if I scrolled down
 
Don't you mean up?
 
All I want is this:
1) I need to have an empty list to insert timedelta values.
2) I would like to insert the values inside that list this way:
list[0, "04:00"]
list[1, "00:00"]
list[2, "00:00"]
list[3, "05:30"]
3) - the index of the list, is actual the day of the month. So, whenever it's not information in that day, it will insert "00:00", if there's information in that day, it should insert the timedelta. If there's already in the index of the list a item, it should sum the actual item to the new item.
If you see in the pastebin I paste here in the conversation, I'm trying to apply that logic.
 
9:43 AM
Okay.
You need a dictionary.
 
Yes. Looking at the manual, I think it's worth giving a try.
 
its exactly what you need
d = {}
d[0] = "04:00"
 
d = {} is equal to d = dict() ?
I actually put d = {}
but I found now that people use too d = dict()
 
They're the same
 
not exactly
{} can also create a set
 
9:49 AM
People might use dict() instead to avoid confusion with sets
@InbarRose empty sets have to be created with set() afaik
 
>>> s = {'a', 'b', 'c'}
>>> s
set(['a', 'c', 'b'])
>>> d = {'a':'b', 'c':'d'}
>>> d
{'a': 'b', 'c': 'd'}
@Volatility yes - but just clarifying .
 
According to the info in google
I can do something like this:
if i in all_list:
to verify if the list has the key "i"
 
yes, but please don't call a dictionary all_list
Makes it extremely confusing
 
it should be: days = dict()
days[0] = "04:00"
what logic do you use to sum different timedelta's ?
at the moment I see they are simply strings.
you might want to make them into small classes, that have an addition operator
 
Ok.
Actually, my problem I think is now only in the sum.
I'm getting this error:
unsupported type for timedelta minutes component: str
And I'm quite sure it is in this lines:
variable_time = str(days[i])
hours_time = variable_time .split(':')[0]
minutes_time = variable_time .split(':')[1]

time_horizontal = timedelta(hours=hours_time, minutes=minutes_time)
days[i] = (time_horizontal + timedelta(hours=int(hours_), minutes=int(minutes_)))
I also tried:

days[i] = str(time_horizontal + timedelta(hours=int(hours_), minutes=int(minutes_)))
 
10:08 AM
first of all
hours, minutes = map(int, days[i].split(':'))
second of all - why are you turning them into strings in the first place?
Why not keep them timedelta objects?
 
With only this:
if i in days:
variavel_time = map(int, days[i].split(':'))
else:
days[i] = timedelta(hours=int(hours_), minutes=int(minutes_))
I get the following error:
AttributeError: 'datetime.timedelta' object has no attribute 'split'
If i do for example this:
if i in days:
variavel_time = "03:05" # just for testing
else:
days[i] = timedelta(hours=int(hours_), minutes=int(minutes_))
I get: Exception: Unexpected data type <type 'datetime.timedelta'>
 
Still waiting for the day Martijn will ask a question
 
when I said "first of all" and "second of all" those are OR. you cant do both of those option.
If you want to store the time as strings - then "first of all" is the way to do it.
But I think you should store them as timedelta objects. in which case you dont need to split them, just add to them
in fact, you should use a defaultdict with timedelta objects.
good luck.
 
10:41 AM
Thanks @InbarRose. I think I'll get with the dictionary. At least i'm getting results.
 
11:23 AM
cbg4all
 
Cabbage.
Slow day today.
 
indeed;)
or :(
 
12:13 PM
cabbage y'all
 
What is it with cabbage here ?
 
It's a typing quirk used by regulars, to identify one another. Anyone that doesn't know what cabbage is, is an outsider.
In short, it exists so that people can ask about it quizzically. It's a rite of passage :-)
If you browse the starred list, you can find this handy reference guide.
 
There we gooo @Kevin, was looking for that
 
And the conversations list records the historical first use
Blame Jon.
 
12:30 PM
On that note - he's not actually online?!
 
Not yesterday either :-(
 
Think we should call someone, like emergency services?
 
I'm not sure what the etiquette is, for that.
 
Asparagus, Potato?
 
If the paramedics broke into my house every time I abruptly stopped posting in an online community, I would consider installing a revolving door.
 
12:35 PM
Why bother with the whole door bit?
 
Yeah, better not. How would they fit the stretcher through?
 
Aye.
Actually, tell you what, just leave the garage door open. then the paramedics wouldn't need to pay for parking
 
12:49 PM
took this to SO
0
Q: Merging a list with a list of lists

K DawGI have a list of lists: [['John', 'Sergeant '], ['Jack', 'Commander '], ['Jill', 'Captain ']] How can I merge it with a single list like: ['800','854','453'] So that the end result looks like: [['John', 'Sergeant', '800'], ['Jack', 'Commander', '854'], ['Jill', 'Captain', '453']]

 
Haha, ashwini and I posted the exact same answer, except for variable names
I'm the fastest gun today B-)
 
@Kevin Thanks :)
 
@Kevin man that was quick..
man no upvotes :(
anyway the answers are worth it :)
 
You got one
 
@kevin
 
12:54 PM
You've got 2/3rds of a good question, the input and expected output. But you're missing the last third, the infamous "what have you tried?"
 
@Kevin your answer works man, *damn can't accept it, please wait 10min *
 
I can't wait that long. Please hack the mainframe and insert an accept into the database by hand.
 
@Kevin If ya say so... :D
hacking 1%
2%
 
Actually, it's easier if I just correct the rep on my monitor with a magic marker.
 
It will be faster to wait actually :P
 
12:57 PM
3% and failed, system admins caught me pooh wooo wooo
 
I was playing around and got this:
>>> l1 = [['John', 'Sergeant '], ['Jack', 'Commander '], ['Jill', 'Captain ']]
>>> l2 = ['800','854','453']
>>> for i in range(0,len(l1)):
...     l1[i].append(l2[i])
...
>>> l1
[['John', 'Sergeant ', '800'], ['Jack', 'Commander ', '854'], ['Jill', 'Captain', '453']]
 
@Jerry that's lengthy though
 
was initially trying to put in in a fresh list, but then I remembered about lists being mutable
@KDawG I didn't post it as answer xD
just trying out what I could do with what I currently knew
 
anyway how's my naming scheme Involved jack and jill too
 
I prefer Alice and Bob for my fake name needs :-)
 
12:59 PM
also, I was almost going to vote to close your question for "Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results" xD
 
@Kevin They sound too perverted for me
@Jerry C'mon man
@Jerry If ya listen to the crazy solutions I came with you'll bang your head on the computer screen
 
You could edit the question to be like, "here's the way I'm doing it now, but it's like five lines long. Is there a shorter way?"
 
yea
I can assure you I won't bang my head
 
Nice answer badge acquired! On one hand, I'm like, do I really deserve this? On the other hand, I'm like, maybe I'll hit 7k rep today...
 
Initially I tried iter(zip(self.cities[0],self.postal_codes)) man that was a total fail :P
I just used jack and jill for educational purposes
 
1:04 PM
well, since I don't know any of those functions, I can only shrug right now, and maybe look those up in the docs
 
and then came a step closer with zip(a,b)
but didn't work too
and I was already in tears :(
 
aww
/me pats K DawG
 
Yeah, sometimes when you use your actual data, you get a lot of people clamoring about xy problems. Best to obfuscate things so they don't reverse-engineer your real goal.
 
@Kevin just hacked the system :D
So damn proud
 
More fuel for my rep-powered go cart.
 
1:07 PM
@Kevin edited da question so now 3/3 or a full question
don't I deserve some rep for a good Q
 
On SO, you might not get what you deserve, but you'll get what you need.
 
@Kevin !lol!
 
@Kevin SO Karma? :P
 
@Kevin yeah but ya just got 140 rep for a small answer :( jealous
 
@Kevin why are you using concatenation rather than simple append? [x.append(y) for x, y in zip(a, b)]
heya @JonClements !
howdy?
 
1:11 PM
I was using only append and for... sob
 
@PeterVaro good thanks
 
oh hi Jon o/
 
It's a very rare occurrence for me, @KDawG. I spend most of my time toiling in the question mines, with little to show for it
 
Because then you'll end up with a list of None as the result? @PeterVaro :)
 
oh, time to go home
bbiab
 
1:12 PM
@Jerry laters
 
@JonClements OMG... how silly I am -> append doesn't return anything
 
@Jerry Rhubarb!
 
Hey Jon, good thing you showed up. We were about to break into your house.
 
@Kevin yes, my "door getting broken down" sense was tingling...
 
Useful sense to have
 
1:16 PM
@IntrepidBrit not as cool as swinging from a web, but it has its use occasionally...
 
The last four Jon Clementses whose homes we invaded were very rude to us :-(
 
Really? If they were anything like me, they'd be really appreciative that someone was actually that eager to see them!
 
@JonClements Well, I swing from webs all the time. They collapse. It's overrated imho
 
Rude by British standards, I mean. They offered me tea, but not sugar!
 
And no crumpets. Who doesn't offer biscuits or crumpets? I ask you
 
1:18 PM
@IntrepidBrit more time spent in R&D and less time spent trying it out before beta testing could help there...
@IntrepidBrit yes, and not those 20p jumbo box of biscuits from Tesco. PROPER biscuits! With real chocolate and biscuity base...
 
Pah! Project management. Wasn't that just invented by a chap called Gantt to sell charts?
cues Buttery biscuit base flashbacks
 
Oh wait, I forget I'm a dog - eating chocolate is bad... Why are you trying to poison me!!!!?
 
It's real imitation chocolate.
 
Rhubarb! fella's!!! Movie break
 
As opposed to fake imitation chocolate?
 
1:20 PM
Rhubarb crumble, @KDawG
 
real fake genuine imitation chocolate
 
@Kevin ahhh, my favourite... put it in my bowl and pour tea over it - there's a good human...
(no cream mind you - I'm watching my wait!)
So, in my absence - have their been any normal conversations?
 
Deploying Low Orbit Tea Cannon. Approaching geosynchronous lock.
Place the bowl in a spot with a clear overhead view of the sky (preferably on your roof), and activate the positioning beacon
 
Ummm.... we're using the cannon and not the teleporter?
How am I supposed to climb to the roof... these paws are made for typing.... not for climbing!
 
Moot point, the launch window expired. Venting excess tea into the Indian ocean.
Hope the fish like their tea weak. Say, diluted to one part per trillion :-)
The problem with the teleporter is, the object retains its rotational velocity with respect to the Earth's axis, but the direction changes since we're on different longitudes. So it would materialize and smash through your ceiling.
 
1:32 PM
@Kevin but I'd get tea right? So where's the downside?
 
Yes and no. You'd get the constituent atoms, but in the form of a hot, fast moving, radioactive plasma cloud.
 
It would be smashing good tea?
 
Certainly, it would be tea that is good at smashing :-)
 
Hang on - doesn't tea diluted to one part per trillion have wonderful healing effects? Such as curing cancer and stuff?
 
Homeopathy. That's what they claim, yes.
 
1:35 PM
So, here's the bit I don't get about it
Surely water has all those healing properties already?
Since, y'know - someone probably dropped it into the sea at some point?
 
@IntrepidBrit nope - different bits of water know different things
 
Taking the long view, water is just super diluted dinosaur urine :-)
 
Does anybody know what a Sphinx-style docstring for a generator method would ideally look like? Is there a field that marks an object as being a generator?
 
@Kevin So, surely the solution to all of our ills is to get rid of this long-memoried vindictive water?
 
@jbaiter I'm not sure sphinx has a distinction...
 
1:37 PM
@Kevin Partake in water husbandry, only product stupid/forgetful water?
 
@IntrepidBrit and replace it with tea... YES!
 
The only water I drink is synthesized from hydrogen and oxygen gas.
 
Hahnemann believed that the underlying causes of disease were phenomena that he termed miasms, and that homeopathic remedies addressed these. The remedies are prepared by repeatedly diluting a chosen substance in alcohol or distilled water, followed by forceful striking on an elastic body.[7] Dilution usually continues well past the point where no molecules of the original substance remains.[8]
 
@Jon: Me neither, that's why I was asking :-) Currently I'm stating it informally in the docstring, while :returns: and :rtype: describe a single generated return value
I was just wondering if there was some kind of accepted best practice for documenting generators
 
@jbaiter just looking at the Python docs - I don't see that distinguish either... so, I think you're probably okay just mentioning it as you do
 
1:40 PM
dang, I totally forgot that the standard library uses sphinx too... thanks for checking for me! :-)
 
@JonClements - What kind of tea though. My vote would be for Earl Grey
 
Earl grey is fine for afternoon, but breakfast tea for mornings...
 
Maybe we could have Breakfast Ocean, Earl Grey Sea & the Roiboos Channel...
 
And replace the "red sea" with the "green tea"?
In fact, if we're going to terraform Mars - let's tea-a-form it instead... vast lakes of Earl Grey and Ceylon etc...
I'll put it on the todo list, just after "finish taking over earth"
created in 1796 by Samuel Hahnemann, based on his doctrine of like cures like, according to which a substance that causes the symptoms of a disease in healthy people will cure similar symptoms in sick people.
Umm... he's been shot - grab the gun!
Except - when you shoot him again, don't use any bullets!
@Kevin wow - that's up to 19 :)
 
I reckon he had the case of going out drunk, sleeping in the same bed as his partner - and his partner got the hangover?
 
1:53 PM
Hooray, 19 people like me
 
@Kevin wouldn't go that far :)
@IntrepidBrit umm.. so if he'd diluted his whiskey to 1 part per million... it wouldn't have happened... and thus...
 
He wouldn't have been subjected to domestic abuse - hence the theory
 
The only thing that resembles homeopathy, and also works, is vaccines. Give the immune system a small dead sample of the organism, and it can better defend itself against the live version.
Got polio? Have some more polio, that will help...
 
I suppose it's unlikely to make things any worse?
 
if I have a python file, let's name it A.py and I have another one, named B.py, and B imports A, and I have a third file, named C.py, and in that C file I use:
    _locals = {}
    _globals = {}

    with open('B.py') as f:
        exec(compile(f.read(), 'B.py', 'exec'), _globals, _locals)
 
1:58 PM
Unless you inject them with a critical mass of a disease
 
then how is it possible, that B's global dict is _globals
but A's globals dict is not
?
 
@PeterVaro we're trying to put the worlds wrongs to right, and you're talking about Python - how dare you!? :P
 
yeah, yeah, shame on me... :) but seriously? why is the globals() changes? and how to prevent that?
 
The best way to execute a file (so it opens) it's the function execfile?
 
Wow - is it me, or are there two identical gravatars here....
Oh... no - just one now
Nope 3 of em
 
2:08 PM
Actually, there's 3..
 
cabbage
 
Hey all, I'm still trying to use selenium for some site scraping and was trying to find an xpath selector to find all links that DO NOT CONTAIN the phrase "javascript:" in their href. I can find all sorts of examples of the "contains" xpath keyword, but trying to reverse the logic is a different story.. any ideas?
 
I don't know anything about what you're saying, but what if you grab everything then check for 'javascript:', and if it's there, reject?
 
//a[not(contains(@href, "javascript"))] or something...
@sadmicrowave If you're comfortable using beautifulsoup (I think you were starting with that) then it's probably easiest to use get extract the DOM and put that into BS, and query from there
 
2:27 PM
@JonClements thats probably true considering I've already got the html source at the point that I'm trying to do this xpath command
 
so @JonClements -- do you have any idea on what's going on with the exec?
 
@PeterVaro nope - haven't even thought about it
Shouting at baseball at the sec :)
 
So B imports A and C execs B, and you expect A to be able to access the global variables given by C?
 
cabbage y'all
 
2:30 PM
cabbage nihiser
 
@Kevin Exactly!
 
But that doesn't seem to fit with the scoping that files usually have. As a simpler example:
#a.py
global foo
print foo

#main.py
global foo
foo = 23
import a
Result: NameError: global name 'foo' is not defined
a can't access the globals created by main.
 
so it is not possible to create a cross-module global value?
 
Perhaps you could make a globalsettings.py file.
 
That'd be the normal approach - then just import that when it's required
 
2:37 PM
Ah the old "how do I keep the command window open" question.
 
umm.. sure, it could work -- but this also means, that I cannot create any kind of sandbox-like thingy with exec -> I mean even if I pass a limited __builtins__, the module that is imported by the main python file, can easily rewrite it..
 
Re-writing Python code in python is easy... just tell people not to :)
 
So you're worried that when you exec B, then it could modify the values in globalsettings, which will affect code not in the sandbox. Troublesome.
 
Then, if they do, and it goes bang... it's not your problem :P
 
2:40 PM
I don't want to create any kind of bullet-proof stuff, because as you mentioned it is a piece of cake to hack out of it
ummm...
@JonClements nice attitude:P
 
I wonder if there's a way to overshadow the real globalsettings, so when b tries to import it, it gets a replica whose changes won't propogate to the real one.
 
Yup, but to make sure they don't push the big red button - make sure to put flashing signs all around it, pointing to the button, with "UNDER NO CIRCUMSTANCES SHOULD YOU PRESS THIS BUTTON BECAUSE..." and then see what happens
 
Cabbage fellow Pythonistas! :D How goes snake charming?
 
Cabbage @Games
 
2:43 PM
Do not press the jolly, shiny, candy-like button
(Sorry for the recording-of-a-television quality :< )
 
oh I love ren & stimpy
 
@nihiser Yo! :)
@PeterVaro Hows visual python coming along?
 
@GamesBrainiac umm.. I'm working on it;)
 
cbg
 
01:00 - 15:0015:00 - 23:00

« first day (1068 days earlier)      last day (3880 days later) »