Re: [Tutor] Remote module loading

2017-09-07 Thread Mats Wichmann
On 09/07/2017 12:49 AM, devN wrote:
> Hi,
> I am newbie in python. I wrote a module which is meant to be run across
> couple of unix OS variants (redhat, debian, bsd and solaris). The module is
> updated frequently and new features added.
> 
...
> The above code was an alpha and there could be further optimizations which
> I request you to overlook.
> My requirement is, I have an agent copied in all the UNIX variants and I
> have done that only once and dont want to do it again (too many machines
> and no possibility of ansible or chef implementation). The agent currently
> loads the module locally but I need to let all clients know that the module
> is updated with new features, but really can't.
> So I thought to expose the module as plain text over http from a remote
> apache container. Is there any way to load the module from remote just as
> simple as import statement (without using urllib or wget piped to python)?
> This could also mean does PYTHONPATH support http/ftp?
> 
> Thanks

We had a bit of a discussion not too long ago about the general topic.
You can search in the list archive for "How to deploy seamless script
updates to your clients"

You've left a situation that isn't really very flexible since you say
you don't want to copy the agent again.  Nonetheless, I'll point you to
a little bit of fiddling I did on this topic that you could just chew on
and see if it makes any sense.  It's not really "newbie" code.  The
basic idea is that you have a known location which contains a file with
information about available releases; the module has a function a
participating script can call to find out if it has a new version
available.

Link to my pointer to this:
https://www.mail-archive.com/tutor@python.org/msg76681.html


The rest of the discussion has some other good ideas in it too (a
version control server may be able to provide a kind of solution).

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Remote module loading

2017-09-07 Thread devN
Well, it's another hassle to keep NFS shared and mounted in every other
systems, not to include the firewall rules.
Let me check out with the importlib

On Fri, 8 Sep 2017, 00:14 Peter Otten <__pete...@web.de> wrote:

> devN wrote:
> > Is there any way to load the module from remote just as
> > simple as import statement (without using urllib or wget piped to
> python)?
> > This could also mean does PYTHONPATH support http/ftp?
>
> While there are hooks to do everything you can imagine
>
> https://docs.python.org/dev/library/importlib.html
>
> that's not very accessible to newbies.
>
> Why don't you make the module available through the file system? Think NFS
> or SMB or WebDAV...
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help

2017-09-07 Thread boB Stepp
Greetings Edmundo!

On Thu, Sep 7, 2017 at 1:35 PM, Peter Otten <__pete...@web.de> wrote:
> edmundo pierre via Tutor wrote:
>
>>
>> I am trying to write a code that asks an User to Enter a decimal number,
>> the my program should separate the number in two parts like this: 1
>> cae:Enter a number: 12.9Decimal part: 12whole part : 9 2 case:Enter:
>> 10Decimal par:Whole part: 10 That is my code:
>> A = input("Enter a number")
>> C = [ ] for  i  in  str(A) :
>> C.append(i)  if i ==".# period ": break  aa= "".join(c)
>> print(aa, end =" ") if i == int(A): print(" It is the whole part")
>> I can not display the whole part when I enter float number. Plus when I
>> enter an integer, it takes that enteger as a decimal number. Any help?
>
> Hello Edmundo!
>
> We are all volunteers. Please help us help you. If you have a look at
>
> https://mail.python.org/pipermail/tutor/2017-September/111984.html
>
> you can see what we see of your code. It's completely garbled, and second-
> guessing what it might originally have looked like is no fun.
>
> You have to find out how to get your email program to send unmodified plain
> text before we can engage in a meaningful conversation.

I'd like to augment Peter's request:  Please use a more informative
subject line than "Help".  I notice you have posted two "Help" emails
recently on two substantially different topics.

As to the most current topic, your code is garbled to me as well, but
it looks like you realize that input() returns a string, not a float,
and that you are trying to use string methods to get what you want.
Another approach you might want to look into is using float(input())
to convert the string resembling a float into a floating point number
and then use the operator "//" (to perform integer division) and then
use that result to extract the decimal portion.  You will still have
to work on dealing with the decimal point removal and just getting the
decimal fraction as just integer-like numbers, but that is not too
hard ...

-- 
boB
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help

