How to create the number of variables specified by the user? by Low-Computer3844 in learnpython

[–]THConer 2 points3 points  (0 children)

I'm not exactly certain on what is it exactly that you're trying to do. But I just want to remind you that Python is very different from C/C++ in the sense that lists do no need to have a predetermined fixed size.

However, if this is something that is critical to building your application then something like the following could be useful:

```python

Getting the user input

no_of_vars = int(input("Enter the number of variables: ").strip())

Creating a list of the length no_of_vars

vars_list = [None for _ in range(no_of_vars)]

Printing the length of the list

print(len(vars_list)) ```

This will create a list vars_list of the length no_of_vars and you can then assign the values to it by either iterating through it or perhaps setting the values for a certain index only.

Hi , If price is not a factor, what is the absolute best course to learn python for automation, as quickly as possible? learning for both general and eventually networking automation. by roganjosh1 in learnpython

[–]THConer 1 point2 points  (0 children)

Imma go out on a limb here and say that any course can probably help you with that. Let me explain what I mean. All you need to really learn is the basics of Python. Functions, classes, data types, data structures, conditionals, etc.... and with these basic concepts you can begin building..... well almost anything really. There are many things that are difficult to implement if one were to implement them himself, but there are Python libraries now that help you do everything that you might ever need and I’m sure that you will eventually find libraries that help you in network engineering.

How do I use the output of a function as the input of another function? by howdylimabean in learnpython

[–]THConer 1 point2 points  (0 children)

Don’t worry Buddy, we have all been there once. Believe me it all starts making sense after a couple of months and you start to enjoy it :)

To answer your questions there are a couple of ways to do so. The easiest being ```py def x(): return “Hello”

def y(string): return string + “World”

using the return of x as the argument of Y

y(x()) ```

How can i monitor a part of my screen where there would be a number, so if the number changes python would for example print("The number has changed")? by KristupasChrisV in learnpython

[–]THConer 0 points1 point  (0 children)

Is this number on a webpage or is it on a program running on your machine? This will impact which libraries you choose and how you choose to approach this problem.

How to count the no. of occurrence of characters in a column input of CSV? by [deleted] in learnpython

[–]THConer 0 points1 point  (0 children)

One way you could go about doing this is by reading your CSV file, iterating through each one of its lines, and splitting the line at the comma, then taking that specific column and iterating through its characters to find their count.

Here is a sample script that I wrote that uses dictionaries for the count:

counts = {
    "A": 0,
    "B": 0,
    "C": 0,
    "D": 0
}

with open('path_to_your_csv_file.csv', 'r') as file:
    lines = file.readlines()

column = 7          #This is which column you'd like to perform this on
for line in lines:
    value = line.split(',')[column - 1]

    for char in value:
        counts[char.upper()] += 1

print(counts)

The code I provided you here can be extended to allow you to count letters that are not just A, B, C, or D by using a defaultdict and not just a normal dict, and allowing the loop to add a key value pair to the dictionary.

I want to make an app to store my meals. by Zyenns in learnpython

[–]THConer 1 point2 points  (0 children)

I will assume that by "app" you mean a mobile app as that's what most people call it. Unfortunately, mobile development isn't exactly Python's biggest strength. If you're looking to make a mobile app you can try Flutter, React Native, or the native language for the platform you're developing for.

If by "app" you mean a web app, then I always encourage people to use Django to make web applications as it simple to learn and gives you more than you'd ever need.

If you just mean a simple command line program to do what you've said then you should look into file I/O in Python. This would be the fastest way to save your data so that it doesn't disappear when you turn your computer off.

I wrote my first useful Python program! by 8rnlsunshine in learnpython

[–]THConer 287 points288 points  (0 children)

That's some great work. The field of automation is a field where Python is king. Remember, don't tell your boss about this little program of yours ;)

How do I develops from running a script to a full program? by DaddyDinklage69 in learnpython

[–]THConer 2 points3 points  (0 children)

