Around 3+ years back, I remember having seen a man brutally beating a 7-8 year old kid. It all started in front of my eyes in Mumbai at Siwri railway station ticket counter where a man beats up a homeless kid, He took kid behind the ticket counter and beat him brutally while the kid was shouting crying helpless. Then few of those standing in ticket queue when to stop that man... Perhaps humans are becoming lesser human...
Few months back I saw a news in which muslims were attacked in china, just because they were muslims. 31 innocent people were killed and 90 were injured in the attack on market in volatile western China region: source: Fox News
I see a clear picture we humans are not the species best evolved, infact humans are still those unsocial animal, criminal carnivore beasts roaming freely. I have been hearing news on attack on israel by Hamas. Hatred and killing to such an extent is the failure of our societies and culture. Religion seems to have played venomous role in making the situation even more tragic. Society is lacking collectively in critical thinking skills.
Hang on a second is this Man who god created in his own image. what is the excuse for the religious now? If god really existed why are their so many rapes, murder and crimes happening all around the world. Its not a religion trying to overcome other religion or trying o prove who/what/ which is better, it is people killing people. Everyday if you watch TV news pick up a newspaper you will get to see, hear news of murder, killing rape.
Just today I see this news on TV a private tutor beating a 3 year old kid ruthlessly, and another incident in which 3 visually challenged students gets caned by teacher. Undoubtedly humanity is seems seems to losing grip of civilised and sane living.
is this going to continue like this ? why can't this be changed for goodness, if not god then why can't human proves themselves that they are really the one who deserve to be on the top order of all the species on the planet. To bar or refrain yourself to effort to make things better or just ignore or being blind with eyes wide open is the worst of mankind has ever faced. Law and government who are supposed to bring law justice and order is just sitting their to prove themselves right and they are doing their best in efforts. maybe true to some extent but for sure it is we the people of so called civilised society also has to change.
Everyone commutes to go places, come to office, use electricity to each TV or browse the internet, then why do we go to temple or pray to god to bring happiness in their lives, why know work an effort like a worship to learn and do the things that helps us progress and survive. When all vehicles runs on petrol, diesel or some electric power why do we have to still believe or pray to someone invisible that doesn't exist. This is the real image of society we are living in . It is too difficult for the civilised to keep a control to their emotions and be self disciplined.
So recently I figured out how to emit a signal for a QT SLOT triggered by function at module level. Although I am still digging more into this but I will put two techniques here in this post.
The second case is when you want to emit a signal from one class and to be captured by different class .
Although, It is not a good idea to kill a thread abruptly, in python or in any language.
This is due to two main reason I can think of:
> the thread is holding a critical resource that must be closed properly
> the thread has created several other threads that must be killed as well.
In addition to that mixing signals and threads is always a little precarious.
Python only handles signals in the main thread. If the OS delivered the signal to another thread, that thread may be briefly interrupted (when it's performing, say, a systemcall) but it won't execute the signal handler. The main thread will be asked to execute the signalhandler at the next opportunity.
If you have ever done multithreaded programming in Python you have probably found it frustrating that you can't simply hit Ctrl-C in the terminal and have it exit like a normal Python process. Instead you have to put the process in the background (Ctrl-D) and then either "kill %%" or kill the PID. The good news is that it doesn't have to be this way. After experimenting whole day I finally figured out why it doesn't work normally and what you have to do to make it work.
Have a look at the code here: https://bitbucket.org/sanfx/filedownloader/
a thread of execution is the smallest sequence of programmed instructions that can be managed independently by an operating system scheduler. For more detailed jump to : http://en.wikipedia.org/wiki/Thread_(computing)
the above code runs 4 threads in a single process, where each thread utilising resources of a common process initiated. So this is probably doing it with single processor when my macbook has 1 processor and 2 cores.
However keeping in mind with the python code above, each subsequent threads will starts in each loop and do their operation. Python suffers from GIL, so you should consider using threads only in case of i/o bound tasks and not computational one.
what are the resources that gets shared ?
Multiple threads can exist within the same process and share resources such as memory, while different processes do not share these resources. In particular, the threads of a process share the latter's instructions (its code) and its context (the values that its variables reference at any given moment).
Here is a simple program that downloads mp3 files from internet parallel however the display is not done in the same way due to the nature how sys.stdout.write & sys.stdout.flush() works
Later that day, I used Queue & daemon thread, see here
threading can be complicated when threads need to share data or resources. The threading module does provide many synchronization primatives, including semaphores, condition variables, events, and locks. While these options exist, it is considered a best practice to instead concentrate on using queues. Queues are much easier to deal with, and make threaded programming considerably safer, as they effectively funnel all access to a resource to a single thread, and allow a cleaner and more readable design pattern.
“Join” method is used for waiting on threads & processes to end. It means “wait until the thread dies”, without explicitly killing it. So "join" doesn’t kill the thread, it just waits (and blocks) until the thread has finished running.
In non-daemon thread, you'd have to keep track of them, and tell them to exit, before your program can completely quit. By setting them as daemon threads, you can let them run and forget about them, and when your program quits, any daemon threads are killed automatically.
A daemon thread is ended when it's parent thread has ended, a non-daemon thread will keep the parent thread alive until the non-daemon is finished.
A primary use for weak references is to implement caches or mappings holding large objects, where it’s desired that a large object not.
So the question came to my mind, in a list, set or tuple if an item/ object doesn't exist then can't WeakSet be helpful ?
So what I came to learn is you can reference weakRef object in the set as long as it exists. It will be removed when the last reference is let go and it gets garbage collected. Helps for stuff like indexing other objects and allowing them to disappear when they should.
so what I make out if this there is some benefit of using WeakSet or you referred to sets only because it would be automatically garbage collected...
using WeakSet, If you put an object in there, and then the object goes out of scope, it will disappear. Because the WeakSet isn't keeping the reference count up. Here is a random example: Lets say you have a bunch of objects and you want to categorize some of them as being "good". You can put the ones you want into a WeakSet called goodSet. Now when the actual original objects get deleted, they will automatically remove themselves from the goodSet. You don't have to go and keep track of them in multiple places. But you can look at that goodSet any time you want to see if something is in there. I actually have used WeakKeyDictionary and WeakValueDictionary a lot more, for associating objects with some value. But if the object gets deleted, it will pop out of the dict automatically.
The post is documentation of my discussion with Justin on Google +
to put an end to the rape culture their is not easy way to go, human thinking cannot be changed no matter how many articles, protests or laws are made. When intuition are triggered by a chemical reaction in brain of a person it is the outcome of the chemical bonds that played the role in construction of his thoughts that one had at that time that he would attempt such a heinous crime then society, culture and religion are to blame. These are the elements that form the very basis of human thinking and that leaves a benchmark in human genes when information expressed through language and actions, the learning gets carried over to next generation through genes.
I personally believe, if humanity does seek a cure for such an itch "i.e. to end the rape culture" that would require a big necessary sacrifice (and at a bigger domain).
If we are the outcome of the evolutionary success(are we really) of billions of years, then now we are reaching the age when we can genetically modify our own DNA. What I mean is if we have the ability to control the fate of our own existence taking the advantage of science and technology we can control the thinking of humans by offsetting those chemical bonding that causes the trigger of thoughts in brain to completely avoid an such event (act of committing crime).
I believe and I am sure, that won’t be an easy to do, scientifically and psychologically too.
So now the question comes what is the sacrifice I am talking about, I do not want to blow your mind but and I can be wrong because nothing is certain in nature.
That would be the suppression/ termination of those who carries carries the maximum genes that can potentially contribute to act of violence. This might sound crazy because the number would surely will come in billions. a mass sacrifice.
Well that's what makes it hard to accept, how is this possible (maybe to even think of)?
And then genetically modifying or even more advanced technology to alter the DNA and programme the genes of those are yet to be born.
Thinking with the norms built by the current society it is impossible, so their is a need of change, we must be ready to accept the levels of survival if we really want to put an end to heinous crime out if which ‘rape’ is one of them committed by men living and born in this society.
Its a sort of impossible thinking, and to even take this seriously it much sounds like a extremely risky experiment and a crazy idea.
I won't be surprised if what I am pointing to doesn't blows your mind.
I believe society lacks not just the morale but ability to take hard decisions and self-discipline.
For me it is really hurting to see that girls live, walk through, under the fear of vulnerability because not all men are rapist.
When you sit on a chair and work continuously time seems to pass fast, because your focus on time is lost, due to the fact you are paying more attention to your work. But when you move to seat by seat to look at someone else’s work or talk to someone time will seem to be passing slow because now you are more concerned about time because you have to finish your own work too, So now you have added movement of your body in space and a secondary attention in mind to finish your work before office hours is making you feel of the time. So you experience the passing of time each and every tick.
My understanding of time:
Since the passing of time is affected by various forces acting on an object/ living being, like one such force is gravity , it tends to slow down time with the rate of increase in the force of gravity. So time travel is observed as by the laws of physics , from an example travelling to an object that has immense gravitational force such as blackhole will make the time passed by us at an extremely slow rate, i.e. we are now relative to the time of blackhole, but our body will only grow old at the rate at which is going through by the brain temporally coordinating among different senses, but also among different sensory modalities. For example, for vision, this would include a coordination between an objects' edges, motion, angles, color, etc. (stated by David Eagleman) however the time on planet earth is bind to its own gravity and the people on earth will continue to grow old at its rate which is faster in comparison to the time around the blackhole. So those on a spaceship near a blackhole will not grow old and when they reach back earth a lot of time might have been passed and the people of same age would have grown old and you are still young.
However the question now comes to my mind is why the people/scientist call it travelled in time, when its rather only that we have lived more in time.
What people think is normal is actually the norms that come from the culture or society we live in, and when someone rational gets up to speak sensible or logical, then somebody from the society gets up laugh and make fun of him by calling crazy. Self-righteousness has brain-washed minds of million and those who are playing boss have become or keep tendency to become a control freak. Then these momentarily master ignore the one under him or they are blind to sight the real. Alas, the society continues to become more and more crazy, and vicious acts becomes the acceptable norms.
Education - it is more often seen and observed that teaching goes like an indoctrinate from the elders, parents senior people in society or teachers in school, or religious institutions This is make living strenuous for the present generation and could probably lead to extremes for the future generations.
Education should be like a guiding system, in which individual can make their own decisions.
Cure for the itch !!!
Demand rational thought, people will come to their own conclusions.
"Do not do to others what you do not want done to yourself" golden rule of Confucianism.
It would be dishonest to do anything less for the people we care about.
Thought I should post it before I forget. Few months back I came across with this way to get row vs column using itertools.
I have started to use the else clause with For loop and with try Except quite late though. Its really very useful and neat. For understanding I am going to put some examples below.
using else with try except
using else with for loop