2017-09-07 Thread Mats Wichmann
On 09/07/2017 10:20 AM, edmundo pierre via Tutor wrote:
> 
> I am trying to write a code that asks an User to Enter a decimal number, the 
> my program should separate the number in two parts like this:
> 1 cae:Enter a number: 12.9Decimal part: 12whole part : 9
> 2 case:Enter: 10Decimal par:Whole part: 10
> That is my code: 
> A = input("Enter a number")
> C = [ ]     for  i  in  str(A) :
>       C.append(i)      if i ==".# period ":         break      aa= "".join(c) 
>   print(aa, end =" ")
>    if i == int(A):         print(" It is the whole part")
> I can not display the whole part when I enter float number. Plus when I enter 
> an integer, it takes that enteger as a decimal number. Any help?

Depending on what you have already learned, these hints may be helpful.

1. type() will let you experiment with what Python thinks you got. So as
to the second question,

A = input("Enter a number")
print(type(A))

if it is not what you expected, how can you get it to something you can
work with. Hint: you're already doing that once in your code.

2. strings are easy to split into pieces.  See the split() method.  This
simple tutorial might give you an idea:

http://www.pythonforbeginners.com/dictionary/python-split

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python

2017-09-07 Thread boB Stepp
Welcome to Tutor!

On Thu, Sep 7, 2017 at 8:14 AM, Vikram Singh
 wrote:
> I've been learning Python from Google For Education
> . A little help will be
> appreciated regarding the right way and right tutorials to learn Python
> from. Thanks in advance.

This is a very common question on this list as you might imagine.  If
you go to the searchable Tutor list archives at

https://www.mail-archive.com/tutor@python.org/

and search for "learn python", you will get 8048 hits!  You might want
to do that, look over the results and perhaps perform other searches
for topics that more closely match your interest.

One thing I notice about the Google course you link to is that it is
Python 2-based.  The latest version of Python is now in version 3.6,
and generally speaking, if you are just starting out with Python, you
probably should be focusing your efforts on Python 3.

As a fellow learner, I can recommend some things *not* to do:

1)  Keep buying bunches of interesting books on Python and not
studying any of them thoroughly!  Instead, find a resource -- printed
on paper or online -- that speaks to you and work through it
thoroughly.

2)  Starting new project after new project and finishing very few of
them!  Instead, pick something interesting and start working on it,
planning on augmenting it as your knowledge grows in parallel with
your more formal studying.

3)  Working earnestly for a while, then taking long breaks off!  If
you are like me, you will tend to forget many things you have studied
previously, even forgetting you have asked about these things
previously on Tutor!!  Instead, try to work on at least a little bit
of Python studying each and every day, longer when life allows.

4)  I have more I could share, but I think you take my points!

If you have never done any programming, you may need to find a very
gentle resource to start out with that explains not only Python, but
general programming/computer science concepts in a lot of detail.
OTOH, if you already have experience with programming, then you
probably can greatly accelerate your learning progress, perhaps even
getting by with studying the official Python tutorial at

https://docs.python.org/3/tutorial/index.html

Bear in mind that Python has its own culture and ways of doing things
that can be a bit different from other languages you may have
studied/worked in.  You might enjoy the "Zen of Python" by Tim Peters.
You can access it in the Python interpreter by typing

>>> import this

I have been rambling a bit.  I just noticed that the searchable Tutor
archive is back up and searched for all of my previous posts.  Five
years and I have not come very far.  Do as I say and not as I do!!!
~(:>))

And always ask questions here when you get stuck.  Try not to top
post.  Give your OS and Python version and all other relevant
information to allow the experts to diagnose your problem(s).  Always
COPY AND PASTE both your relevant code and FULL ERROR TRACEBACK into a
plain text email to Tutor.  Try to limit your code to just the part
that is causing you to pull your hair out (If you still have any!
~(:>)) ).

And come back with more specific goals for your self-study along with
any relevant background.  Perhaps someone might be able to offer
advice that is more tailored to your needs and goals.

And again, welcome!  This is a very friendly and helpful place to learn!!

Cheers!


-- 
boB
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help

2017-09-07 Thread Peter Otten
edmundo pierre via Tutor wrote:

> 
> I am trying to write a code that asks an User to Enter a decimal number,
> the my program should separate the number in two parts like this: 1
> cae:Enter a number: 12.9Decimal part: 12whole part : 9 2 case:Enter:
> 10Decimal par:Whole part: 10 That is my code:
> A = input("Enter a number")
> C = [ ] for  i  in  str(A) :
> C.append(i)  if i ==".# period ": break  aa= "".join(c)  
> print(aa, end =" ") if i == int(A): print(" It is the whole part")
> I can not display the whole part when I enter float number. Plus when I
> enter an integer, it takes that enteger as a decimal number. Any help?

Hello Edmundo!

We are all volunteers. Please help us help you. If you have a look at

https://mail.python.org/pipermail/tutor/2017-September/111984.html

you can see what we see of your code. It's completely garbled, and second-
guessing what it might originally have looked like is no fun.

You have to find out how to get your email program to send unmodified plain 
text before we can engage in a meaningful conversation.

Thank you.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Remote module loading

2017-09-07 Thread Peter Otten
devN wrote:
> Is there any way to load the module from remote just as
> simple as import statement (without using urllib or wget piped to python)?
> This could also mean does PYTHONPATH support http/ftp?

While there are hooks to do everything you can imagine

https://docs.python.org/dev/library/importlib.html

that's not very accessible to newbies. 

Why don't you make the module available through the file system? Think NFS 
or SMB or WebDAV...

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Help

2017-09-07 Thread edmundo pierre via Tutor

I am trying to write a code that asks an User to Enter a decimal number, the my 
program should separate the number in two parts like this:
1 cae:Enter a number: 12.9Decimal part: 12whole part : 9
2 case:Enter: 10Decimal par:Whole part: 10
That is my code: 
A = input("Enter a number")
C = [ ]     for  i  in  str(A) :
      C.append(i)      if i ==".# period ":         break      aa= "".join(c)   
print(aa, end =" ")
   if i == int(A):         print(" It is the whole part")
I can not display the whole part when I enter float number. Plus when I enter 
an integer, it takes that enteger as a decimal number. Any help?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] New to Python

2017-09-07 Thread Vikram Singh
I've been learning Python from Google For Education
. A little help will be
appreciated regarding the right way and right tutorials to learn Python
from. Thanks in advance.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Remote module loading

2017-09-07 Thread devN
Hi,
I am newbie in python. I wrote a module which is meant to be run across
couple of unix OS variants (redhat, debian, bsd and solaris). The module is
updated frequently and new features added.

import platform
import os
import subprocess
def main ():
RESPONSE = dict ();
PYVER = float (platform.python_version_tuple ()[0] + "." +
platform.python_version_tuple ()[1]);
if PYVER < 2.4:
return;
RESPONSE["HOSTNAME"] = platform.node ();
RESPONSE["MEMORY"] = str (float (os.sysconf ('SC_PAGE_SIZE')) *
os.sysconf ('SC_PHYS_PAGES') /(1024 * 1024 * 1024)) +"GB";
RESPONSE["OSTYPE"] = platform.system ();
RESPONSE["OSKERNEL"] = platform.uname ()[3];
RESPONSE["PROCESSOR"] = platform.processor ();
if 'SunOS' in RESPONSE.values ():
RESPONSE["CORECOUNT"] = re.sub ('\s+', '',subprocess.Popen
("/usr/sbin/psrinfo | wc -l | cat", shell =True, stdout = subprocess.PIPE,
stderr =subprocess.STDOUT).stdout.readline ());
RESPONSE["OSVERSION"] = platform.release ();
if 'Linux' in RESPONSE.values ():
RESPONSE["OSKERNEL"] = platform.release ();
RESPONSE["OSVERSION"] = platform.linux_distribution ()[0] + " " +
platform.linux_distribution ()[1];
RESPONSE["CORECOUNT"] = CPUCOUNT;

print (RESPONSE);

if __name__== '__main__':
  main ()

The above code was an alpha and there could be further optimizations which
I request you to overlook.
My requirement is, I have an agent copied in all the UNIX variants and I
have done that only once and dont want to do it again (too many machines
and no possibility of ansible or chef implementation). The agent currently
loads the module locally but I need to let all clients know that the module
is updated with new features, but really can't.
So I thought to expose the module as plain text over http from a remote
apache container. Is there any way to load the module from remote just as
simple as import statement (without using urllib or wget piped to python)?
This could also mean does PYTHONPATH support http/ftp?

Thanks
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor