Re: Question regarding objects in __call__() methods

2018-03-25 Thread Arshpreet Singh
On Monday, 26 March 2018 11:32:51 UTC+5:30, dieter  wrote:

> Fürther inspection utilities: "dir", "vars" and the "inspect" module.
> Read the documentation to find out what they do.

Thanks, Dieter, That is really helpful!
-- 
https://mail.python.org/mailman/listinfo/python-list


Question regarding objects in __call__() methods

2018-03-25 Thread Arshpreet Singh
I am debugging a set of code which is something like this:
 
http://dpaste.com/1JXTCF0

I am not able to understand that what role internet object is playing and how I 
can  use/call it. 

As debugging the code I got at line 10. I am sending a request to particular 
API and returning a request_object . further deep down it generates the 
"response_object" as from my requirements that should be JSON object but I am 
only getting Python-Object in hexa form, is there any way I can get to know how 
to use internet_object so I can get to know how to use that internet_object 
with response.

I am also able to call __call__ method something like this:

def hierarchy_attach(env, parent):
svc = IMS(env)
svc(parent)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cython taking more time than regular Python

2016-09-19 Thread Arshpreet Singh
On Tuesday, 20 September 2016 11:00:40 UTC+5:30, Stefan Behnel  wrote:
 
> > In [8]: %timeit omega(10)
> > 1 loops, best of 3: 91.6 µs per loop
> 
> Note that this is the worst benchmark ever. Any non-dump C compiler will
> happily apply Young Gauß and calculate the result in constant time.

Hey Stefan what else you suggest?

-- 
https://mail.python.org/mailman/listinfo/python-list


Cython taking more time than regular Python

2016-09-19 Thread Arshpreet Singh
Hope this is good place to  ask question about Cython as well. 
Following code of mine is taking 2.5 times more time than Native Python code:

%%cython
import numpy as np
a = np.array([])
def large_sum2(int num_range):
np.append(a,[i for i in xrange(num_range)])
return a.sum

%timeit large_sum2(10)
10 loops, best of 3: 19 ms per loop

on the other side python takes much less time:

def large_sum(num_range):
return sum([i for i in xrange(num_range)])

%timeit large_sum(10)
100 loops, best of 3: 7 ms per loop
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Holding until next value change

2016-08-26 Thread Arshpreet Singh
On Saturday, 20 August 2016 11:38:03 UTC+5:30, Steve D'Aprano  wrote:

> state = ignore_negative  # DON'T call the function yet
> for value in main_call():
> print(value)  # for testing
> if state(value):
> print("changing state")
> state = TABLE[state]

Above code works at some extent but after few minutes of running it
returns and exists by printing 'None' on screen. Let me tell that
main_call() generator spits out values like one more each second after
going through some sort of heavy calculations(but even 50% of RAM is
available) it exits by printing 'None' on screen. Is it some kind of recursion 
problem?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Holding until next value change

2016-08-25 Thread Arshpreet Singh
On Saturday, 20 August 2016 19:48:38 UTC+5:30, andrze...@gmail.com  wrote:
 
> prev = None
> for value in main_call():
> if value==prev:
> pass
> else:
> prev = value
> if prev>0:
> print('+v')
> elif prev<0:
> print('-v')
> else:
> print('0')

No it did'nt worked.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Holding until next value change

