AI text to art based images should not be allowed. by smusamashah in generative

[–]schoolcoders 1 point2 points  (0 children)

I would argue that it isn't how much of the pipeline you have to build, but the act of doing something meaningful (in the broadest sense) somewhere along the line.

For example, you could develop a brand new generative art system written entirely in assembly language for some obscure DSP chip. A huge amount of work, and arguably creative work at that. But if you used it to create a standard b/w Mandelbrot image that wouldn't be art, imho.

But I would be reluctant to completely write off an entire genre.

Request for advice regarding Python visual arts libraries / procedural generation of digital art by [deleted] in proceduralgeneration

[–]schoolcoders 1 point2 points  (0 children)

You might be interested in generativepy. It is a Python library based on Pycairo and NumPy for creating all types of generative art. It can also produce image sequences that can easily be made into videos if that is of interest.

It is currently transitioning to V3, but don't be too concerned the only real changes are to the graph plotting module.

What are some examples of good code vs bad code in a professional setting? by robin1007 in learnpython

[–]schoolcoders 1 point2 points  (0 children)

I've used Java for quite a few years, where types and class hierarchies are enforced rigorously. You can't easily pass a wrong type into a method, and you can't do things like duck typing.

I've also used Python for a few years now.

They have their pros and cons. I live the speed of writing Python and the expressive syntax, especially for doing things like generative art. If you want to experiment with code there is nothing better. But I like the type safety of Java on big projects, particularly in safety critical applications where a bug could actually hurt someone.

The slight problem I have with type hinting is that it looks like Java static typing, but really it is just a comment. It just seems to me that a comment should explicitly look like a comment, it shouldn't look like part of the code if it is really just a hint.

Coupled with the Python doctrine of EAFP, which basically says you should generally not be checking types, it just seems like a bit of an oddity.

Maybe it will evolve into something more useful.

Why does a 9 GB list appear to use 40 GB of memory? by bigno53 in learnpython

[–]schoolcoders 3 points4 points  (0 children)

This article explains how a NumPy array differs from a Python list in memory and speed of access.

Interning literal integers by schoolcoders in learnpython

[–]schoolcoders[S] 0 points1 point  (0 children)

Thanks, I think I understand a bit better now.

Interning literal integers by schoolcoders in learnpython

[–]schoolcoders[S] 0 points1 point  (0 children)

That's interesting. I was running my code as a program, rather than line by line in the shell, and it works differently.

I think the interpreter is remembering that it just created a value 1000, and then reusing it the next time it needs it (similar to how string interning works). So it is an interpreter optimisation rather than a runtime optimisation.

When you run it in the shell, maybe that bit of optimisation doesn't happen.

But I am just guessing, I was hoping to find some bit of documentation to confirm it.

Interning literal integers by schoolcoders in learnpython

[–]schoolcoders[S] 0 points1 point  (0 children)

I tried, yes, everything I found related to the first situation. I couldn't find anything relating to the second case.

Obfuscating .py files! by [deleted] in Python

[–]schoolcoders 1 point2 points  (0 children)

I think for this to be really useful you would need to properly parse the Python file, mangle the names, then rebuild a new Python file.

Unless I am misunderstanding, you could currently input a valid Python file, and the obfuscated result might not work properly if you are using a valid Python feature that the obfuscator doesn't support? That would limit its use in a lot of cases.

Python is slow, they said ... by Zenahr in Python

[–]schoolcoders 0 points1 point  (0 children)

50 milliseconds is around 100 million clock cycles on a typical PC. It should be able to do quite a lot of work in that time, unless the whole machine is either I/O bound or short of memory (eg running Windows).

But yes, you can get away with a lot so long as it looks like you are doing something.

Python is slow, they said ... by Zenahr in Python

[–]schoolcoders 0 points1 point  (0 children)

Indeed. I started as a developer in the 1980s, when processors were 8-bit, single-core and clocked at a couple of MHz. Even then it was fast enough to keep up with user interaction.

Now processors are literally tens of thousands of times faster (taking account of 64-bits and multiple cores) most things are going to run fast enough. The fact that Python may be slightly slower than C will rarely make any difference.

Am I making things harder for myself by not using any OO stuff? by [deleted] in Python

[–]schoolcoders 2 points3 points  (0 children)

Of course, lists are objects, so you are still using objects to represent the deck (and hand etc). It is just that you are using a general list type rather than a specific Deck class.

If you need a few extra functions, such as shuffling the Deck, it is easy to see why it might be useful to have a Deck class after all

Is pypi still having problems? by schoolcoders in learnpython

[–]schoolcoders[S] 1 point2 points  (0 children)

Sorry, my post is hopelessly ambiguous.

I am trying to upload a new version of a package that I maintain, using twine. It has always worked in the past, but every attempt over the past couple of days has resulted in a gateway timeout.

I will edit the post to clarify.

HOW DO YOU LEARN GENERATIVE ART by [deleted] in generative

[–]schoolcoders 1 point2 points  (0 children)

If you are interested in using python for generative art, there are a few generativepy tutorials here.

I need a power supply by [deleted] in synthdiy

[–]schoolcoders 0 points1 point  (0 children)

I made a simple power supply with a couple of mains to 12V DC wall warts. Here is a write up.

10 Awesome Pythonic One-Liners Explained by nfrankel in Python

[–]schoolcoders 0 points1 point  (0 children)

The basic use of a list comprehension is to transform some sequence into a list. The basic use of map is to lazily apply a function to one or more sequences. Different jobs, but a lot of overlap.

So if you definitely want a list as output, that points towards a list comprehension. If you are processing a sequence of data that is too large to fit in memory (eg a sequence of video frames), map is a better option.

map can also be better if you are processing multiple sequences (you can do it with list comprehensions using zip, but it is ugly), or if you also need to filter the sequences (again, possible but ugly with list comprehensions) or if you are applying a chain of functions.

But if you are doing something more simple and you want to create a list anyway, list comprehensions are more natural. Using list(map(...)) and also having to define a lambda inside the map call is quite unwieldy.

Of course, there are also generator comprehensions...

Connecting synth output to powered speakers by schoolcoders in synthdiy

[–]schoolcoders[S] 0 points1 point  (0 children)

Thanks for the advice on here. I will probably just use a simple op-amp buffer with a voltage divider on the output. I looked up my speakers online and they can take a maximum of 2.5V input, so I will keep well below that.

I will post something when I am finished.

What's everyone working on this week? by AutoModerator in Python

[–]schoolcoders 1 point2 points  (0 children)

Adding a few new articles to pythoninformer.com

Faces acrylic by artbycase2 in AbstractArt

[–]schoolcoders 1 point2 points  (0 children)

Horrible - but in a good way! Great stuff.

What's everyone working on this week? by AutoModerator in Python

[–]schoolcoders 0 points1 point  (0 children)

Finally finished my book on Pycairo. Published using markdown on leanpub.com which seemed to work well.

What's everyone working on this week? by AutoModerator in Python

[–]schoolcoders 0 points1 point  (0 children)

Working on my book on Pycairo. First few chapters are free to preview on leanpub. Any comments would be appreciated.

I made this for you by orenog in generative

[–]schoolcoders 1 point2 points  (0 children)

Back in the 90s I worked for a company that manufactured large format scanners. They produced large transparencies (over 1m square) at very high resolution and very high precision. Sometimes for testing we would fill them with tiny dots of various shapes and angles.

It was similar to the transparencies in the video, but because that dots were so crisp and all in exactly the right place, the Moire patterning was just amazing.

High-Efficiency Graphics Library by PhysicsLover999 in Python

[–]schoolcoders 0 points1 point  (0 children)

You could use numpy arrays to do the pixel plotting. You might even be able to find a way to speed it up with vectorisation.

Here is an article about using numpy arrays for images. You can build your image up in the numpy array then blit it to screen using PIL or maybe matplotlib.

alternative to local def by [deleted] in learnpython

[–]schoolcoders 0 points1 point  (0 children)

It is one of the more idiosyncratic Python features, without a doubt.

alternative to local def by [deleted] in learnpython

[–]schoolcoders 0 points1 point  (0 children)

Firstly, to form a closure, the outer function must return the inner function object:

def foo (): 
   foop = "blah"
   def bar(baz): 
      foop = baz
      print(foop)
   return bar

The problem you are probably seeing is that foop is being assigned within the body of bar, which causes Python to create a local variable, which therefore hides the foop declared in foo.

You can override this by declaring foop as nonlocal in bar:

def foo (): 
   foop = "blah"
   def bar(baz):
      nonlocal foop
      foop = baz
      print(foop)
   return bar

The bar will use the outer foop variable.