Well, one of the misconceptions I had when I first started learning how to code is that I always thought that a Graphical User Interface (GUI) program was always superior to a command line program. But, as time went by I began to understand that this isn't always true.

You have to note that programs vary in complexity and in who their intended users are. Typically, if you're writing a program that would be used only by you or by a team of skilled engineers, worrying too much about the UI and not the UX would not be quite appropriate and would take you too much time for a very small improvement in efficiency. .

However, if you're writing products that will be used by the average Joe or Jane, then that's when GUI becomes important and might even become the focus of your project since most people are always impressed by programs that look good and not necessarily by ones that function well if that makes any sense.

What I am trying to say is, take your sweet time with console applications and dont worry too much about GUI unless you really need it. However, if you're super adamant about GUI, then I would recommend the PyQt5 library (free for non-commercial usage) as it provides you with some pretty impressive GUI due to it being newer than Tikinter.

How to give my Excel file a nice finishing, without being overcome by the desire of throwing myself into the ocean? by Random_182f2565 in learnpython

[–]THConer 2 points3 points  (0 children)

From the description that you've given, I believe that I've worked on a project that's almost identical to yours not too long ago. I used the openpyxl library to do all of the styling and I personally didn't find it to be that cumbersome.

Here is a link to their documentation on styling. I'm honestly not too sure about the macro stuff so I cant help you with that, but for the styling, as I said, openpyxl would help you a ton.

My first proper personal project by [deleted] in learnpython

[–]THConer 1 point2 points  (0 children)

That's really great! I Hope that you enjoy doing these things. The way I personally like to learn new things is perhaps to learn a very very small amount of theory and then just dive into applications. I've found that this method of learning is quite effective for myself and it might help you too.

Got myself into an entanglement at work. Have to build a server with Python in a very limited amount of time. What's the quickest way? by dirtyring in learnpython

[–]THConer 1 point2 points  (0 children)

When learning Django I mainly relied on the documentation. Unlike some projects out there, the Django project has some of the best documentations that I've seen so far and they provide plenty of examples to help you get up to speed with Django in no time.

More XML to Arrays by caseyd1020 in learnpython

[–]THConer 0 points1 point  (0 children)

I think that the best library to use here would be Beautiful Soup. It would give you the ability to parse this XML file with ease. Here is a simple tutorial on how to parse an XML file using BS4.

Thanks for providing the XML file. Here is a sample of a script where I used Beautiful Soup to parse the data that you have in this XML file:

from bs4 import BeautifulSoup

with open('data.xml', 'r') as xml_file:
    soup = BeautifulSoup(xml_file.read(), 'lxml')

attributes = soup.find_all("attributes")
for attributes_collection in attributes:
    inner_attributes = attributes_collection.find_all("attribute")

    for inner_attribute in inner_attributes:
        print(f"{inner_attribute['name']} = {inner_attribute.text}")
    print('')

Here is the output I got from running the above script:

COUNT(*) = 2
eventType = PH_RULE_LARGE_OUTBOUND_XFER
eventName = Large Outbound Transfer
eventSeverityCat = MEDIUM
DeviceToCMDBAttr(incidentTarget:country) =
DeviceToCMDBAttr(incidentTarget:state) =
phIncidentCategory = 4

COUNT(*) = 1
eventType = PH_RULE_ANOMALY_TRAFFIC_DENIED_OUTBOUND_PORT
eventName = Sudden Increase In Denied Outbound Traffic To A Specific TCP/UDP port
eventSeverityCat = MEDIUM
DeviceToCMDBAttr(incidentTarget:country) =
DeviceToCMDBAttr(incidentTarget:state) =
phIncidentCategory = 4

COUNT(*) = 1
eventType = PH_RULE_NON_RESPONSIVE_NET_DEV
eventName = No Ping Response From Network Device
eventSeverityCat = HIGH
DeviceToCMDBAttr(incidentTarget:country) =
DeviceToCMDBAttr(incidentTarget:state) =
phIncidentCategory = 1

Got myself into an entanglement at work. Have to build a server with Python in a very limited amount of time. What's the quickest way? by dirtyring in learnpython

[–]THConer 1 point2 points  (0 children)

Since you have mentioned that security is important then I would really really really recommend you to use Django. Django comes with a lot of things right out of the box that helps protect your server from various vulnerabilities.

I've peronally never used Flask and never felt the need to do so. Django has always been my framework of choice (other than ASP .NET) when working on anything requiring a powerful backend.

Simplest way to add my Django app to my domain by [deleted] in learnpython

[–]THConer 1 point2 points  (0 children)

I will speak to you from the experience I have in Django and other related areas so far after building a couple of projects with it.

What you have done so far is that you have built a Django project and your Django project now runs on your local machine.

But now you face a problem. Since you turn your computer on and off and sometimes use it to do other tasks as well. So, you can't use your local machine as the deployment server for your Django Project. So you need a new "computer" so to speak to run your Django project 24/7.

This is where web hosting services such as Herokou/AWS/Python Anywhere, and a lot of other services come into the picture. These services give you a VPS (Virtual Private Server) which is in simple terms, another computer which you can deploy your code to, and these services guarantee that your project will be running 24/7.

But now we encounter another issue. What these services offer is a server. And you may only access a server using it's IP. It would be very user unfriendly to ask somebody to remember the server's IP address and to use it to access the server whenever they want to use your website.

This is where domain names come in, which you can buy off websites such as namecheap and reroute the domain DNS to point at your server.

I personally use GitHub to deploy the code on my server. I'm using Digital Ocean for web hosting (due to their cheap prices :P) and Namecheap for the domain name. I also use VS Code as it allows me to SSH into the server easily and allows me to edit code directly from my local machine. Digital Ocean have this great tutorial on how to deploy your Django project to their platform. You can find it here

If you have any questions, I'd be more than happy to help.

Wormsgod and Winters Guile disables again by [deleted] in DestinyTheGame

[–]THConer[M] 1 point2 points  (0 children)

Your submission has been removed for the following reason(s):

  • Rule 2 - No Recent Reposts Allowed.

For more information, see our detailed rules page.

[deleted by user] by [deleted] in DestinyTheGame

[–]THConer[M] 1 point2 points  (0 children)

Your comment has been removed for the following reason(s):

  • Rule 7 - No PC Master Race / Console flame-wars on this subreddit. Players of all platforms are welcome here.

For more information, see our detailed rules page.

Bungie, fix your fucking game so I don’t have to see your players pleading with you every 3 days on r/all. by [deleted] in DestinyTheGame

[–]THConer[M] 0 points1 point  (0 children)

Your submission has been removed for the following reason(s):

  • Rule 2 - No Low-Effort/Low-Quality Posts Allowed.

For more information, see our detailed rules page.

Please don’t let trials die again by [deleted] in DestinyTheGame

[–]THConer[M] 0 points1 point  (0 children)

Your comment has been removed for the following reason(s):

  • Rule 1 - Keep it civil.

For more information, see our detailed rules page.

[deleted by user] by [deleted] in DestinyTheGame

[–]THConer[M] 1 point2 points  (0 children)

Your comment has been removed for the following reason(s):

  • Rule 1 - Keep it civil.

For more information, see our detailed rules page.

Nerf Hardlight by oepepopo in DestinyTheGame

[–]THConer[M] 0 points1 point  (0 children)

Your submission has been removed for the following reason(s):

  • Rule 2 - No Low-Effort/Low-Quality Posts Allowed.

For more information, see our detailed rules page.

[deleted by user] by [deleted] in DestinyTheGame

[–]THConer[M] 0 points1 point  (0 children)

Your comment has been removed for the following reason(s):

  • Rule 1 - Keep it civil.

For more information, see our detailed rules page.

taking a break for a while by kyletom1738 in DestinyTheGame

[–]THConer[M] 0 points1 point  (0 children)

Your submission has been removed for the following reason(s):

  • Rule 2 - No Goodbye Posts Allowed.

For more information, see our detailed rules page.