2016-08-20 Thread Arshpreet Singh
On Saturday, 20 August 2016 11:38:03 UTC+5:30, Steve D'Aprano  wrote:
> On Sat, 20 Aug 2016 02:53 pm, Arshpreet Singh wrote:
> 
> > I am writing a function as main_call() which is continuously producing
> > values. (+ve or -ve) I want to print on screen only for first +ve value
> > and hold until -ve value comes around. here is my code:
> > 
> > 
> > def main_call():
> > while True:
> > yield strategy()
> >  
> > for value in main_call():
> > if(value>0):
> > print '+ve'
> > elif(value>0):
> > print '-ve'
> > else:
> > pass
> > 
> > Do I need to use threads or processes?
> 
> Only if you want a major headache.
> 
> 
> Your code doesn't do what you want it to do. It prints "+ve" every time it
> sees a positive value, not just the first time.
> 
> One solution to this is to think of a state machine: your machine starts off
> in the state:
> 
> (1) Ignore negative values, print the first positive value you see, 
> then change to the next state.
> 
> The second state is:
> 
> (2) Ignore positive values, print the first negative value you see,
> then change to the next state.
> 
> The third state is unspecified. You don't know say what it is, so I'm going
> to guess that you change to a third state:
> 
> (3) Don't ignore anything, print every value you see.
> 
> 
> So here are our three machines:
> 
> def ignore_negative(x):
> if x < 0:
> return False
> else:
> print("+ve")
> return True
> 
> def ignore_positive(x):
> if x > 0:
> return False
> else:
> print("-ve")
> return True
> 
> def ignore_nothing(x):
> if x > 0:
> print("+ve")
> else:
> print("-ve")
> return False
> 
> 
> Here is a table that specifies the changes in state:
> 
> TABLE = { # current state: next state
> ignore_negative: ignore_positive,
> ignore_positive: ignore_nothing,
> }
> 
> 
> And some code to drive it:
> 
> 
> state = ignore_negative  # DON'T call the function yet
> for value in main_call():
> print(value)  # for testing
> if state(value):
> print("changing state")
> state = TABLE[state]
Hi Steve, my third state is if x==0 , I tired the same code but here is output 
I am getting, so we are changing the state even it is printing out the +ve as 
well as -ve values

8.7664352813e-05
+ve
changing state
8.7664352813e-05
8.7664352813e-05
8.7664352813e-05
8.7664352813e-05
8.7664352813e-05
8.76628243948e-05
8.30490294982e-05
8.30490294982e-05
6.45892873188e-05
6.45892873188e-05
6.45892873188e-05
6.45892873188e-05
-4.61232547941e-06
-ve
changing state
-4.61232547941e-06
-ve
-4.61232547941e-06
-ve
-4.61232547941e-06
-ve
-4.61232547941e-06
-ve
-4.61232547941e-06
-ve
-4.61232547941e-06
-ve
-4.61232547941e-06
-ve
-4.61232547941e-06
-ve
-4.61232547941e-06
-ve
-4.61232547941e-06
-ve
-4.61232547941e-06
-ve
-- 
https://mail.python.org/mailman/listinfo/python-list


Holding until next value change

2016-08-19 Thread Arshpreet Singh
I am writing a function as main_call() which is continuously producing values. 
(+ve or -ve) I want to print on screen only for first +ve value and hold until 
-ve value comes around. here is my code:


def main_call():
while True:
yield strategy()
 
for value in main_call():
if(value>0):
print '+ve'
elif(value>0):
print '-ve'
else:
pass 

Do I need to use threads or processes?
-- 
https://mail.python.org/mailman/listinfo/python-list


holding if/else condition in live bitcoin trading Python

2016-08-02 Thread Arshpreet Singh
I am making a function that is running in while loop and if/else statements 
make decisions on based on the condition:
here is code:


def main_call():
while True:
l0_0 = getDiff('btcusd',8)
l1_0 = np.tanh(l0_0*0.8446488687)

l1_1 = np.tanh(l0_0*-0.5674069006)
l1_2 = np.tanh(l0_0*0.8676766445)

  
if(l3_0>0):
print l3_0
print auto_order_buy('0.01',str(ticker_last('btcusd')))
elif(l3_0<0):
print l3_0
print auto_order_sell('0.01',str(ticker_last('btcusd')))
else:
pass

now in my function l3_0>0 auto_order_buy() is executed but as program is 
running in while loop so it gets executed again and again. I have implemented 
while loop because I am doing live trading. is there any approach I can go with 
so auto_order_buy() auto_order_sell() function only executed once?
-- 
https://mail.python.org/mailman/listinfo/python-list


Python text file fetch specific part of line

2016-07-27 Thread Arshpreet Singh
I am writing Imdb scrapper, and getting available list of titles from IMDB 
website which provide txt file in very raw format, Here is the one part of 
file(http://pastebin.com/fpMgBAjc) as the file provides tags like Distribution  
Votes,Rank,Title I want to parse title names, I tried with readlines() method 
but it returns only list which is quite heterogeneous, is it possible that I 
can parse each value comes under title section?
-- 
https://mail.python.org/mailman/listinfo/python-list


CyberRoam Python Alternative for network security

2016-07-08 Thread Arshpreet Singh
This is question more about product information and less technical but Hope It 
will be use-able at some context, I use Cyeberoam(https://www.cyberoam.com/) Is 
there any Python alternative available for that? or If I have to 
write/implement something like this(https://github.com/netkiller/firewall) 
should I need to install it inside every computer or I can create a server and 
all the internet requests will pass through that, But that will be slow down 
the speed of the internet as well?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: not able to install mysqldb-python

2016-06-24 Thread Arshpreet Singh
On Thursday, 23 June 2016 23:18:27 UTC+5:30, Joaquin Alzola  wrote:
> >ImportError: No module named 'ConfigParser'
>  It is telling you the error
> This email is confidential and may be subject to privilege. If you are not 
> the intended recipient, please do not copy or disclose its content but 
> contact the sender immediately upon receipt.

Thanks but somehow it fixed itself. :P now able to install mysql-python without 
any problem.
-- 
https://mail.python.org/mailman/listinfo/python-list


not able to install mysqldb-python

2016-06-23 Thread Arshpreet Singh
I am trying to run django project in virtual environment. it needs mysql 
database library but when I try to install that it returns the error that 
configparser is not installed but I have installed configparser still the error 
remains same, is this ubuntu bug?


(env) ubuntu@ip-:~/clearapp$ pip install ConfigParser
Requirement already satisfied (use --upgrade to upgrade): ConfigParser in 
./env/lib/python3.4/site-packages
(env) ubuntu@ip-172-31-56-59:~/clearapp$ pip install configparser
Requirement already satisfied (use --upgrade to upgrade): configparser in 
./env/lib/python3.4/site-packages
(env) ubuntu@ip-172-31-56-59:~/clearapp$ pip install MySQL-python
Collecting MySQL-python
  Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "", line 1, in 
  File "/tmp/pip-build-rrhl9079/MySQL-python/setup.py", line 13, in 
from setup_posix import get_config
  File "/tmp/pip-build-rrhl9079/MySQL-python/setup_posix.py", line 2, in 

from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'


Command "python setup.py egg_info" failed with error code 1 in 
/tmp/pip-build-rrhl9079/MySQL-python/
(env) ubuntu@ip-172-31-56-59:~/clearapp$ 
-- 
https://mail.python.org/mailman/listinfo/python-list


passing dictionay as argument

2016-06-13 Thread Arshpreet Singh
I have to pass dictionary as function argument for following code:


import authorize

authorize.Configuration.configure(
authorize.Environment.TEST,
'api_login_id',
'api_transaction_key',
)

result = authorize.Transaction.sale({
'amount': 40.00,

'credit_card': {
'card_number': '4111',
'expiration_date': '04/2014',
'card_code': '343',
}

})

result.transaction_response.trans_id



I want to define 'credit-card' dictionary as argument in the function as 
follows but it returns syntax error:



# define dictionary outside the function call: 
credit_card={
'card_number': '4111',
'expiration_date': '04/2014',
'card_code': '343',
}

import authorize

authorize.Configuration.configure(
authorize.Environment.TEST,
'api_login_id',
'api_transaction_key',
)

result = authorize.Transaction.sale({'amount': 40.00,credit_card})

result.transaction_response.trans_id

it returns following error:

result = authorize.Transaction.sale({40.00,credit_card})
TypeError: unhashable type: 'dict'

Do I need to make changes in authorize.Transaction.sale() source code?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Intel Distribution for Python

2016-05-10 Thread Arshpreet Singh
Thanks for the information, I just applied for program but I got one mail about 
license and expiration. 


This software license expires on October 29, 2016.


I am not able to understand that can anyone put some light on that how license 
can be expired? 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: E-commerce system in Python

2016-03-20 Thread Arshpreet Singh
On Friday, 18 March 2016 21:44:46 UTC+5:30, Chris Warrick  wrote:
 
> asyncio is, as you said, brand new -- probably nothing exists.
> Why not use the existing Django solution though? What is your problem
> with it? It's a great framework that does a lot of the hard work for
> you. Flask is low-level.

Yes Flask is low level so it comes before for me.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fetch Gmail Archieved messages

2016-03-20 Thread Arshpreet Singh
On Saturday, 19 March 2016 05:38:16 UTC+5:30, Rick Johnson  wrote:

> I gave you "real help". 
> 
> What you want me to do -- write the code for you? Sorry, but Python-list is 
> not a soup kitchen for destitute code. Neither is it a triage center were you 
> can bring your sick code, drop it at the door, and say: "Here, fix this, i'm 
> going to the bar".  
> 
> Where is your traceback? 
> 
> Does your code run without raising Errors?
> 
> Why did you create a loop, simply to iterate over a list-literal containing  
> one value?
> 
> At this point, i can't determine if you're trolling or serious...

Thanks "Big boy"! I just asked for help not any kind of malfunction here. 
-- 
https://mail.python.org/mailman/listinfo/python-list


E-commerce system in Python

2016-03-19 Thread Arshpreet Singh
I am looking for an E-commerce system in python to sell things things online, 
which can also be responsive for Android and IOS. 

A  quick Google search brought me  http://getsaleor.com/ it uses Django, Is 
there any available one using Flask or newly born asyncio based framework?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fetch Gmail Archieved messages

2016-03-18 Thread Arshpreet Singh
On Friday, 18 March 2016 11:14:44 UTC+5:30, Rick Johnson  wrote:

> #
> # BEGIN CODE
> #
> import imaplib
> 
> def inbox_week():
> emailAddress = '...@gmail.com'
> emailPassword = 'mypassword'
> # START ADDING CODE HERE
> #
> # END CODE
> #

Well I am asking for real help.(!suggestions)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fetch Gmail Archieved messages

2016-03-18 Thread Arshpreet Singh
On Tuesday, 15 March 2016 22:32:42 UTC+5:30, Rick Johnson  wrote:

> Is that last line doing what you think it's doing? Let's
> break it down... Basically you have one condition, that is
> composed of two main components:
> 
> Component-1: EMAIL in str(msg[header])
> 
> and 
> 
> Component-2: str(msg[header])
>  
> 
> "Component-1" will return a Boolean. So in essence you're
> asking:
> 
> boolean = EMAIL in str(msg[header])
> if boolean in str(msg[header]):
> do_something()
>  
> Is that really what you wanted to do? I'm not sure how you
> will ever find a Boolean in a string. Unless i've missed
> something...? 

Yes I am looking for in EMAIL string is present in  str(msg[header]) then 
do_something()

>It will also help readability if you only 
> applied str() to the value *ONCE*. But, maybe you don't 
> even need the str() function???

I also run without str() but sometimes it causes weird exception errors because 
you can't predict the behaviour msg[header].
-- 
https://mail.python.org/mailman/listinfo/python-list


Fetch Gmail Archieved messages

2016-03-15 Thread Arshpreet Singh
Hi, I am using imaplib to fetch Gmail's Inbox Archived message but results are 
not that much accurate. Here is code+logic:


def inbox_week():
import imaplib
EMAIL = 'myusern...@gmail.com'
PASSWORD = 'mypassword'
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login(  EMAIL, PASSWORD )
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.select("[Gmail]/All Mail")
interval = (date.today()-timedelta(d)).strftime("%d-%b-%Y")
_, data = mail.uid('search', None,'(SENTSINCE{date})'.format(date=interval))

for num in data[0].split():
_, data = mail.uid('fetch', num, '(BODY.PEEK[])')

for response_part in data:
if isinstance(response_part, tuple):
msg = email.message_from_string(response_part[1])
for header in ['to']:
   
# This is logic for inbox-archieved messages
if (EMAIL in str(msg[header]) in str(msg[header])):

main_tuple = email.utils.parsedate_tz(msg['Date'])   

yield main_tuple

I am not sure how to get the list of only Inbox-messages as well as Sentbox 
messages from [All-mail]. Do I need to any other library ?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyraf problem

2016-02-26 Thread Arshpreet Singh
On Thursday, 25 February 2016 20:07:52 UTC+5:30, Sapna Mishra  wrote:
> Dear Sir/Mam, 
> 
> I am using python for my astronomy purpose, for that I want to use PyRaf, but 
> strange thing is occurring that pyraf is getting open as a root but out side 
> my root user directory when I am typing pyraf I am getting like; 
> No graphics/display possible for this session. 
> Tkinter import failed. 
> The numpy package is required by PyRAF and was not found. Please visit 
> http://numpy.scipy.org 

Hi Sapna, You can't run directly X-window system from root account, SO you are 
getting Tkinter error. 

You can try to install as follows:

sudo pip install pyraf

But befoore that you also need to install numpy as it is required for pyraf or 
scipy too.

SO you need to run 
sudo pip install numpy scipy

Above instructions will work only for Python2.X
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: avoid for loop calling Generator function

2016-02-22 Thread Arshpreet Singh
On Monday, 22 February 2016 19:05:24 UTC+5:30, Peter Otten  wrote:
> Arshpreet Singh wrote:
> 
> > Hi, I am converting PDF into text file, I am using following code.
> > 
> > from pypdf2 import PdfFileReader
> > 
> > def read_pdf(pdfFileName):
> > 
> > pdf = PdfFileReader(pdfFileName)
> > 
> > yield from (pg.extractText() for pg in pdf.pages)
> > 
> > for i in read_pdf('book.pdf'):
> >  print(i)
> > 
> > I want to avoid for loop , I also tried to create another function and
> > call read_pdf() inside that new function using yield from but I think I am
> > missing real picture here
> 
> While it is possible to replace the loop with
> 
> next(filter(print, read_pdf("book.pdf")), None)

Why we are w=using filter here?
 
> or the slightly less convoluted
> 
> sys.stdout.writelines(map("{}\n".format, read_pdf("book.pdf")))

Actually I am using this function in Android App which is being built using 
Kivy, Where I am returning whole text into a file, So what you think will be 
more efficient way? 

> the for loop is the obvious and therefore recommended solution. Personally, 
> I would also replace
> 
> > yield from (pg.extractText() for pg in pdf.pages)
> 
> with the good old
> 
> for pg in pdf.pages:
> yield pg.extractText()
> 
> and reserve the generator expression for occasions where it has a 
> demonstrable advantage in readability.
But when I am calling pdf_read() from nother function to avoid for loop why it 
is not working?
say:

def hello()
yield from read_pdf('book.pdf')

print(hello()) # still returns memory location instead of text. If I am not 
wrong yield from can be used to avoid for loop? 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Setting up/authenticating Google API?

2016-02-22 Thread Arshpreet Singh
On Sunday, 21 February 2016 21:21:54 UTC+5:30, Skip Montanaro  wrote:
> This isn't strictly a Python question, however... Once I get myself
> authenticated, I intend to use the Python Google API to pump archived
> mail messages from a few defunct mailing lists into Google Groups. I
> thought it would be pretty straightforward, but my attempts a few
> months ago were completely unsuccessful. I asked for help on the
> relevant Google product forum but got zero assistance.
> 
> I'd really appreciate a little help with the setup. If anyone has had
> successful experience with this, please contact me off-list. Once I
> get something going, I'll write a blog post so others don't have the
> same problems I have.
> 
> Thanks,
> 
> Skip Montanaro

Your question seems quite cinfusing to me but I think following may is what you 
are asking for.(Read the source)

https://google-mail-oauth2-tools.googlecode.com/svn/trunk/python/oauth2.py

After getting the authentication you can use imaplib to get all the gmail Data.

-- 
https://mail.python.org/mailman/listinfo/python-list


avoid for loop calling Generator function

2016-02-22 Thread Arshpreet Singh
Hi, I am converting PDF into text file, I am using following code.

from pypdf2 import PdfFileReader 

def read_pdf(pdfFileName):

pdf = PdfFileReader(pdfFileName) 

yield from (pg.extractText() for pg in pdf.pages)

for i in read_pdf('book.pdf'):
 print(i)

I want to avoid for loop , I also tried to create another function and call 
read_pdf() inside that new function using yield from but I think I am missing 
real picture here 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why generators take long time?

2016-01-19 Thread Arshpreet Singh
On Tuesday, 19 January 2016 15:42:16 UTC+5:30, Steven D'Aprano  wrote:
 
> [steve@ando ~]$ python -m timeit -s "from collections import deque" 
> -s "it = iter([i for i in xrange(1000)])" "deque(it, maxlen=0)"
> 100 loops, best of 3: 0.913 usec per loop
> 
> 
> [steve@ando ~]$ python -m timeit -s "from collections import deque" 
> -s "it = (i for i in xrange(1000))" "deque(it, maxlen=0)"
> 100 loops, best of 3: 0.965 usec per loop

Thanks Steven, it was really helpful answer.  

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why generators take long time?

2016-01-19 Thread Arshpreet Singh
On Tuesday, 19 January 2016 12:58:28 UTC+5:30, Arshpreet Singh  wrote:
> I was playing with Generators and found that using Generators time is bit 
> more than list-comprehensions or I am doing it wrong?
> 
> 
> Function with List comprehensions:
> 
> def sum_text(number_range):
> return sum([i*i for i in xrange(number_range)])
> 
> %timeit sum_text(1)
> 1 loops, best of 3: 14.8 s per loop
> 
> Using generator Expressions:
> 
> def sum_text(number_range):
> 
> return sum((i*i for i in xrange(number_range))) 
> 
> %timeit sum_text(1)
> 
> 1 loops, best of 3: 16.4 s per loop

Or even when I use generator function:

def sum_text(number_range):
yield sum((i*i for i in xrange(number_range)))

another function to get value:

def get_sum():
for i in sum_text(1):
return i

%timeit get_sum()
1 loops, best of 3: 16.1 s per loop

-- 
https://mail.python.org/mailman/listinfo/python-list


Why generators take long time?

2016-01-18 Thread Arshpreet Singh

I was playing with Generators and found that using Generators time is bit more 
than list-comprehensions or I am doing it wrong?


Function with List comprehensions:

def sum_text(number_range):
return sum([i*i for i in xrange(number_range)])

%timeit sum_text(1)
1 loops, best of 3: 14.8 s per loop

Using generator Expressions:

def sum_text(number_range):

return sum((i*i for i in xrange(number_range))) 

%timeit sum_text(1)

1 loops, best of 3: 16.4 s per loop


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: When I need classes?

2016-01-10 Thread Arshpreet Singh
On Sunday, 10 January 2016 20:33:20 UTC+5:30, Michael Torrie  wrote:

> This way I can import functions defined in this script into another
> script later if I want.
> 
> If I find I need to share state between functions, and if I find that I
> might need to have multiple situations of shared state possibly at the
> same time, then I will refactor the script into a class.  Despite the
> apparent shame of using global variables, if I need to share state
> between functions, but I cannot ever foresee a time when I'll need to
> have multiple instances of that state, 

I have a case in Flask-Oauth2 where one function returns Username, Email ID and 
Authorised Token.

So I can make that function Global and access EMail,username and Authorised 
token from any other Script.

Or 
I can make it class?
  
>then I'll just use a module-level
> global variable and continue to use normal functions, rather than define
> a class.  In the parlance of OOP, this use case would be referred to as
> a "singleton" and a python module (a script) is a form of singleton
> already, even without using classes.

Is it also true that Classes(OOP) help to optimise code(uses less memory) 
rather than just doing things with functions.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: When I need classes?

2016-01-10 Thread Arshpreet Singh
On Sunday, 10 January 2016 21:09:52 UTC+5:30, Steven D'Aprano  wrote:

> There are *no* problems that are impossible to solve without classes, but
> sometimes classes will make problems easier to solve. And sometimes classes
> make problems harder to solve. It depends on the problem.

Is there any particular situation in your experience or in your past like you 
felt this could be more suitable with classes?

Actually a real life story from someone'e past experience could do much greater 
help.

> This may help you:
> 
> http://kentsjohnson.com/stories/00014.html

Thanks That is good read to remember and practice.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: When I need classes?

2016-01-10 Thread Arshpreet Singh
On Sunday, 10 January 2016 23:20:02 UTC+5:30, Bernardo Sulzbach  wrote:
> Essentially, classes (as modules) are used mainly for organizational purposes.
> 
> Although you can solve any problem you would solve using classes
> without classes, solutions to some big problems may be cheaper and
> more feasible using classes.

That seems coming to me as. I am going to start Kivy to build Android 
application and As I see there are lots of Example code with classes and stuff.
-- 
https://mail.python.org/mailman/listinfo/python-list


When I need classes?

2016-01-09 Thread Arshpreet Singh
Hello Friends, I am quite new to OOP(object oriented Programming), I did some 
projects with python which includes Data-Analysis, Flask Web Development and 
some simple scripts. 

I have only one question which is bothering me most of the time, When I will 
get the need to use Classes in Python? Or in other way is there any real-life 
example where you can tell me this problem/solution is kind of impossible in 
Python without Classes?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python PNG Viewer(Browser Based)

2015-11-03 Thread Arshpreet Singh
On Tuesday, 3 November 2015 21:32:03 UTC+5:30, Chris Warrick  wrote:
> On 3 November 2015 at 12:54, Arshpreet Singh  wrote:
> > Hello Everyone,
> >
> > I am looking for Browser-based PNG file viewer written in
> > Python.(Flask framework preferably)
> >
> > Following project(Flask-Based) provides many things(File manager as
> > well as file viewer)  but it does not support PNG files.
> >
> > https://github.com/vmi356/filemanager
> >
> > Any idea if I have to write my own browser based PNG viewer from
> > scratch(Using PIL or other required library)
> >
> > On the other side if I have to write only Desktop-based only two lines
> > are enough to do many things:
> >
> > Like,
> >
> > from PIL import Image
> > f = Image.open("file.png").show()
> >
> >
> > But I am not getting right sense that how to make possible using 
> > Python+Flask.
> >
> > Hope I am able to tell my problem?
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> 
> Your problem is lack of basic understanding of the Internet. 

Yes That's true at some level.

>Because
> EVERY graphical web browser supports PNG files NATIVELY. With a single
>  tag.

That is easily understandable. 
 
> Just figure out where to add the PNG handler code and read any random
> "how to add images to a webpage" tutorial.
> You might need a new template and some code that is aware of the file
> being an image. But absolutely no PNG viewer is necessary.

My present working system shows me list of all files (PNGs, JPGs, txt, SVGs) in 
browser, when I click on file it opens it and show contents of it. but PNG and 
JPGs are not working. Surely handling one PNG file is easy but no idea how to 
solve multiple file situation.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python PNG Viewer(Browser Based)

2015-11-03 Thread Arshpreet Singh
Hello Everyone,

I am looking for Browser-based PNG file viewer written in
Python.(Flask framework preferably)

Following project(Flask-Based) provides many things(File manager as
well as file viewer)  but it does not support PNG files.

https://github.com/vmi356/filemanager

Any idea if I have to write my own browser based PNG viewer from
scratch(Using PIL or other required library)

On the other side if I have to write only Desktop-based only two lines
are enough to do many things:

Like,

from PIL import Image
f = Image.open("file.png").show()


But I am not getting right sense that how to make possible using Python+Flask.

Hope I am able to tell my problem?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recover data over the network

2015-10-09 Thread Arshpreet Singh
On Friday, 9 October 2015 22:51:16 UTC+5:30, Emile van Sebille  wrote:
 
> without extensive clues as to the nature of the data to be recovered 
> you're not going to get much further with this.  

It is mostly /home partition data on disk. Those are user Configuration 
files.(user accounts, settings etc) 

>When I've had to 
> recover data from disks or damaged files is generally been a one-off 
> kind of recovery.

Please enlighten me about one-off kind of data recovery.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recover data over the network

2015-10-09 Thread Arshpreet Singh
On Saturday, 10 October 2015 04:40:27 UTC+5:30, Steven D'Aprano  wrote:
 
> What do you mean, "recover data from a server"? What has happened to the
> server? Can it boot or is it in an unbootable state? Are the hard drives
> physically damaged? What sort of hard drives? (Solid state, or magnetic
> media?)

Server is booting up. We are using SSD. Disk is not physically Damaged. I can't 
reach to server Physically. 
 
 
> What makes you think this will be a "small" Python application? Do you have
> limits on the maximum size? (Does the application have to fit on a floppy
> disk?) Are you expecting a GUI? What OS do you want the application to run
> on? (Windows, Linux, Mac OS, Android, embedded systems, something else?)

>From the small I was meaning a simple Python command Line application. That I 
>will be able to execute from shell. Server is on Ubuntu Linux.

> > For the 2nd part I can use scp(secure copy), Please let me know if any
> > data-recovery library is available in Python to do 1st task.
> 
> Depends on what you mean by data recovery.

My main aim is to recover user accounts mostly data present in /home partition 
of the disk.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recover data over the network

2015-10-09 Thread Arshpreet Singh
On Saturday, 10 October 2015 04:40:27 UTC+5:30, Steven D'Aprano  wrote:
 
> What do you mean, "recover data from a server"? What has happened to the
> server? Can it boot or is it in an unbootable state? Are the hard drives
> physically damaged? What sort of hard drives? (Solid state, or magnetic
> media?)

Server is booting up. We are using SSD. Disk is not physically Damaged. I can't 
reach to server Physically. 
 
 
> What makes you think this will be a "small" Python application? Do you have
> limits on the maximum size? (Does the application have to fit on a floppy
> disk?) Are you expecting a GUI? What OS do you want the application to run
> on? (Windows, Linux, Mac OS, Android, embedded systems, something else?)

>From the small I was meaning a simple Python command Line application. That I 
>will be able to execute from shell. Server is on Ubuntu Linux.

> > For the 2nd part I can use scp(secure copy), Please let me know if any
> > data-recovery library is available in Python to do 1st task.
> 
> Depends on what you mean by data recovery.

My main aim is to recover user accounts mostly data present in /home partition 
of the disk.
-- 
https://mail.python.org/mailman/listinfo/python-list


Recover data over the network

2015-10-09 Thread Arshpreet Singh
Hello Python and People!

I want to write a small Python application which will be able to 1.recover data 
from server and 2.send it to another server.

For the 2nd part I can use scp(secure copy), Please let me know if any 
data-recovery library is available in Python to do 1st task.
-- 
https://mail.python.org/mailman/listinfo/python-list